BeBot - An Anarchy Online and Age Of Conan chat automaton

General => Feedback and Suggestions => Topic started by: Tichy on September 12, 2007, 10:56:54 am

Title: same output of ig/IRC !online command
Post by: Tichy on September 12, 2007, 10:56:54 am
I have multiple org bots running on the same database and relaying to each other. The !online command is configured to show the buddies of all bots. If one does  !online from IRC you will only get the online buddies of the bot relaying to IRC.

Small patch to work like the OnlineDisplay module:

Code: [Select]
--- DNWCom/modules/IRC.php      2007-07-29 19:20:45.000000000 +0200
+++ FECom/modules/IRC.php       2007-09-11 14:19:17.000000000 +0200
@@ -800,8 +800,27 @@
        */
        function irc_online(&$irc, &$data)
        {
-               $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE botname = '" . $this -> bot -> botname
-               . "' AND status_gc = 1 ORDER BY nickname ASC");
+               if ($this -> bot -> settings -> get("Online", "Otherbots") != "")
+               {
+                       $bots = explode(",", $this -> bot -> settings -> get("Online", "Otherbots"));
+                       $botnames = array();
+                       foreach ($bots as $bot)
+                       {
+                               // Only use valid botnames
+                               if ($this -> bot -> aoc -> get_uid(trim($bot)))
+                               {
+                                       $botnames[] = "botname = '" . trim($bot) . "'";
+                               }
+                       }
+                       $botnames[] = "botname = '" . $this -> bot -> botname . "'";
+                       $botstring = "(" . implode(" OR ", $botnames) . ")";
+               }
+               else
+               {
+                       $botstring = "botname='" .  $this -> bot -> botname . "'";
+               }
+
+               $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE $botstring AND status_gc = 1 ORDER BY nickname ASC");
                if (empty($online))
                {
                        $msg = "Nobody online!";

Maybe there is some additional checking needed if the OnlineDisplay module is installed.


Regards,
Tichy
SimplePortal 2.3.7 © 2008-2024, SimplePortal