L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 06, 2008, 09:27:06 AM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Feedback and Suggestions > Topic: AFK module fixes/little tweak to Main.php
Pages: [1]   Go Down
« previous next »
Print
Author Topic: AFK module fixes/little tweak to Main.php  (Read 438 times)
0 Members and 1 Guest are viewing this topic.
kuznechik
BeBot Contributor
Rookie
*******
Offline Offline

Gender: Male
Posts: 60



AFK module fixes/little tweak to Main.php
« on: February 27, 2007, 07:15:44 AM »

Set myself afk and found bot is spamming "Kuznechik is AFK" nonstop. After looking into code realised it didn't checked if bot_name written in lowercase with 1st letter being capital.
Fix:
Code:
--- AFK.php.orig        Wed Feb 21 21:43:50 2007
+++ AFK.php     Tue Feb 27 14:50:36 2007
@@ -80,7 +80,7 @@
        }

        function privgroup($name, $msg) {
-               if($name != $this -> bot -> botname) {
+               if($name != ucfirst(strtolower($this -> bot -> botname))) {
                        if(preg_match("/^" . $this -> bot -> commpre . "afk (.*)/i", $msg, $afkmsg)) {
                                $this -> gone($name, $afkmsg[1]);
                                $this -> bot -> send_pgroup($name . " is now AFK.");
@@ -98,7 +98,7 @@
        }

        function gmsg($name, $group, $msg) {
-               if($name != $this -> bot -> botname) {
+               if($name != ucfirst(strtolower($this -> bot -> botname))) {
                        if(preg_match("/^" . $this -> bot -> commpre . "afk (.*)/i", $msg, $afkmsg)) {
                                $this -> gone($name, $afkmsg[1]);
                                $this -> bot -> send_gc($name . " is now AFK.");

Alternate fix:
Code:
--- Main.php.orig       Wed Feb 21 21:25:12 2007
+++ Main.php    Tue Feb 27 14:58:25 2007
@@ -122,7 +122,7 @@
 global $db;
 global $bot;

-
+$bot_name = ucfirst(strtolower($bot_name));
 $db = new MySQL();
 $aoc = new AOChat("callback");
 $bot = new Bot($ao_username, $ao_password, $bot_name, $dimension, $bot_version, $bot_version_name, $other_bots, $aoc, $irc, $db, $commands, $command_prefix, $cron, $cron_delay, $tell_delay, $max_blobsize, $reconnect_time, $guildbot, $guild_name, $guild_id, $guild_relay_target, $log, $log_path);

I myself went with alternate fix due to more global fix of things.
Also due to pregmatch empty "!afk" will fail since you need a space after.
Fix for it:
Code:
--- AFK.php.orig        Wed Feb 21 21:43:50 2007
+++ AFK.php     Tue Feb 27 15:11:27 2007
@@ -73,16 +73,16 @@
        }

        function tell($name, $msg) {
-               if(preg_match("/^" . $this -> bot -> commpre . "afk (.*)/i", $msg, $afkmsg)) {
-                       $this -> gone($name, $afkmsg[1]);
+               if(preg_match("/^" . $this -> bot -> commpre . "afk( *)(.*)/i", $msg, $afkmsg)) {
+                       $this -> gone($name, $afkmsg[2]);
                        $this -> bot -> send_gc($name . " is now AFK.");
                }
        }

        function privgroup($name, $msg) {
                if($name != $this -> bot -> botname) {
-                       if(preg_match("/^" . $this -> bot -> commpre . "afk (.*)/i", $msg, $afkmsg)) {
-                               $this -> gone($name, $afkmsg[1]);
+                       if(preg_match("/^" . $this -> bot -> commpre . "afk( *)(.*)/i", $msg, $afkmsg)) {
+                               $this -> gone($name, $afkmsg[2]);
                                $this -> bot -> send_pgroup($name . " is now AFK.");
                        } else if($this -> acheck($name)) {
                                $this -> back($name);
@@ -99,8 +99,8 @@

        function gmsg($name, $group, $msg) {
                if($name != $this -> bot -> botname) {
-                       if(preg_match("/^" . $this -> bot -> commpre . "afk (.*)/i", $msg, $afkmsg)) {
-                               $this -> gone($name, $afkmsg[1]);
+                       if(preg_match("/^" . $this -> bot -> commpre . "afk( *)(.*)/i", $msg, $afkmsg)) {
+                               $this -> gone($name, $afkmsg[2]);
                                $this -> bot -> send_gc($name . " is now AFK.");
                        } else if($this -> acheck($name)) {
                                $this -> back($name);
Logged

Kuznechik, proud bot admin of Disciples of Omni-Tek, Rimor.
Vhab
BeBot Contributor
Experienced
*******
Offline Offline

Posts: 156


WWW
Re: AFK module fixes/little tweak to Main.php
« Reply #1 on: February 27, 2007, 10:03:57 AM »

Code:
if($name != ucfirst(strtolower($this -> bot -> botname))) {

the strtolower is kinda pointless there since it's gonna be converted to ucfirst right after that.
better way to make sure both match:

Code:
if(strtolower($name) != strtolower($this -> bot -> botname)) {
Logged
kuznechik
BeBot Contributor
Rookie
*******
Offline Offline

Gender: Male
Posts: 60



Re: AFK module fixes/little tweak to Main.php
« Reply #2 on: February 27, 2007, 10:28:16 AM »

Well, ingame names are in UCFirst() format... And I dunno why, but all bebot modules are covered with ucfirst(strtolower(..))

From php.net manual
Code:
Example 2367. ucfirst() example
<?php
$foo 
= 'hello world!';
$foo = ucfirst($foo);            // Hello world!

$bar = 'HELLO WORLD!';
$bar = ucfirst($bar);            // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>
« Last Edit: February 27, 2007, 10:32:07 AM by kuznechik » Logged

Kuznechik, proud bot admin of Disciples of Omni-Tek, Rimor.
Nytridr
Expert
*****
Offline Offline

Gender: Male
Posts: 252


WWW
Re: AFK module fixes/little tweak to Main.php
« Reply #3 on: May 26, 2007, 12:20:27 AM »

not sure if this was fixed at one time or not in the svn but it is broke again. 

Code:
[Rising Sun (AoF)] Metanyt: !afk test
[Rising Sun (AoF)] Rsbot: Metanyt is now AFK.
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Metanyt: oh wow
[Rising Sun (AoF)] Rsbot: Metanyt is AFK (test).
[Rising Sun (AoF)] Rsbot: Metanyt is back.

just figured someone can fix it again if they want for the snv release.
Logged

Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1052


Re: AFK module fixes/little tweak to Main.php
« Reply #4 on: May 27, 2007, 04:21:56 AM »

Fix applied in SVN.
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Feedback and Suggestions > Topic: AFK module fixes/little tweak to Main.php
« previous next »
 
Jump to:  

Recent
!items database
by cthulhu
[October 05, 2008, 11:36:16 AM]

Supplies needed module
by viper
[October 05, 2008, 11:11:13 AM]

Assist
by Foxy
[October 05, 2008, 05:09:02 AM]

How's 0.5.x coming? Wonde...
by Hyde
[October 04, 2008, 04:59:20 PM]

TWC
by Elesar1
[October 04, 2008, 12:55:59 PM]

Org in AoC
by Alreadythere
[October 04, 2008, 04:50:00 AM]

OnlineOrg
by Slacklin
[October 04, 2008, 03:06:00 AM]

Learning .NET, Mono, C#, ...
by Vhab
[October 04, 2008, 02:39:03 AM]

guild taxes module for ag...
by Elesar1
[October 03, 2008, 09:06:09 AM]

MediaControl
by Elesar1
[October 03, 2008, 08:38:18 AM]
Stats
Members
Total Members: 983
Latest: Titerris
Stats
Total Posts: 10740
Total Topics: 1448
Online Today: 15
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 2
Guests: 44
Total: 46
Sudoka
cthulhu

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.404 seconds with 28 queries. (Pretty URLs adds 0.04s, 4q)
Loading...