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:
--- 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:
--- 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:
--- 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);