コード例 #1
0
/**
* Title
*
* Description
*
* @access public
*/
 function say($ph, $level=0) {
 global $commandLine;
 global $voicemode;

 /*
  if ($commandLine) {
   echo utf2win($ph);
  } else {
   echo $ph;
  }
  */

  $rec=array();
  $rec['MESSAGE']=$ph;
  $rec['ADDED']=date('Y-m-d H:i:s');
  $rec['ROOM_ID']=0;
  $rec['MEMBER_ID']=0;

  if ($level>0) {
   $rec['IMPORTANCE']=$level;
  }

  SQLInsert('shouts', $rec);

  if ($level>=(int)getGlobal('minMsgLevel')) { //$voicemode!='off' && 

   $lang='en';
   if (defined('SETTINGS_SITE_LANGUAGE')) {
    $lang=SETTINGS_SITE_LANGUAGE;
   }
   if (defined('SETTINGS_VOICE_LANGUAGE')) {
    $lang=SETTINGS_VOICE_LANGUAGE;
   }

   $google_file=GoogleTTS($ph, $lang);
   if ($google_file) {
    @touch($google_file);
    playSound($google_file, 1, $level);
   } else {
    //getObject("alice")->raiseEvent("say", array("say"=>$ph));
    safe_exec('cscript '.DOC_ROOT.'/rc/sapi.js '.$ph, 1, $level);
   }
  }
  postToTwitter($ph);

  global $noPatternMode;
  if (!$noPatternMode) {
   include_once(DIR_MODULES.'patterns/patterns.class.php');
   $pt=new patterns();
   $pt->checkAllPatterns();
  }
 }
コード例 #2
0
/**
* Title
*
* Description
*
* @access public
*/
function say($ph, $level = 0, $member_id = 0)
{
    global $commandLine;
    global $voicemode;
    global $noPatternMode;
    global $ignorePushover;
    global $ignorePushbullet;
    global $ignoreGrowl;
    global $ignoreTwitter;
    /*
    if ($commandLine) {
     echo utf2win($ph);
    } else {
     echo $ph;
    }
    */
    $rec = array();
    $rec['MESSAGE'] = $ph;
    $rec['ADDED'] = date('Y-m-d H:i:s');
    $rec['ROOM_ID'] = 0;
    $rec['MEMBER_ID'] = $member_id;
    if ($level > 0) {
        $rec['IMPORTANCE'] = $level;
    }
    $rec['ID'] = SQLInsert('shouts', $rec);
    if ($member_id) {
        //if (!$noPatternMode) {
        include_once DIR_MODULES . 'patterns/patterns.class.php';
        $pt = new patterns();
        $pt->checkAllPatterns($member_id);
        //}
        return;
    }
    if (defined('SETTINGS_HOOK_BEFORE_SAY') && SETTINGS_HOOK_BEFORE_SAY != '') {
        eval(SETTINGS_HOOK_BEFORE_SAY);
    }
    global $ignoreVoice;
    if ($level >= (int) getGlobal('minMsgLevel') && !$ignoreVoice && !$member_id) {
        //$voicemode!='off' &&
        $lang = 'en';
        if (defined('SETTINGS_SITE_LANGUAGE')) {
            $lang = SETTINGS_SITE_LANGUAGE;
        }
        if (defined('SETTINGS_VOICE_LANGUAGE')) {
            $lang = SETTINGS_VOICE_LANGUAGE;
        }
        if (!defined('SETTINGS_TTS_GOOGLE') || SETTINGS_TTS_GOOGLE) {
            $google_file = GoogleTTS($ph, $lang);
        } else {
            $google_file = false;
        }
        if (!defined('SETTINGS_SPEAK_SIGNAL') || SETTINGS_SPEAK_SIGNAL == '1') {
            $passed = time() - (int) getGlobal('lastSayTime');
            if ($passed > 20) {
                // play intro-sound only if more than 20 seconds passed from the last one
                setGlobal('lastSayTime', time());
                playSound('dingdong', 1, $level);
            }
        }
        if ($google_file) {
            @touch($google_file);
            playSound($google_file, 1, $level);
        } else {
            safe_exec('cscript ' . DOC_ROOT . '/rc/sapi.js ' . $ph, 1, $level);
        }
    }
    if (!$noPatternMode) {
        include_once DIR_MODULES . 'patterns/patterns.class.php';
        $pt = new patterns();
        $pt->checkAllPatterns($member_id);
    }
    if (defined('SETTINGS_PUSHOVER_USER_KEY') && SETTINGS_PUSHOVER_USER_KEY && !$ignorePushover) {
        include_once ROOT . 'lib/pushover/pushover.inc.php';
        if (defined('SETTINGS_PUSHOVER_LEVEL')) {
            if ($level >= SETTINGS_PUSHOVER_LEVEL) {
                postToPushover($ph);
            }
        } elseif ($level > 0) {
            postToPushover($ph);
        }
    }
    if (defined('SETTINGS_PUSHBULLET_KEY') && SETTINGS_PUSHBULLET_KEY && !$ignorePushbullet) {
        include_once ROOT . 'lib/pushbullet/pushbullet.inc.php';
        if (defined('SETTINGS_PUSHBULLET_PREFIX') && SETTINGS_PUSHBULLET_PREFIX) {
            $prefix = SETTINGS_PUSHBULLET_PREFIX . ' ';
        } else {
            $prefix = '';
        }
        if (defined('SETTINGS_PUSHBULLET_LEVEL')) {
            if ($level >= SETTINGS_PUSHBULLET_LEVEL) {
                postToPushbullet($prefix . $ph);
            }
        } elseif ($level > 0) {
            postToPushbullet($prefix . $ph);
        }
    }
    if (defined('SETTINGS_GROWL_ENABLE') && SETTINGS_GROWL_ENABLE && $level >= SETTINGS_GROWL_LEVEL && !$ignoreGrowl) {
        include_once ROOT . 'lib/growl/growl.gntp.php';
        $growl = new Growl(SETTINGS_GROWL_HOST, SETTINGS_GROWL_PASSWORD);
        $growl->setApplication('MajorDoMo', 'Notifications');
        //$growl->registerApplication('http://localhost/img/logo.png');
        $growl->notify($ph);
    }
    if (defined('SETTINGS_TWITTER_CKEY') && SETTINGS_TWITTER_CKEY && !$ignoreTwitter) {
        postToTwitter($ph);
    }
    if (defined('SETTINGS_HOOK_AFTER_SAY') && SETTINGS_HOOK_AFTER_SAY != '') {
        eval(SETTINGS_HOOK_AFTER_SAY);
    }
}
コード例 #3
0
ファイル: common.class.php プロジェクト: vasvlad/majordomo
/**
* Title
*
* Description
*
* @access public
*/
function say($ph, $level = 0)
{
    global $commandLine;
    global $voicemode;
    /*
    if ($commandLine) {
     echo utf2win($ph);
    } else {
     echo $ph;
    }
    */
    $rec = array();
    $rec['MESSAGE'] = $ph;
    $rec['ADDED'] = date('Y-m-d H:i:s');
    $rec['ROOM_ID'] = 0;
    $rec['MEMBER_ID'] = 0;
    if ($level > 0) {
        $rec['IMPORTANCE'] = $level;
    }
    $rec['ID'] = SQLInsert('shouts', $rec);
    if (defined('SETTINGS_HOOK_BEFORE_SAY') && SETTINGS_HOOK_BEFORE_SAY != '') {
        eval(SETTINGS_HOOK_BEFORE_SAY);
    }
    if ($level >= (int) getGlobal('minMsgLevel')) {
        //$voicemode!='off' &&
        $lang = 'en';
        if (defined('SETTINGS_SITE_LANGUAGE')) {
            $lang = SETTINGS_SITE_LANGUAGE;
        }
        if (defined('SETTINGS_VOICE_LANGUAGE')) {
            $lang = SETTINGS_VOICE_LANGUAGE;
        }
        if (!defined('SETTINGS_TTS_GOOGLE') || SETTINGS_TTS_GOOGLE) {
            $google_file = GoogleTTS($ph, $lang);
        } else {
            $google_file = false;
        }
        if (!defined('SETTINGS_SPEAK_SIGNAL') || SETTINGS_SPEAK_SIGNAL == '1') {
            $passed = SQLSelectOne("SELECT (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(ADDED)) as PASSED FROM shouts WHERE ID!='" . $rec['ID'] . "' ORDER BY ID DESC LIMIT 1");
            if ($passed['PASSED'] > 20) {
                // play intro-sound only if more than 30 seconds passed from the last one
                playSound('dingdong', 1, $level);
            }
        }
        if ($google_file) {
            @touch($google_file);
            playSound($google_file, 1, $level);
        } else {
            safe_exec('cscript ' . DOC_ROOT . '/rc/sapi.js ' . $ph, 1, $level);
        }
    }
    global $noPatternMode;
    if (!$noPatternMode) {
        include_once DIR_MODULES . 'patterns/patterns.class.php';
        $pt = new patterns();
        $pt->checkAllPatterns();
    }
    if (defined('SETTINGS_HOOK_AFTER_SAY') && SETTINGS_HOOK_AFTER_SAY != '') {
        eval(SETTINGS_HOOK_AFTER_SAY);
    }
    if (defined('SETTINGS_PUSHOVER_USER_KEY') && SETTINGS_PUSHOVER_USER_KEY) {
        include_once ROOT . 'lib/pushover/pushover.inc.php';
        if (defined('SETTINGS_PUSHOVER_LEVEL')) {
            if ($level >= SETTINGS_PUSHOVER_LEVEL) {
                postToPushover($ph);
            }
        } elseif ($level > 0) {
            postToPushover($ph);
        }
    }
    if (defined('SETTINGS_GROWL_ENABLE') && SETTINGS_GROWL_ENABLE && $level >= SETTINGS_GROWL_LEVEL) {
        include_once ROOT . 'lib/growl/growl.gntp.php';
        $growl = new Growl(SETTINGS_GROWL_HOST, SETTINGS_GROWL_PASSWORD);
        $growl->setApplication('MajorDoMo', 'Notifications');
        //$growl->registerApplication('http://localhost/img/logo.png');
        $growl->notify($ph);
    }
    postToTwitter($ph);
}