コード例 #1
0
ファイル: context.inc.php プロジェクト: NioFBI/majordomo
function context_activate($id, $no_action = 0, $history = '')
{
    $user_id = context_getuser();
    $user = SQLSelectOne("SELECT * FROM users WHERE ID='" . (int) $user_id . "'");
    $user['ACTIVE_CONTEXT_ID'] = $id;
    $user['ACTIVE_CONTEXT_EXTERNAL'] = 0;
    $user['ACTIVE_CONTEXT_UPDATED'] = date('Y-m-d H:i:s');
    if ($history) {
        $user['ACTIVE_CONTEXT_HISTORY'] .= ' ' . $history;
    }
    SQLUpdate('users', $user);
    if ($id) {
        //execute pattern
        $context = SQLSelectOne("SELECT * FROM patterns WHERE ID='" . (int) $id . "'");
        $timeout = $context['TIMEOUT'];
        if (!$timeout) {
            $timeout = 60;
        }
        setTimeOut('user_' . $user_id . '_contexttimeout', 'context_timeout(' . $context['ID'] . ', ' . $user_id . ');', $timeout);
        if (!$no_action) {
            include_once DIR_MODULES . 'patterns/patterns.class.php';
            $pt = new patterns();
            $pt->runPatternAction($context['ID']);
        }
    } else {
        context_clear();
        clearTimeOut('user_' . $user_id . '_contexttimeout');
    }
}
コード例 #2
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();
  }
 }
コード例 #3
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);
    }
}
コード例 #4
0
ファイル: command.php プロジェクト: cdkisa/majordomo
$session = new session("prj");
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
include_once "./load_settings.php";
Define('DEVIDER', 'и');
$sqlQuery = "SELECT MESSAGE\n               FROM shouts\n              WHERE MEMBER_ID = 0\n              ORDER BY ID DESC\n              LIMIT 1";
$lastest_word = current(SQLSelectOne($sqlQuery));
if ($qry != '' && $qry != $lastest_word) {
    if (!$session->data['logged_user']) {
        $user = SQLSelectOne("SELECT ID FROM users ORDER BY ID");
        $user_id = $user['ID'];
    } else {
        $user_id = $session->data['logged_user'];
    }
    include_once DIR_MODULES . 'patterns/patterns.class.php';
    $pt = new patterns();
    $qrys = explode(' ' . DEVIDER . ' ', $qry);
    $total = count($qrys);
    for ($i = 0; $i < $total; $i++) {
        $room_id = 0;
        $rec = array();
        $rec['ROOM_ID'] = (int) $room_id;
        $rec['MEMBER_ID'] = $user_id;
        $rec['MESSAGE'] = htmlspecialchars($qrys[$i]);
        $rec['ADDED'] = date('Y-m-d H:i:s');
        SQLInsert('shouts', $rec);
        $res = $pt->checkAllPatterns($rec['MEMBER_ID']);
        if (!$res) {
            processCommand($qrys[$i]);
        }
    }
コード例 #5
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);
}
コード例 #6
0
ファイル: command.php プロジェクト: novozhenets/majordomo
}


Define('DEVIDER', 'и');

if ($qry!='') {

   if (!$session->data['logged_user']) {
    $user=SQLSelectOne("SELECT ID FROM users ORDER BY ID");
    $user_id=$user['ID'];
   } else {
    $user_id=$session->data['logged_user'];
   }

   include_once(DIR_MODULES.'patterns/patterns.class.php');
   $pt=new patterns();

   $qrys=explode(' '.DEVIDER.' ', $qry);
   $total=count($qrys);
   for($i=0;$i<$total;$i++) {

    $room_id=0;
    $rec=array();
    $rec['ROOM_ID']=(int)$room_id;
    $rec['MEMBER_ID']=$user_id;
    $rec['MESSAGE']=htmlspecialchars($qrys[$i]);
    $rec['ADDED']=date('Y-m-d H:i:s');
    SQLInsert('shouts', $rec);

    $pt->checkAllPatterns();
    getObject("ThisComputer")->raiseEvent("commandReceived", array("command"=>$qrys[$i]));