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

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Modified is to accept multiple usernames  (Read 7374 times)

0 Members and 1 Guest are viewing this topic.

Offline Areteh

  • BeBot User
  • **
  • Posts: 23
  • Karma: +0/-0
Modified is to accept multiple usernames
« on: October 02, 2006, 08:51:34 pm »
Really simple, but damn it was bugging me.  Modified is to accept multiple usernames to check on the same line. 

ie. !is user1 user2 user3 user4

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Modified is to accept multiple usernames
« Reply #1 on: October 02, 2006, 10:45:19 pm »
Useful :)
Eternalist
General of The Syndicate

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Modified is to accept multiple usernames
« Reply #2 on: October 17, 2006, 04:12:02 pm »
here's a working version:

Code: [Select]
<?


/*


* Is.php - Check if a player is online.
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
* Developed by Blondengy (RK1)
* Modified by Areteh (RK1) to support multiple names per command 2006-10-02
* Special thanks goes out to Khalem (RK1) for his support.
*
* File last changed at $LastChangedDate: ... $
* Revision: $Id: Is.php ... $

*/


$is = new Is($bot);


$commands["tell"]["is"] = &$is;
$commands["gc"]["is"] = &$is;
$commands["pgmsg"]["is"] = &$is;
$commands["buddy"][] = &$is;


/*
The Class itself...
*/

class Is
{

var $bot;
var $query;

/*
Constructor:
Hands over a referance to the "Bot" class.
*/

function Is (&$bot)
{
$this -> bot = &$bot;
}

/*
This gets called on a tell with the command
*/

function tell($name, $msg)
{
$this -> is_online ($name, $msg);
}

/*
This gets called on a msg in the guildchat with the command
*/

function gc($name, $msg)
{
$this -> is_online ("gc", $msg);
}

/*
This gets called on a msg in the guildchat with the command
*/

function pgmsg($name, $msg)
{
$this -> is_online ("pgroup", $msg);
}

/*
Handles the acutally online/offline code
*/

function is_online ($where, $msg)
{
if(!preg_match("/^" . $this -> bot -> commpre . "is (.+)$/i", $msg, $info))
$msg = "Please enter a valid name.";

else
{
$names = preg_split ("/\s+/", $info[1]);
foreach ($names as $name)
{
$name = ucfirst(strtolower($name));
$msg = "";

if (!$this -> bot -> aoc -> get_uid($name))
$msg = "Player " . $name . " does not exist.";

else if ($name == ucfirst(strtolower($this -> bot -> botname)))
$msg = "I'm online!";

else if ($this -> bot -> aoc -> buddy_exists($name))
{
if ($this -> bot -> aoc -> buddy_online($name))
$msg = $name . " is <font color=#00ff00>online</font>";
else
$msg = $name . " is <font color=#ff0000>offline</font>";
}

else
{
$this -> query[$name] = $where;
$this -> bot -> aoc -> buddy_add($name);
}
                if (!empty($msg) && $where == "gc")
                        $this -> bot -> send_gc($msg);
                else if (!empty($msg) && $where == "pgroup")
                        $this -> bot -> send_pgroup($msg);
                else if (!empty($msg))
                        $this -> bot -> send_tell($where, $msg);
}
}
}

/*
This gets called if a buddy logs on/off
*/

function buddy($name, $msg)
{
if ($this -> bot -> is_member($name) != 1)
{
if (isset($this -> query[$name]))
{
if ($msg == 1)
{
$msg =  $name . " is <font color=#00ff00>online</font>";
}
else
$msg = $name . " is <font color=#ff0000>offline</font>";
if (!empty($msg) && ($this -> query[$name] == "gc"))
$this -> bot -> send_gc($msg);
else if (!empty($msg) && ($this -> query[$name] == "pgroup"))
$this -> bot -> send_pgroup($msg);
else if (!empty($msg))
$this -> bot -> send_tell($this -> query[$name], $msg);
unset($this -> query[$name]);
}
}
}
}

?>
Eternalist
General of The Syndicate

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Modified is to accept multiple usernames
« Reply #3 on: December 05, 2006, 04:09:34 pm »
Here is an updated version of the Is module supporting multiple names and main/alts checking. 0.2.x version, add table prefix for 0.3.x I guess.

edit: Fixed main/alts offline issue.
« Last Edit: December 05, 2006, 09:24:02 pm by Malosar »
Eternalist
General of The Syndicate

Offline pusikas

  • BeBot Apprentice
  • ***
  • Posts: 161
  • Karma: +0/-0
Re: Modified is to accept multiple usernames
« Reply #4 on: April 16, 2007, 01:46:59 pm »
Questions, because I do not fully understand how the !is command works:

If the toon is on the bot's buddylist already, you check his status with buddy_online? And if he is not, you use buddy_add and wait for the logon event? When does this new buddy get removed? During the next roster update? Is there a problem if I do too many !is in short succession? Can I get over the limit of 1K buddies this way? Why isn't the buddy removed from the list after the logon event has been catched?
« Last Edit: April 16, 2007, 01:52:31 pm by pusikas »
Luuv  Bot-Keeper of Vengeance ^^*

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: Modified is to accept multiple usernames
« Reply #5 on: April 16, 2007, 02:30:31 pm »
You need the queue the check as if you use add_buddy then buddy_online without the queue on the command, 99% of the time it won't work as it takes AO a few seconds to add the buddy to server (by which time script would be finished).  I really don't like this way of doing it, but I think this is AO issue rather than Bebot.

The excess buddies would be removed at bot restart or roster update (6 hours?), whichever is sooner.  I don't think you would ever reach 1000 friends, unless the org roster wasn't in a tidy condition, but yeah its perfectly possible.

-jj-

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Modified is to accept multiple usernames
« Reply #6 on: April 16, 2007, 02:47:59 pm »
The excess buddies get removed with the buddy event I believe, as only members/guests are kept on buddy list.

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: Modified is to accept multiple usernames
« Reply #7 on: April 16, 2007, 03:04:34 pm »
With the way the !is is coded atm, the excess buddies get removed on roster update or bot restart.

[2007-04-16 12:57:50]   [BUDDY] [DEL]   Sheena
[2007-04-16 12:57:50]   [BUDDY] [DEL]   Vimsemp
[2007-04-16 12:57:50]   [BUDDY] [DEL]   Kylu
[2007-04-16 12:57:50]   [BUDDY] [DEL]   Shootroxj00
[2007-04-16 12:57:50]   [ROSTER]        [UPDATE]        Roster update complete. Added 1 members, removed 4.
Eternalist
General of The Syndicate

Offline pusikas

  • BeBot Apprentice
  • ***
  • Posts: 161
  • Karma: +0/-0
Re: Modified is to accept multiple usernames
« Reply #8 on: April 16, 2007, 03:20:58 pm »
The excess buddies would be removed at bot restart or roster update (6 hours?), whichever is sooner.  I don't think you would ever reach 1000 friends, unless the org roster wasn't in a tidy condition, but yeah its perfectly possible.

I recently kicked like 120 peeps, because we were getting awfully close to 1K...  ;D Yeah, guess that was not a tidy condition.
« Last Edit: April 16, 2007, 03:24:09 pm by pusikas »
Luuv  Bot-Keeper of Vengeance ^^*

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

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