public function Reply(BotEvent $event) { $sender = $event->GetSender(); $uptime = time() - $event->GetBot()->GetStartTime(); $replies_counter = $event->GetBot()->GetRepliesCounter(); $time_units = array('dia' => 86400, 'hora' => 3600, 'minuto' => 60, 'segundo' => 1); $tmp = $uptime; $msg = ""; foreach ($time_units 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 há {$msg}" . "respondi à {$replies_counter} mensagens até agora."; if ($event->GetIsPrivate()) { $destination = $sender; } else { $reply = "{$sender}: {$reply}"; $destination = $event->GetDestination(); } return new BotMessage($destination, $reply); }
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->GetIsPrivate()) { $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); }