示例#1
0
 function trigger($processed_data)
 {
     if ($processed_data['IRC_TYPE'] == 'none') {
         return false;
     }
     $trigger = explode(' ', trim($processed_data['message']));
     if (($k = $this->find_trigger($trigger[0], $processed_data['type'])) !== false) {
         // throttle spam and such.
         if ($this->throttle($processed_data)) {
             return;
         }
         if ($processed_data['type'] == 'msg') {
             $this->main->log(Bashful::bold() . $trigger[0] . Bashful::unbold() . ' on ' . $processed_data['type'] . ' triggered by ' . Bashful::blue() . $processed_data['nick'] . Bashful::unblue(), __CLASS__);
         }
         $k = $this->registered_triggers[$k];
         $k['module'] = strtolower($k['module']);
         if ($k['exec'] !== false && method_exists($this->modules[$k['module']], $k['exec'])) {
             $this->modules[$k['module']]->{$k['exec']}($processed_data);
             return true;
         } elseif (method_exists($this->modules[$k['module']], 'call')) {
             $this->modules[$k['module']]->call($processed_data);
             return true;
         }
         $this->main->log('Error: Trigger specified, but no route found for \'' . $k['module'] . '->' . $trigger . '\'', __CLASS__);
     }
     return false;
 }
示例#2
0
    define('STDIN', fopen('php://stdin', 'r'));
}
stream_set_blocking(STDIN, false);
require_once INCLUDE_PATH . 'mootyconf.php';
require_once INCLUDE_PATH . 'bashful.php';
require_once INCLUDE_PATH . 'deer.php';
require_once CORE_PATH . 'defines.php';
require_once CORE_PATH . 'ircine.php';
require_once CORE_PATH . 'ircine.core.php';
require_once CORE_PATH . 'ircine.module.php';
require_once CORE_PATH . 'ircine.connection.php';
require_once CORE_PATH . 'ircine.input.php';
function load_mooty($serverconfig)
{
    Mootyconf::read($serverconfig, 'plugins.conf') or die($usage . Bashful::c('bold', 'red') . '        ERROR:' . Bashful::reset() . ' Could not read config ' . $conf . '.' . PHP_EOL . PHP_EOL);
}
$conf = 'deerkins.conf';
$usage = PHP_EOL . '        USAGE: php deerkins.php ' . Bashful::bold() . '-c deer.conf' . Bashful::unbold() . PHP_EOL;
$opts = getopt('c:h::');
if (isset($opts['h'])) {
    die($usage . PHP_EOL);
}
if (isset($opts['c']) && $opts['c'] != '') {
    $conf = $opts['c'];
} else {
    die($usage . PHP_EOL);
}
load_mooty($conf);
$ircine = new IRCine($conf);
echo "Bot has been shut down\r\n";
exit;
示例#3
0
文件: deerme.php 项目: unnes/deerkins
 function deer($processed_data)
 {
     if (($type = $this->is_banned($processed_data)) !== false) {
         $this->log(Bashful::c('bold', 'red') . 'Banned' . Bashful::reset() . ': ' . Bashful::bold() . $processed_data['nick'] . Bashful::unbold() . '@' . $processed_data['host'] . ' on ' . $processed_data['replyto'] . ' (' . $type . ': ' . $processed_data[$type] . ')');
         return;
     }
     $replyto = $processed_data['recepient'];
     $privileged = $this->is_privileged($processed_data);
     if (strpos($replyto, '#') !== 0 && $privileged == false) {
         $this->log('Ignoring deerme in priv');
         return;
     }
     $timer_to = 'cake';
     //$timer_to = $replyto; // TODO: make this channel specific!
     if (!isset($this->deer_used[$timer_to])) {
         $this->deer_used[$timer_to] = false;
     }
     $requested_deer = $this->strip_command($processed_data['message']);
     if ($requested_deer == '') {
         $requested_deer = 'deer';
     }
     $mods_deer = $this->get_mods($requested_deer);
     $mods_deer == !empty($mods_deer) ? $mods_deer : array();
     $requested_deer = $this->strip_mods($requested_deer);
     $timeout = $this->deer_timeout;
     // check for samedeer or samenick. Add timeout as punishment.
     if ($replyto == $this->last['channel'] && $processed_data['nick'] == $this->last['nick'] || $requested_deer != 'random' && $replyto == $this->last['channel'] && $requested_deer == $this->last['deer'] && array_diff($mods_deer, $this->last['modifiers']) == array()) {
         $timeout = $timeout * $this->timeout_punish;
     }
     // if person is in NICELIST, completely ignore the punishment! :D:D:D
     $timeout = $privileged != false && is_numeric($privileged['timeout']) ? $privileged['timeout'] : $timeout;
     // if privileged, undo punish!
     if ($requested_deer == 'help') {
         $deertime = !isset($this->deer_used[$timer_to]) || $this->deer_used[$timer_to] + $timeout < microtime(true) ? 'Ready to deer!' : floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds until deer.';
         $this->notice($processed_data['nick'], chr(02) . 'How to deer:' . chr(02) . ' Type deerme <mods>|<deer> to deer or deerme help modifiers for available mods. (' . Deer::count_deer() . ' deer total) ' . chr(02) . 'Status: ' . chr(02) . $deertime . ' ' . chr(02) . 'Create your own: ' . chr(02) . $this->deeritor, IRCINE_PRIO_MEDIUM);
         return;
     }
     if ($requested_deer == 'help modifiers') {
         $modifiers = Deer::$deer_modifiers;
         $mods = array();
         foreach ($modifiers as $mod => $name) {
             $mods[] = $mod . '(=' . $name . ')';
         }
         $mods = implode(', ', $mods);
         $this->notice($processed_data['nick'], chr(02) . 'Available modifiers: ' . chr(02) . $mods . '.', IRCINE_PRIO_MEDIUM);
         return;
     }
     if ($this->deer_used[$timer_to] + $timeout > microtime(true)) {
         $this->log('Deer called, but deer not so fast :(');
         if ($timeout < $this->deer_timeout) {
             $this->notice($processed_data['nick'], 'You are privileged! You have LOWER timeout than others (-' . ($this->deer_timeout - $timeout) . ' seconds), which is like ' . floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds from now, bro.', IRCINE_PRIO_MEDIUM);
         } elseif ($timeout > $this->deer_timeout) {
             $this->notice($processed_data['nick'], 'You have somehow been punished! You have HIGHER timeout than others (+' . ($timeout - $this->deer_timeout) . ' seconds), which is like <CENSORED> seconds from now, bro.', IRCINE_PRIO_MEDIUM);
         } elseif ($timeout == $this->deer_timeout) {
             $this->notice($processed_data['nick'], 'Deer called, but deer not so fast :( It only walks the earth every ' . $timeout . ' seconds, which is like ' . floor($this->deer_used[$timer_to] - microtime(true) + $timeout) . ' seconds from now, bro.', IRCINE_PRIO_MEDIUM);
         }
         return;
     }
     // fetch deer from db
     $deer = Deer::get_deer($requested_deer);
     if (empty($deer)) {
         $this->log('No such deer.');
         $this->say($replyto, '404: Deer Not Found. Go to ' . $this->deeritor . ' and create it.', IRCINE_PRIO_MEDIUM);
         return;
     }
     // apply modifier, turn into IRC
     $data = explode(PHP_EOL, Deer::parse_deer(Deer::apply_modifiers($deer['kinskode'], $mods_deer)));
     foreach ($data as $line) {
         $this->say($replyto, $line, IRCINE_PRIO_MEDIUM);
         // TODO: THROTTLE THIS BITCH?
     }
     $used_mods = in_array('x', $mods_deer) ? Deer::$x_last_mods : $mods_deer;
     $used_mods_friendly = empty($used_mods) ? '' : ' (' . implode(', ', $used_mods) . ')';
     if (strtolower($requested_deer) == 'random') {
         $this->say($replyto, $deer['deer'] . ' by ' . $deer['creator'] . $used_mods_friendly, IRCINE_PRIO_MEDIUM);
     }
     $this->log('Deer "' . $deer['deer'] . '" is walking in ' . $replyto . '!');
     $this->deer_used[$timer_to] = microtime(true);
     $this->last = array('deer' => $deer['deer'], 'nick' => $processed_data['nick'], 'channel' => $replyto, 'creator' => $deer['creator'], 'modifiers' => $used_mods);
 }
示例#4
0
文件: ircine.php 项目: unnes/deerkins
 function log($msg, $handler = __CLASS__)
 {
     $prefix = strpos($msg, '<--') === false && strpos($msg, '-->') === false ? ' -!- ' : ' ';
     $msg = str_replace(array("\n", "\r"), '', $msg);
     if (is_object($handler)) {
         $handler = get_class($handler);
     } elseif (!$handler) {
         $handler = get_class($this);
     }
     $log = date("Y-m-d H:i:s") . ' ' . Mootyconf::get_value('deerkins::nick') . ' ( ' . $handler . ' ) !? ' . $prefix . $msg;
     $output = date("Y-m-d H:i:s") . ' ' . Mootyconf::get_value('deerkins::nick') . ' ' . Bashful::bold() . '(' . Bashful::unbold() . ' ' . $handler . ' ' . Bashful::bold() . ')' . Bashful::unbold() . $prefix . $msg;
     if ($this->debuglevel == IRCINE_DEBUG_HIGH || $this->debuglevel == IRCINE_DEBUG_MEDIUM) {
         if (!@fwrite($this->log_handle, $log . PHP_EOL)) {
             $output .= " [NO LOG]";
         }
     }
     echo $output . PHP_EOL;
 }