collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: !whois and !online (IRC) broken  (Read 2320 times)

0 Members and 1 Guest are viewing this topic.

Offline Tichy

  • BeBot User
  • **
  • Posts: 42
  • Karma: +0/-0
!whois and !online (IRC) broken
« 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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #1 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.

Offline Tichy

  • BeBot User
  • **
  • Posts: 42
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #2 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.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #3 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

Offline Bart

  • BeBot User
  • **
  • Posts: 39
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #4 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?

Offline Tichy

  • BeBot User
  • **
  • Posts: 42
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #5 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.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: !whois and !online (IRC) broken
« Reply #6 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.

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 750
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal