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

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18376
  • stats Total Topics: 2503
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 37912

Author Topic: afk on linked org bots  (Read 9011 times)

0 Members and 1 Guest are viewing this topic.

Offline Ixiaan

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
afk on linked org bots
« on: March 19, 2010, 01:46:46 am »
I have some org bots that are linked via a private group. The online list is showing members from all org bots; however, the afk status is only shown for characters in the same org.

Is there any version of afk that will show the afk status across all orgs, or if I want this feature I would have to code it myself?

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: afk on linked org bots
« Reply #1 on: March 20, 2010, 10:37:38 pm »
Iirc the AFK status is only stored in memory.

The most sane thing to do would probably be to add a field to the online table for this and modify the AFK module to use this instead.
BeBot Founder and Fixer Kingpin

Offline Ixiaan

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: afk on linked org bots
« Reply #2 on: June 24, 2010, 05:27:53 am »
Here's a quick fix for this if anyone is interested:

Code: (AFK.php) [Select]
<?php
/*
* AFK Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
*
* BeBot - An Anarchy Online & Age of Conan Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Copyright (C) 2005-2010 Thomas Juberg, ShadowRealm Creations and the BeBot development team.
*
* Developed by:
* - Alreadythere (RK2)
* - Blondengy (RK1)
* - Blueeagl3 (RK1)
* - Glarawyn (RK1)
* - Khalem (RK1)
* - Naturalistic (RK1)
* - Temar (RK1)
*
* See Credits file for all aknowledgements.
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; version 2 of the License only.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*  USA
*
* File last changed at $LastChangedDate: 2008-11-30 23:09:06 +0100 (Sun, 30 Nov 2008) $
* Revision: $Id: AFK.php 1833 2008-11-30 22:09:06Z alreadythere $
*/

/*
Add a "_" at the beginning of the file (_AFK.php) if you do not want it to be loaded.
*/

$afk = new AFK($bot);

Class 
AFK extends BaseActiveModule
{
var $afk;

function __construct(&$bot)
{
parent::__construct(&$bot, get_class($this));

$this -> afk = array();
$this -> afkalias = array();

$this->register_command("all", "afk", 'MEMBER');

$this->register_event("privgroup");
$this->register_event("gmsg", "org");
$this->register_event("buddy");
$this->register_command("extpgmsg", "relayafk", "MEMBER");

//Create default_level access levels
$this -> help['description'] = "Shows other players that you are afk.";
$this -> help['command']['afk <message>'] = "Sets you afk with <message>";
$this -> help['notes'] = "This command does not affect nor is it affected by the in-game command /afk.";

$this -> bot -> core("settings") -> create("Afk", "Alias", TRUE, "Should Alias's be used with AFK?");
$this -> bot -> core("settings") -> create("Afk", "noprefix", FALSE, "Can no prefix with AFK be used to go AFK?");
$this -> bot -> core("settings") -> create("Afk", "brb_noprefix", FALSE, "Can no prefix with BRB be used to go AFK?");
$this -> bot -> core("settings") -> create("Afk", "RelayAfk", TRUE, "Should afk status be relayed to all relay bots using the established relay network?");

$this -> bot -> core("command_alias") -> register("afk", "brb");
}

function command_handler($name, $msg, $origin)
{
$this->error->reset();
$com=$this->parse_com($msg, array('com', 'args'));
$this->gone($name, $com['args']);

if (!$relaying && $channel != "tell" && $channel != 'internal' && $this -> bot -> core("settings") -> get("Afk", "RelayAfk")
&& $this -> bot -> core("relay") instanceof Relay && $this -> bot -> core("settings") -> get('Relay', 'Status'))
{
$rmsg = "<pre>relayafk name:" . $name . " msg:" . $msg;
$this -> bot -> core("relay") -> relay_to_bot($rmsg, false);
}

return("##highlight##$name##end## is now AFK.");
}

function extpgmsg($pgroup, $name, $msg)
{
if (preg_match("/name:(.+) msg:(.+)/i", $msg, $info))
{
$this->error->reset();
$com=$this->parse_com($info[2], array('com', 'args'));
$this->gone($info[1], $com['args']);
$this -> bot -> send_output($name, "##highlight##$info[1]##end## is now AFK.", "both");
} 
else if (preg_match("/name:(.+) status:(.+)/i", $msg, $info))
{
$timegone = $this -> afk_time($info[1]);
$this -> back($info[1]);
$msgs = $this -> msgs($info[1]);
$this -> bot -> send_output($info[1], $info[1] . " is back. AFK for (".$timegone.") ".$msgs, "both");
}
}

/*
Check if the line in privgroup was meant for someone afk or if someone afk is back
*/
function privgroup($name, $msg)
{
if($this -> acheck($name))
{
$timegone = $this -> afk_time($name);
$this -> back($name);
$msgs = $this -> msgs($name);
$this -> bot -> send_output($name, $name . " is back. AFK for (".$timegone.")  ".$msgs, "both");
}
if ($this -> bot -> core("settings") -> get("Afk", "noprefix"))
{
if(preg_match("/^afk (.*)/i", $msg, $afkmsg))
{
$this -> gone($name, $afkmsg[1]);
$this -> bot -> send_output($name, $name . " is now AFK.", "both");
}
elseif (preg_match("/^afk/i", $msg))
{
$this -> gone($name);
$this -> bot -> send_output($name, $name . " is now AFK.", "both");
}
}
elseif ($this -> bot -> core("settings") -> get("Afk", "brb_noprefix"))
{
if(preg_match("/^brb (.*)/i", $msg, $afkmsg))
{
$this -> gone($name, $afkmsg[1]);
$this -> bot -> send_output($name, $name . " is now AFK.", "both");
}
elseif (preg_match("/^brb/i", $msg))
{
$this -> gone($name, "");
$this -> bot -> send_output($name, $name . " is now AFK.", "both");
}
}
if(!empty($this -> afk))
$msgcheck = $this -> msg_check($name, "", $msg);
if(!empty($msgcheck))
$this -> bot -> send_pgroup($msgcheck);
}

function gmsg($name, $group, $msg)
{
if($this -> acheck($name))
{
$timegone = $this -> afk_time($name);
$this -> back($name);
$msgs = $this -> msgs($name);
$this -> bot -> send_output($name, $name . " is back. AFK for (".$timegone.") ".$msgs, "both");

if (!$relaying && $channel != "tell" && $channel != 'internal' && $this -> bot -> core("settings") -> get("Afk", "RelayAfk")
&& $this -> bot -> core("relay") instanceof Relay && $this -> bot -> core("settings") -> get('Relay', 'Status'))
{
$rmsg = "<pre>relayafk name:" . $name . " status:back";
$this -> bot -> core("relay") -> relay_to_bot($rmsg, false);
}
}
if ($this -> bot -> core("settings") -> get("Afk", "noprefix"))
{
if(preg_match("/^afk (.*)/i", $msg, $afkmsg))
{
$this -> gone($name, $afkmsg[1]);
$this -> bot -> send_output($name, "##highlight##$name##end## is now AFK.", "both");
Return;
}
elseif (preg_match("/^afk/i", $msg))
{
$this -> gone($name);
$this -> bot -> send_output($name, "##highlight##$name##end## is now AFK.", "both");
Return;
}
}
elseif ($this -> bot -> core("settings") -> get("Afk", "brb_noprefix"))
{
if(preg_match("/^brb (.*)/i", $msg, $afkmsg))
{
$this -> gone($name, $afkmsg[1]);
$this -> bot -> send_output($name, "##highlight##$name##end## is now AFK.", "both");
}
elseif (preg_match("/^brb/i", $msg))
{
$this -> gone($name, "");
$this -> bot -> send_output($name, "##highlight##$name##end## is now AFK.", "both");
}
}
if(!empty($this -> afk))
$msgcheck = $this -> msg_check($name, $group, $msg);
if(!empty($msgcheck))
$this -> bot -> send_gc($msgcheck);
}

function msg_check($name, $group, $msg)
{
$found = false;
foreach($this -> afk as $key=>$value)
{
if(preg_match("/$key\b/i", $msg))
{
$this -> afkmsgs[$key][] = array (time(), $name, $msg);
return ($key." has been AFK for ".$this -> afk_time($key)." (" . $value[msg]. ").");
}
}
if ($this -> bot -> core("settings") -> get("Afk", "Alias"))
{
if(!$found)
{
if(!empty($this -> afkalias))
{
foreach($this -> afkalias as $key2 => $value)
{
if(preg_match("/$key2\b/i", $msg))
{
$this -> afkmsgs[$value][$this -> afkmsgid] = array (time(), $name, $msg);
$this -> afkmsgid++;
return ($value . " has been AFK for ".$this -> afk_time($value)." (" . $this -> afk[$value][msg] . ").");
}
}
}
}
}
Return FALSE;
}

function afk_time($name)
{
$timenow = "" . time() ."";
$timeafk = $this -> afk[$name][time];
$dif = $timenow - $timeafk;
if($dif < 60) Return $dif." Seconds";
elseif($dif < 3600)
{
$mins = floor($dif / 60);
Return $mins." Minutes";
}
else
{
$mins = floor($dif / 60);
$hours = floor($mins / 60);
$minstorem = $hours * 60;
$minsrem = $mins - $minstorem;
Return $hours." Hours and ".$minsrem." Minutes";
}
}

function gone($name, $msg=false)
{
if(empty($msg))
{
$msg = "Away from keyboard";
}
$this -> afk[$name] = array ('time' => time(), 'msg' => $msg);
// Add Aliases to AFK list
$main = $this -> bot -> core("alts") -> main($name);
$alts = $this -> bot -> core("alts") -> get_alts($main);
if(!empty($alts))
{
foreach($alts as $alt)
{
$this -> afkalias[$alt] = $name;
}
}
if ($this -> bot -> core("settings") -> get("Afk", "Alias"))
{
$aliases = $this -> bot -> core("alias") -> alias;
if(!empty($aliases))
{
foreach($aliases as $alias => $nickname)
{
if($main == $nickname)
{
$this -> afkalias[$alias] = $name;
}
}
}
}
}

function back($name)
{
if($this -> afk[$name])
{
unset($this -> afk[$name]);
foreach($this -> afkalias as $key => $value)
{
if ($name == $value)
{
unset($this -> afkalias[$key]);
}
}
}
}

function acheck($name)
{
if(isset($this -> afk[$name]))
{
return true;
}
else
{
return false;
}
}

function buddy($name, $msg)
{
$access = $this -> bot -> core("security") -> get_access_level($name);

if (($msg == 5) && ($access > 1))
{
if($this -> acheck($name))
{
$this -> back($name);
$msgs = $this -> msgs($name);
if($this -> bot -> game == "ao")
$this -> bot -> send_tell($name, "you have been set as back. ".$msgs."");
}
}
else if (($msg == 3) && ($access > 1))
{
if(!$this -> acheck($name))
{
$this -> gone($name);
$msgs = $this -> msgs($name);
if($this -> bot -> game == "ao")
$this -> bot -> send_tell($name, "you have been set as AFK. ".$msgs."");
}
}
elseif ($msg == 0)
{
if($this -> acheck($name))
{
$this -> back($name);
$msgs = $this -> msgs($name);
$this -> bot -> send_tell($name, "you have been set as back. (Logoff) ".$msgs."");
}
}
}

function msgs($name)
{
if (!empty($this -> afkmsgs[$name]))
{
$inside = "##blob_title##..:: AFK Messages ::..##end##\n\n";
foreach ($this -> afkmsgs[$name] as $key => $value)
{
$inside .= "##green##".gmdate($this -> bot -> core("settings") -> get("Time", "FormatString"), $value[0])."##end##  ##orange##".$value[1]."##end##\n        ##blob_text##".$value[2]."##end##\n\n";
$count++;
}
$msgs = "##highlight##".$count."##end## Messages :: " . $this -> bot -> core("tools") -> make_blob("click to view", $inside);
unset ($this -> afkmsgs[$name]);
Return ($msgs);
}
unset ($this -> afkmsgs[$name]);
Return FALSE;

}


}
?>


Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: afk on linked org bots
« Reply #3 on: June 25, 2010, 07:20:17 am »
Iirc the AFK status is only stored in memory.

The most sane thing to do would probably be to add a field to the online table for this and modify the AFK module to use this instead.

Never understood the point of having a bot track AFKness, AO does it for us. Just send the person a tell already you lazy...

One of the first things I disable. :)

 

* Recent Posts
0.8.x updates for AoC by bitnykk
[July 14, 2026, 06:46:44 pm ]


0.8.x updates for AO by bitnykk
[July 14, 2026, 06:46:37 pm ]


Bebot in 2026 by bitnykk
[June 11, 2026, 07:53:51 am ]


Bebot in 2025 by bitnykk
[August 21, 2025, 05:17:18 pm ]


Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]

* Who's Online
  • Dot Guests: 1577
  • 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-2026, SimplePortal