BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => BeBot 0.4 support => Topic started by: Tichy on October 08, 2007, 03:40:37 pm

Title: !whois and !online (IRC) broken
Post by: Tichy on October 08, 2007, 03:40:37 pm
Since upgrading to 0.4.2 two functions are broken:

The Details window on whois querys contains broken char details:

Code: [Select]
:::  T '##T##T' T  :::
 Level: T
 Defender Rank: T (T)
 Breed: T
 Gender: T
 Profession: T
 Organization: T
 Organization Rank: T
 Status: Unknown

This results from a bad call of the whois_details function in the Whois core class by the Whois module. Patch:

Code: [Select]
--- ../Bebot 0.4.2/modules/Whois.php    2007-10-02 23:02:00.000000000 +0200
+++ modules/Whois.php   2007-10-08 15:30:07.000000000 +0200
@@ -189,7 +189,7 @@
                                                $result .= " :: Alt of $main";
                                        }
                                }
-                               $result .= " :: " . $this -> bot -> whois -> whois_details($source, $who);
+                               $result .= " :: " . $this -> bot -> whois -> whois_details($who);
                        }
                        else if ($this -> bot -> settings -> get("Whois", "Alts") == TRUE)
                        {

In the upstream version whois_details($who) is replaced with whois_details($source, $who), but whois_details takes only one parameter.




When doing a !online in IRC and the Chat setting of the IRC module is set to both, you always get two answers. There is a missing "else" before the second "if" statement in modules/IRC.php, patch:

Code: [Select]
--- ../Bebot 0.4.2/modules/IRC.php      2007-09-27 15:52:00.000000000 +0200
+++ modules/IRC.php     2007-10-08 15:35:00.000000000 +0200
@@ -822,7 +822,7 @@
                        $this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $target, $msg);
                }

-               if ((strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "both") ||
+               else if ((strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "both") ||
                (strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "pgroup"))
                {
                        $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE botname = '" . $this -> bot -> botname
Title: Re: !whois and !online (IRC) broken
Post by: Alreadythere on October 08, 2007, 04:09:47 pm
The first clearly is a bug, the second is a feature though.
If you relay between gc and pgroup to irc it's supposed to show both online members and characters in the chat group.

Fixed the whois module (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/modules/Whois.php?view=co).
Title: Re: !whois and !online (IRC) broken
Post by: Tichy on October 08, 2007, 04:36:55 pm
You are right, but i think it should be corrected that it replies only one answer if Chat is set to 'both'. Guys always asking me why the bot replies with two answers ::)

So I propose the following patch:

Code: [Select]
--- ../Bebot 0.4.2/modules/IRC.php      2007-09-27 15:52:00.000000000 +0200
+++ modules/IRC.php     2007-10-08 16:27:45.000000000 +0200
@@ -799,41 +799,26 @@
                        $target = $this -> bot -> settings -> get("Irc", "Channel");
                }

+               $where = array();
                if ((strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "both") ||
                (strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "gc"))
-               {
-                       $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE botname = '" . $this -> bot -> botname
-                       . "' AND status_gc = 1 ORDER BY nickname ASC");
-                       if (empty($online))
-                       {
-                               $msg = "Nobody online on notify!";
-                       }
-                       else
-                       {
-                               $msg = count($online) . " players online on notify: ";
-                               $msgs = array();
-                               foreach ($online as $name)
-                               {
-                                       $msgs[] = $name[0];
-                               }
-                               $msg .= implode(", ", $msgs);
-                       }
-
-                       $this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $target, $msg);
-               }
+                   $where[] = "status_gc = 1";

                if ((strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "both") ||
                (strtolower($this -> bot -> settings -> get("Irc", "Chat")) == "pgroup"))
+                   $where[] = "status_pg = 1";
+
+               if (!empty($where))
                {
-                       $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE botname = '" . $this -> bot -> botname
-                       . "' AND status_pg = 1 ORDER BY nickname ASC");
+                       $online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE ".$this -> bot -> online -> otherbots()
+                       . " AND (".implode(" OR ", $where).") ORDER BY nickname ASC");
                        if (empty($online))
                        {
                                $msg = "Nobody online on notify!";
                        }
                        else
                        {
-                               $msg = count($online) . " players in guest channel: ";
+                               $msg = count($online) . " players online: ";
                                $msgs = array();
                                foreach ($online as $name)
                                {

I also changed the botname check in the SQL statement - I think the IRC online list should list the same bots as the IG online list.
Title: Re: !whois and !online (IRC) broken
Post by: Alreadythere on October 08, 2007, 04:55:53 pm
Good point, changed the output to only one line, and it includes linked online dbs now too, using the online settings.

Current version of IRC module (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/modules/IRC.php?view=co)
Title: Re: !whois and !online (IRC) broken
Post by: Bart on November 11, 2007, 10:31:34 pm
I added this updated mod today and keep getting the message

Fatal error: Cannot redeclare class Whois in c:\xxxx\xxxx\whois.php on line 50


Any suggestions?
Title: Re: !whois and !online (IRC) broken
Post by: Tichy on November 11, 2007, 10:50:01 pm
Where did you save the updatet whois.php? If you save it to the custom directory, you have to disable the original file.
Title: Re: !whois and !online (IRC) broken
Post by: Alreadythere on November 12, 2007, 12:19:55 am
I added this updated mod today and keep getting the message

Fatal error: Cannot redeclare class Whois in c:\xxxx\xxxx\whois.php on line 50


Any suggestions?
As Tichy said, you either have to disable the original whois.php if you saved it somewhere else then the modules directory. Or just save the file in the modules directory, the links I posted are the most current official versions of those files.
SimplePortal 2.3.7 © 2008-2024, SimplePortal