BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: kuznechik on February 27, 2007, 11:16:20 am

Title: fiddling with guildrelay
Post by: kuznechik on February 27, 2007, 11:16:20 am
First of all I must say that my bots using different prefix than "!". So after quick search for "!gcr" I've found 2 errors.
Code: [Select]
--- AutoMsg.php.orig    Wed Feb 21 21:44:28 2007
+++ AutoMsg.php Tue Feb 27 13:04:25 2007
@@ -110,7 +110,7 @@
                $this -> bot -> db -> query("INSERT INTO #___auto_msg (type, towho, msg) VALUES ('gc', '', 'Bot is online :: System Ready')");
                if ($this -> bot -> guild_relay_target)
                {
-                       $this -> bot -> db -> query("INSERT INTO #___auto_msg (type, towho, msg) VALUES ('relay', '', '!gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": Bot is online :: System Ready :: Guild Relay Active')");
+                       $this -> bot -> db -> query("INSERT INTO #___auto_msg (type, towho, msg) VALUES ('relay', '', '" . $this -> bot -> commpre . "gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": Bot is online :: System Ready :: Guild Relay Active')");
                }

        }

Code: [Select]
--- Shutdown.php.orig   Wed Feb 21 21:49:50 2007
+++ Shutdown.php        Tue Feb 27 13:08:58 2007
@@ -73,7 +73,7 @@
                                $this -> bot -> send_tell($name, "The bot is shutting down.");
                                if ($this -> bot -> guild_relay_target)
                                {
-                                       $this -> bot -> send_tell($this -> bot -> guild_relay_target, "!gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": The bot is shutting down :: Guild relay disabled", 0, false);
+                                       $this -> bot -> send_tell($this -> bot -> guild_relay_target, $this -> bot -> commpre . "gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": The bot is shutting down :: Guild relay disabled", 0, false);
                                }
                                $this -> bot -> disconnect();
                                die("The bot has been shutdown.\n");
@@ -85,7 +85,7 @@
                                $this -> bot -> send_tell($name, "The bot is restarting.");
                                if ($this -> bot -> guild_relay_target)
                                {
-                                       $this -> bot -> send_tell($this -> bot -> guild_relay_target, "!gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": The bot is restarting :: Guild relay disabled", 0, false);
+                                       $this -> bot -> send_tell($this -> bot -> guild_relay_target, $this -> bot -> commpre . "gcr [" . $this -> bot -> guildname . "] " . $this -> bot -> botname . ": The bot is restarting :: Guild relay disabled", 0, false);
                                }

                                $this -> bot -> disconnect();


I also didn't liked how I need to add other bot to members and somehow keep him from being cleaned from members list, so I've added tell2.

Code: [Select]
--- GuildRelay_GUILD.php.orig   Tue Feb 27 13:12:29 2007
+++ GuildRelay_GUILD.php        Thu Feb 22 00:47:25 2007
@@ -38,6 +38,7 @@
 $guildrelay = new GuildRelay($bot);

 $commands["tell"]["gcr"] = &$guildrelay;
+$commands["tell2"]["gcr"] = &$guildrelay;
 $commands["gc"]["guildrelay"] = &$guildrelay;
 $commands["connect"][] = &$guildrelay;

@@ -68,6 +69,15 @@
        This gets called on a tell with the command
        */
        function tell($name, $msg)
+       {
+               if (preg_match("/^" . $this -> bot -> commpre . "gcr (.+)$/im", $msg, $info) &&
+               ($this -> guildbot == strtolower($name)))
+               {
+                       $this -> bot -> send_gc($info[1]);
+               }
+       }
+
+       function tell2($name, $msg)
        {
                if (preg_match("/^" . $this -> bot -> commpre . "gcr (.+)$/im", $msg, $info) &&
                ($this -> guildbot == strtolower($name)))

Modifying tell to tell2 resulted in bot restart... Didn't digged why, just added tell2...

To be continued
Title: Another addition - guild_relaying of privgroup
Post by: kuznechik on February 27, 2007, 02:21:39 pm
Due to some people being in baby org we have relay with and some org-friends hanging in privgroup I've got request to relay messages between it.
Here is result:
Code: [Select]
--- GuildRelay_GUILD.php.p1     Thu Feb 22 00:47:25 2007
+++ GuildRelay_GUILD.php        Tue Feb 27 16:08:15 2007
@@ -74,6 +74,9 @@
                ($this -> guildbot == strtolower($name)))
                {
                        $this -> bot -> send_gc($info[1]);
+                    if (isset($this -> bot -> commands["privgroup"]["relay"]))
+                       $this -> bot -> send_pgroup($info[1]);
                }
        }

@@ -83,6 +86,8 @@
                ($this -> guildbot == strtolower($name)))
                {
                        $this -> bot -> send_gc($info[1]);
+                    if (isset($this -> bot -> commands["privgroup"]["relay"]))
+                       $this -> bot -> send_pgroup($info[1]);
                }
        }

@@ -120,6 +125,12 @@
                if (strtolower($name) != strtolower($this -> bot -> botname))
                {
                        $tell = "<pre>gcr [" . $this -> bot -> guildname . "] " . $name . ": " . $msg;
+                       $this -> bot -> send_tell($this -> guildbot, $tell, 0, false);
+               }
+               else if (preg_match("/^<font color=#([0-9a-fA-F]+)>\[Guest\](.+)$/i", $msg, $info) &&
+                       (isset($this -> bot -> commands["privgroup"]["relay"])))
+               {
+                       $tell = "<pre>gcr [" . $name . "-guest]:" . $info[2];
                        $this -> bot -> send_tell($this -> guildbot, $tell, 0, false);
                }
        }
Title: Re: fiddling with guildrelay
Post by: Naturalistic on February 28, 2007, 05:29:04 pm
Nerf your text editor ;)

Title: Re: fiddling with guildrelay
Post by: Glarawyn on February 28, 2007, 06:53:55 pm
Nerf your text editor ;)

No nerfing required. Learn diff and patch.  ;D
Title: Re: fiddling with guildrelay
Post by: Naturalistic on February 28, 2007, 08:11:47 pm
No thanks, Notepad2 ftw :p
SimplePortal 2.3.7 © 2008-2025, SimplePortal