public final function Test(BotEvent $event) { $message = $event->GetMessage(); if (preg_match("#^(\\s*" . $this->trigger . "(\\s+|\$))#i", $message, $match)) { $message = substr($message, strlen($match[1])); $event->SetMessage($message); return true; } return false; }
public function Reply(BotEvent $event) { if ($event->GetIsPrivate()) { return; } $message = $event->GetMessage(); $reply = trim($message); if (!empty($reply)) { return new BotMessage($event->GetDestination(), $reply); } }
/** * Reply to the operation. * @param $event event that triggered the operation. * @return BotMessage with magic 8's answer. */ public function reply(BotEvent $event) { $sender = $event->getSender(); $message = $event->getMessage(); if (preg_match("/([^\\s]+)\\s+ou\\s+([^\\s?]+)/i", $message)) { $responses = spliti(" ou ", $message); } else { $responses = $this->responses; } $response = mt_rand(0, count($responses) - 1); $reply = $responses[$response]; $reply = trim(str_replace("?", "", $reply)); if ($event->isPrivate()) { $destination = $sender; } else { $reply = "{$sender}: {$reply}"; $destination = $event->getDestination(); } return new BotMessage($destination, $reply); }
/** * Reply to the operation. * @param $event event that triggered the operation. * @return BotMessage with bot statistics. */ public function reply(BotEvent $event) { $sender = $event->getSender(); $uptime = time() - $event->getBot()->getStartTime(); $repliesAmount = $event->getBot()->getRepliesCounter(); $timeUnits = array('dia' => 86400, 'hora' => 3600, 'minuto' => 60, 'segundo' => 1); $tmp = $uptime; $msg = ""; foreach ($timeUnits as $name => $seconds) { $calc = floor($tmp / $seconds); $tmp -= $calc * $seconds; if ($calc > 0) { $msg .= "{$calc} {$name}"; if ($calc > 1) { $msg .= "s"; } $msg .= " e "; } } $reply = "Estou vivo ha {$msg} respondi a {$replies} mensagens ate agora."; if ($event->isPrivate()) { $destination = $sender; } else { $reply = "{$sender}: {$reply}"; $destination = $event->getDestination(); } return new BotMessage($destination, $reply); }
public function Reply(BotEvent $event) { $sender = $event->GetSender(); if ($event->GetIsPrivate()) { $destination = $sender; $password = $event->GetMessage(); if (!empty($password)) { if ($password === BotConfig::$PASSWORD["quit"]) { $event->GetBot()->Disconnect(); return; } else { $reply = "Senha incorreta."; } } else { $reply = "Uso: " . $this->GetTrigger() . " senha"; } } else { $destination = $event->GetDestination(); $reply = "{$sender}: essa operação deve ser feita em mensagem privada."; } return new BotMessage($destination, $reply); }
public function Reply(BotEvent $event) { $sender = $event->GetSender(); if ($event->GetIsPrivate()) { $destination = $sender; $message = $event->GetMessage(); $message = explode(" ", $message); if (count($message) >= 3) { list($channel, $password) = $message; if (!empty($password)) { if ($password === BotConfig::$PASSWORD["join"]) { $event->GetBot()->GetIRC()->JoinChannel($channel); return; } else { $reply = "Senha incorreta."; } } else { $reply = "Uso: " . $this->GetTrigger() . " #canal senha"; } } else { $reply = "Uso: " . $this->GetTrigger() . " #canal senha"; } } else { $destination = $event->GetDestination(); $reply = "{$sender}: essa operação deve ser feita em mensagem privada."; } return new BotMessage($destination, $reply); }