function udpmsg4_do($p) { if ($p === FALSE || $p === NULL) { return $p; } if (!is_a($p, 'udpmsg4_packet')) { $p = udpmsg4_packet::parse($p); } if ($p === FALSE || $p === NULL) { return $p; } if (!isset($p['CMD'])) { return TRUE; } if ($this->config['nick'] !== $this->config['nicks'][0]) { switch ($p['CMD']) { case 'X-srn.ano-relaystatus': if ($this->ircchannel2channel($this->config['nicks'][0]) === $p['SRC']) { $this->last_relay_alive_time = time(); } } return TRUE; } switch ($p['CMD']) { case 'JOIN': if (isset($this->config['kicked'][$p['DST']][$p['SRC']])) { unset($this->config['kicked'][$p['DST']][$p['SRC']]); return $this->write_client_irc_from_client('PRIVMSG', array($this->channel2ircchannel($p['DST']), 'unkicked ' . $p['SRC'])); } case 'ALIVE': case 'PART': case 'QUIT': return TRUE; case 'MSG': $icare = 0; if ($this->is_channel($p['DST'])) { if (isset($this->config['channels'][$p['DST']])) { $icare = 1; } else { } } else { $icare = 1; } if ($icare && !isset($this->config['kicked'][$p['DST']][$p['SRC']])) { $ircchan = $this->channel2ircchannel($p['DST']); if ($this->map_function !== NULL && !$this->is_channel($p['DST'])) { $ircchan = $this->map_nick($ircchan); } if (@$this->config['colors'] != NULL) { $cnick = isset($this->config['colors']['nick']) ? $this->config['colors']['nick'] : chr(3) . '05'; $carrow = isset($this->config['colors']['arrow']) ? $this->config['colors']['arrow'] : chr(3) . '08'; $cmsg = isset($this->config['colors']['message']) ? $this->config['colors']['message'] : chr(15); $msg = $cnick . $p['SRC'] . $carrow . '> ' . $cmsg . $p['MSG']; } else { $msg = $p['SRC'] . '> ' . $p['MSG']; } if (isset($this->config['badregexes'])) { foreach ($this->config['badregexes'] as $regex) { $msg = preg_replace($regex . 'e', '"[ ".implode(" ",str_split("$0"))." ]"', $msg); } } return $this->write_client_irc_from_client('PRIVMSG', array($ircchan, $msg)); } return TRUE; case 'ENC': return TRUE; default: debug('udpmsg4', 1, "received CMD=" . $p['CMD']); return TRUE; return FALSE; } }
function udpmsg4_do($p) { if ($p === FALSE || $p === NULL) { return $p; } if (!is_a($p, 'udpmsg4_packet')) { $p = udpmsg4_packet::parse($p); } if ($p === FALSE || $p === NULL) { return $p; } if (!isset($p['CMD'])) { return TRUE; } switch ($p['CMD']) { case 'ALIVE': return TRUE; case 'JOIN': return TRUE; case 'PART': return TRUE; case 'QUIT': return TRUE; case 'MSG': switch ($p['DST']) { case 'chat/talk': case 'chat/anonet': if ($p['MSG'] === "I'm hungry.") { $this->config['hungry'][$p['SRC']] = 1; return $this->send_message($p['DST'], "srnbot: I'm hungry."); } else { if ($this->nick2shortnick($p['SRC']) === 'sevilBot') { if (preg_match('/bagged a ([0-9.KkGg]+) (.*)\\.$/', $p['MSG'], $m)) { if (($hungry = $this->find_next_hungry()) === NULL) { return $this->send_message($p['DST'], 'Nobody else is hungry so I can eat the ' . $m[2] . '.'); } unset($this->config['hungry'][$hungry]); return $this->send_message($p['DST'], $hungry . ': Now you can enjoy to eat your ' . $m[1] . ' ' . $m[2] . '.'); } else { if (preg_match('/ missed /', $p['MSG'])) { if (($hungry = $this->find_next_hungry()) === NULL) { return $this->send_message($p['DST'], 'It does not matter.'); } return $this->send_message($p['DST'], 'srnbot: You suck. Now I need to clean my gun for that ' . $hungry . ' will eat.') && $this->send_message($p['DST'], '!hunt'); } else { if (preg_match('/hogging all the best pitches (.*?), /', $p['MSG'], $m)) { if (($hungry = $this->find_next_hungry()) === NULL) { return $this->send_message($p['DST'], 'It does not matter.'); } if ($m[1] === $this->nick()) { return $this->send_message($p['DST'], 'srnbot: I\'m hungry.'); } return $this->send_message($p['DST'], 'LOL, k, ' . $m[1] . ' should rest.') && $this->send_message($p['DST'], $hungry . ': No worry, I will try to hunt for you.') && $this->send_message($p['DST'], '!hunt'); } else { return TRUE; } } } } } } return TRUE; case 'ENC': return TRUE; default: debug('udpmsg4', 1, "received CMD=" . $p['CMD']); return TRUE; } }
function parse_unframed_nocrypt(&$b) { return udpmsg4_packet::parse($b); }
function udpmsg4_do($p) { /* :dBZ!user@949DD1.5D28CF.4EA2CF.F6DE5C QUIT :irc5.srn.ano pbx.namek.ano :dBZ!user@949DD1.5D28CF.4EA2CF.F6DE5C JOIN :#anonet :/A1/dBZ QUIT :irc.r101.ano irc5.srn.ano :/A1/dBZ!dBZ@dBZ JOIN :#anonet */ if ($p === FALSE || $p === NULL) { return $p; } if (!is_a($p, 'udpmsg4_packet')) { $p = udpmsg4_packet::parse($p); } if ($p === FALSE || $p === NULL) { return $p; } if (!isset($p['CMD'])) { return TRUE; } switch ($p['CMD']) { case 'ALIVE': if ($this->user_is_joined($p['SRC'], $p['DST'])) { return TRUE; } case 'JOIN': if ($this->user_is_joined($p['SRC'], $p['DST'])) { $icare = 0; $this->quit_user($p['SRC'], $icare); if ($icare) { $this->write_client_irc_quit($p['SRC'], 'received JOIN to ' . $p['DST']); } } if (!$this->user_is_joined($p['SRC'], $p['DST'])) { $this->join_user_to_channel($p['SRC'], $p['DST']); } $icare = 0; if ($this->am_joined($p['DST'])) { $icare = 1; } if ($this->nick() === $p['SRC']) { $icare = 0; } if ($icare) { $this->write_client_irc_join($p['SRC'], $p['DST']); } return TRUE; case 'PART': if ($p['BC']) { return TRUE; } if ($this->nick() === $p['SRC']) { return TRUE; } $icare = 0; if ($this->user_is_joined($p['SRC'], $p['DST'])) { $this->part_user_from_channel($p['SRC'], $p['DST']); if ($this->am_joined($p['DST'])) { $icare = 1; } } if ($icare) { $ircchannel = $this->channel2ircchannel($p['DST']); $this->write_client_irc_part($p['SRC'], $p['DST'], $p['REASON']); } return TRUE; case 'QUIT': if ($this->nick() === $p['SRC']) { return TRUE; } $icare = 0; $this->quit_user($p['SRC'], $icare); if ($icare) { $this->write_client_irc_quit($p['SRC'], $p['REASON']); } return TRUE; case 'MSG': $icare = 0; if ($this->am_joined($p['DST'])) { $icare = 1; } if ($this->is_channel($p['DST']) && !$this->user_is_joined($p['SRC'], $p['DST'])) { $this->join_user_to_channel($p['SRC'], $p['DST']); if ($icare) { $this->write_client_irc_join($p['SRC'], $p['DST']); } } if ($p['DST'] === $this->nick()) { $icare = 1; } if ($icare) { $ircchan = $this->chan2ircwire($p['DST']); $this->write_client_irc($this->fullnick($p['SRC']), 'PRIVMSG', array($ircchan, $p['MSG'])); } return TRUE; case 'NOTICE': $icare = 0; if ($this->am_joined($p['DST'])) { $icare = 1; } if ($p['DST'] === $this->nick()) { $icare = 1; } if ($icare) { $ircchan = $this->chan2ircwire($p['DST']); $this->write_client_irc($this->fullnick($p['SRC']), 'NOTICE', array($ircchan, $p['MSG'])); } return TRUE; case 'ENC': return TRUE; case 'TOPIC': $this->set_channel_topic($p['DST'], $p['TOPIC'], $p['SRC']); $icare = 0; if ($this->am_joined($p['DST'])) { $icare = 1; } if ($this->is_channel($p['DST']) && !$this->user_is_joined($p['SRC'], $p['DST'])) { $this->join_user_to_channel($p['SRC'], $p['DST']); if ($icare) { $this->write_client_irc_join($p['SRC'], $p['DST']); } } if ($p['SRC'] === $this->nick()) { $icare = 1; } if ($icare) { $this->write_client_irc_topic($p['SRC'], $p['DST'], $p['TOPIC']); } return TRUE; default: debug('udpmsg4', 1, "received CMD=" . $p['CMD']); return TRUE; } }