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?
December 01, 2008, 12:43:37 PM

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 461 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: 158


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: 261


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: 1085


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
[request] Raid timers
by Alreadythere
[Today at 11:42:32 AM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11143
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 3
Guests: 15
Total: 18
egrath
Temar

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