Ejemplo n.º 1
0
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!delcash.*/', $bot, "delCash");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!addcard.*/', $bot, "addCard");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!delcard.*/', $bot, "delCard");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!dotrade$/', $bot, "doTrade");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!denytrade$/', $bot, "denyTrade");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!accepttrade$/', $bot, "acceptTrade");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!tradeinfo$/', $bot, "tradeInfo");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!gameinfo$/', $bot, "gameInfo");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!startgame$/', $bot, "startGame");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!stopgame\\s/', $bot, "stopGame");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!joingame$/', $bot, "joinGame");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!bankrupt$/', $bot, "bankrupt");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!help$/', $bot, "help");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/^!winneraddress/', $bot, "winnerAddress");
$irc->registerActionHandler(SMARTIRC_TYPE_JOIN, '.*', $bot, "onJoin");
$irc->registerActionHandler(SMARTIRC_TYPE_PART, '.*', $bot, "onQuit");
$irc->registerActionHandler(SMARTIRC_TYPE_KICK, '.*', $bot, "onKick");
$irc->registerActionHandler(SMARTIRC_TYPE_QUIT, '.*', $bot, "onQuit");
$irc->registerActionHandler(SMARTIRC_TYPE_NICKCHANGE, '.*', $bot, "onNickChange");
while (1) {
    $irc->connect("localhost", 7000, true);
    $irc->login("moonopoly", "The Dogecoin Property Trading Game", 8, "tothemoon", '');
    $irc->send("oper username password");
    // oline
    $irc->send("part #services :");
    $irc->message(SMARTIRC_TYPE_QUERY, "nickserv", "identify password");
    $irc->join(array(GAMECHANNEL));
    $irc->send("samode " . GAMECHANNEL . " +Y moonopoly");
    $irc->listen();
    $irc->disconnect();
}
Ejemplo n.º 2
0
// retry if a server connection fails.
$irc->setChannelSyncing(TRUE);
// keep a list of joined users per channel.
$irc->setUseSockets(TRUE);
// uses real sockets instead of fsock().
// send every message type the library supports to our wrapper class.
// we can automate the creation of these actionhandlers, but not the
// class methods below (only PHP 5 supports default methods easily).
$irc_message_types = array('UNKNOWN', 'CHANNEL', 'QUERY', 'CTCP', 'NOTICE', 'WHO', 'JOIN', 'INVITE', 'ACTION', 'TOPICCHANGE', 'NICKCHANGE', 'KICK', 'QUIT', 'LOGIN', 'INFO', 'LIST', 'NAME', 'MOTD', 'MODECHANGE', 'PART', 'ERROR', 'BANLIST', 'TOPIC', 'NONRELEVANT', 'WHOIS', 'WHOWAS', 'USERMODE', 'CHANNELMODE', 'CTCP_REQUEST', 'CTCP_REPLY');
foreach ($irc_message_types as $irc_message_type) {
    $irc->registerActionhandler(constant('SMARTIRC_TYPE_' . $irc_message_type), '.*', $bot, 'invoke_irc_msg_' . strtolower($irc_message_type));
}
// connect and begin listening.
$irc->connect(variable_get('bot_server', 'irc.freenode.net'), variable_get('bot_server_port', 6667));
$irc->login(variable_get('bot_nickname', 'bot_module'), variable_get('bot_nickname', 'bot_module') . ' :http://drupal.org/project/bot', 8, variable_get('bot_nickname', 'bot_module'));
$irc->join(preg_split('/\\s*,\\s*/', variable_get('bot_channels', '#test')));
$irc->listen();
// go into the forever loop - no code after this is run.
$irc->disconnect();
// if we stop listening, disconnect properly.
// pass off IRC messages to our modules via Drupal's hook system.
class drupal_wrapper
{
    function invoke_irc_msg_unknown(&$irc, &$data)
    {
        module_invoke_all('irc_msg_unknown', $data);
    }
    function invoke_irc_msg_channel(&$irc, &$data)
    {
        module_invoke_all('irc_msg_channel', $data);
    }
Ejemplo n.º 3
0
$irc->setDebug(SMARTIRC_DEBUG_NONE);
//$irc->setUseSockets(true);
$irc->setChannelSyncing(true);
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^exit\\s/', $bot, "msgExit");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^info$/', $bot, "msgInfo");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^tipcreate$/', $bot, "msgTipcreate");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^withdraw\\s/', $bot, "msgWithdraw");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^getvip\\s/', $bot, "msgGetvip");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^getad\\s/', $bot, "msgGetad");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '/!/', $bot, "chanMsg");
$irc->registerActionHandler(SMARTIRC_TYPE_ACTION, '/!/', $bot, "chanMsg");
$irc->registerActionHandler(SMARTIRC_TYPE_JOIN, '/\\#dogec0in$/', $bot, "onJoin");
$irc->registerActionHandler(SMARTIRC_TYPE_NICKCHANGE, '.*', $bot, "onNickChange");
while (1) {
    $irc->connect("localhost", 7000, true);
    $irc->login("wowsuchtips", "much tipping", 8, "manydoge", '');
    $irc->send("oper username password");
    // oline
    $irc->send("part #services :");
    $irc->message(SMARTIRC_TYPE_QUERY, "nickserv", "identify password");
    $irc->join(array("#dogec0in", "#dogec0in-vip", "#dogec0in-gamble", "#dogec0in-tip", "#dogec0in-trade"));
    $irc->send("samode #dogec0in +Y wowsuchtips");
    $irc->send("samode #dogec0in-vip +Y wowsuchtips");
    $irc->send("samode #dogec0in-tip +Y wowsuchtips");
    $irc->send("samode #dogec0in-gamble +Y wowsuchtips");
    $irc->send("samode #dogec0in-trade +Y wowsuchtips");
    $irc->setModulepath(".");
    $irc->loadModule("PingFix");
    $irc->listen();
    $irc->disconnect();
}
Ejemplo n.º 4
0
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^identify\\s/', $bot, "msgIdent");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^query(2)?\\s.*/', $bot, "msgQuery");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^ad\\s/', $bot, "msgAd");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^ban\\s/', $bot, "msgBan");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^voice\\s/', $bot, "msgVoice");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^exit\\s/', $bot, "msgExit");
$irc->registerActionHandler(SMARTIRC_TYPE_QUERY, '/^global\\s/', $bot, "msgGlobal");
$irc->registerActionHandler(SMARTIRC_TYPE_CHANNEL, '.*', $bot, "timedChanMsg");
$irc->registerActionHandler(SMARTIRC_TYPE_ACTION, '.*', $bot, "timedChanMsg");
$irc->registerActionHandler(SMARTIRC_TYPE_JOIN, '/\\#dogec0in$/', $bot, "onJoin");
$irc->registerActionHandler(SMARTIRC_TYPE_JOIN, '/\\#dogec0in-vip$/', $bot, "onJoinVip");
$irc->registerActionHandler(SMARTIRC_TYPE_PART, '.*', $bot, "onPart");
$irc->registerActionHandler(SMARTIRC_TYPE_KICK, '.*', $bot, "onKick");
$irc->registerActionHandler(SMARTIRC_TYPE_QUIT, '.*', $bot, "onQuit");
$irc->registerActionHandler(SMARTIRC_TYPE_NICKCHANGE, '.*', $bot, "onNickChange");
$irc->registerTimeHandler(600000, $bot, "adTick");
while (1) {
    $irc->connect("localhost", 7000, true);
    $irc->login("wowsuchdoge", "much coins", 8, "manyshibe", '');
    $irc->send("oper username password");
    // oline
    $irc->send("part #services :");
    $irc->message(SMARTIRC_TYPE_QUERY, "nickserv", "identify password");
    $irc->join(array("#dogec0in", "#dogec0in-vip"));
    $irc->send("samode #dogec0in +Y wowsuchdoge");
    $irc->send("samode #dogec0in-vip +Y wowsuchdoge");
    $irc->setModulepath(".");
    $irc->loadModule("PingFix");
    $irc->listen();
    $irc->disconnect();
}
Ejemplo n.º 5
0
        }
    }
    function markOutgoingMessages($id)
    {
        $set = array('status' => 1);
        $query = $this->fpdo->update('irc_outgoing')->set($set)->where('id', $id)->execute();
    }
    public function msgQueue($irc)
    {
        // Проверяем исходящие сообщения:
        $outgoingMessages = $this->fetchOutgoingMessages($this->settings['irc.nickname'], $this->settings['irc.channel']);
        if ($outgoingMessages) {
            foreach ($outgoingMessages as $arrayMessages) {
                // Отправка сообщения в канал:
                $irc->message(SMARTIRC_TYPE_CHANNEL, $this->settings['irc.channel'], $arrayMessages['message']);
                $this->markOutgoingMessages($arrayMessages['id']);
            }
        }
    }
    public function saveMessage($irc, $data)
    {
        $this->fpdo->insertInto('irc_incoming', array('date' => $this->date, 'nick' => $data->nick, 'host' => $data->ident . "@" . $data->host, 'channel' => $data->channel, 'message' => $data->message, 'to_user' => $this->settings['irc.nickname']))->execute();
    }
}
$irc = new Net_SmartIRC(array('DebugLevel' => SMARTIRC_DEBUG_ALL, 'ChannelSyncing' => true));
$bot = new MyBot($irc);
$irc->connect($bot->settings['irc.server'], $bot->settings['irc.port']);
$irc->login($bot->settings['irc.nickname'], 'teh Client olol', 0, 'ololol');
$irc->join(array($bot->settings['irc.channel']));
$irc->listen();
$irc->disconnect();
Ejemplo n.º 6
0
 /**
  * Join configured channels.
  * If channel name contains space, everything after space is considered channel key.
  *
  * @param Net_SmartIRC $irc
  */
 private function joinChannels(Net_SmartIRC $irc)
 {
     foreach ($this->channels as $prj_id => $options) {
         foreach ($options as $chan => $categories) {
             $parts = explode(' ', $chan, 2);
             if (count($parts) > 1) {
                 // join with key
                 $irc->join($parts[0], $parts[1]);
             } else {
                 $irc->join($chan);
             }
         }
     }
 }
Ejemplo n.º 7
0
    protected function encode($text)
    {
        return mb_convert_encoding($text, mb_internal_encoding(), IRC_ENCODING);
    }
    protected function decode($text)
    {
        return mb_convert_encoding($text, IRC_ENCODING, mb_internal_encoding());
    }
    public static function shortenUrl($matches)
    {
        $url = $matches[0];
        if (defined('BIT_LY_ID') && defined('BIT_LY_API_KEY') && BIT_LY_ID && BIT_LY_API_KEY) {
            $q = 'version=2.0.1&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . BIT_LY_API_KEY;
            $ch = curl_init('http://api.bit.ly/shorten?' . $q);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $result = json_decode(curl_exec($ch), true);
            curl_close($ch);
            if ('OK' === $result['statusCode']) {
                return $result['results'][$url]['shortUrl'];
            }
        }
        return $url;
    }
}
$irc = new Net_SmartIRC();
$twitter = new Twitter(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$bot = new TwitChat($irc, $twitter);
$irc->connect(IRC_HOST, IRC_PORT);
$irc->login(IRC_NICK, IRC_INFO);
$irc->join(array(IRC_CHANNEL));
$irc->listen();