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?
November 22, 2008, 12:19:02 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Modified is to accept multiple usernames
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Modified is to accept multiple usernames  (Read 940 times)
0 Members and 1 Guest are viewing this topic.
Areteh
Rookie
**
Offline Offline

Posts: 23


Modified is to accept multiple usernames
« on: October 02, 2006, 01: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
Logged
Malosar
Expert
*****
Offline Offline

Posts: 259


WWW
Re: Modified is to accept multiple usernames
« Reply #1 on: October 02, 2006, 03:45:19 PM »

Useful Smiley
Logged

Eternalist
General of The Syndicate
Malosar
Expert
*****
Offline Offline

Posts: 259


WWW
Re: Modified is to accept multiple usernames
« Reply #2 on: October 17, 2006, 09:12:02 AM »

here's a working version:

Code:
<?


/*


* 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]);
}
}
}
}

?>
Logged

Eternalist
General of The Syndicate
Malosar
Expert
*****
Offline Offline

Posts: 259


WWW
Re: Modified is to accept multiple usernames
« Reply #3 on: December 05, 2006, 10:09:34 AM »

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, 03:24:02 PM by Malosar » Logged

Eternalist
General of The Syndicate
pusikas
Experienced
****
Offline Offline

Posts: 161


Re: Modified is to accept multiple usernames
« Reply #4 on: April 16, 2007, 06:46:59 AM »

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, 06:52:31 AM by pusikas » Logged

Luuv  Bot-Keeper of Vengeance ^^*
jjones666
BeBot Contributor
Champion
*******
Offline Offline

Posts: 353


Re: Modified is to accept multiple usernames
« Reply #5 on: April 16, 2007, 07:30:31 AM »

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-
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


Re: Modified is to accept multiple usernames
« Reply #6 on: April 16, 2007, 07:47:59 AM »

The excess buddies get removed with the buddy event I believe, as only members/guests are kept on buddy list.
Logged
Malosar
Expert
*****
Offline Offline

Posts: 259


WWW
Re: Modified is to accept multiple usernames
« Reply #7 on: April 16, 2007, 08:04:34 AM »

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.
Logged

Eternalist
General of The Syndicate
pusikas
Experienced
****
Offline Offline

Posts: 161


Re: Modified is to accept multiple usernames
« Reply #8 on: April 16, 2007, 08:20:58 AM »

Quote from: jjones666 on April 16, 2007, 07:30:31 AM
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...  Grin Yeah, guess that was not a tidy condition.
« Last Edit: April 16, 2007, 08:24:09 AM by pusikas » Logged

Luuv  Bot-Keeper of Vengeance ^^*
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: Modified is to accept multiple usernames
« previous next »
 
Jump to:  

Recent
Change text in remember "...
by gerborg
[November 21, 2008, 05:14:57 PM]

Log playtime from buddys ...
by Temar
[November 20, 2008, 10:33:57 AM]

Vote Core module and Simp...
by Temar
[November 19, 2008, 09:26:52 AM]

Restrict access for one m...
by Organizer
[November 19, 2008, 03:21:19 AM]

Custom / Revised Modules ...
by Elesar1
[November 17, 2008, 03:51:46 PM]

TWC
by Temar
[November 16, 2008, 11:39:12 AM]

Are there any FUN modules...
by Elesar1
[November 15, 2008, 07:39:15 PM]

Call to a member function...
by exxie
[November 15, 2008, 09:29:31 AM]

Ported Modules
by Alreadythere
[November 14, 2008, 06:10:07 PM]

cURL and other non-defaul...
by Temar
[November 14, 2008, 04:11:44 PM]
Stats
Members
Total Members: 1235
Latest: DDDepressionnn
Stats
Total Posts: 11037
Total Topics: 1496
Online Today: 18
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 4
Guests: 20
Total: 24
xlDanek
Temar
Stealth
gerborg

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.588 seconds with 29 queries. (Pretty URLs adds 0.035s, 4q)
Loading...