Development > Coding and development discussion

updated Callers.php (from svn)

(1/1)

Wanuarmi:
Made it so it work on tells (all output is thrown in privategroup), not sure if should work in gc aswell?

Added assist commands to list of callers, and a command "assist everyone"

Made "caller add <player>" be just "caller <player>"

Added "callers clear" command, same as "caller del all"


--- Code: ---<?
/*
* Callers.php - Designate and list "Callers" for raids and events.
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* File last changed at $LastChangedDate$
* Revision: $Id$
*/


$callers = new Callers($bot);


$commands["pgmsg"]["caller"] = &$callers;
$commands["pgmsg"]["callers"] = &$callers;
$commands["tell"]["caller"] = &$callers;
$commands["tell"]["callers"] = &$callers;




/*
The Class itself...
*/
class Callers
{
var $bot;
var $callers;



/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Callers (&$bot)
{
$this -> bot = &$bot;
$this -> callers = array();
}



/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
process_command($name, $msg);
}



/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
process_command($name, $msg);
}



function process_command($name, $msg)
{
if ($this -> bot -> is_member($name))
{
if (preg_match("/^" . $this -> bot -> commpre . "callers/i", $msg))
$this -> bot -> send_pgroup($this -> show_callers());
else if (preg_match("/^" . $this -> bot -> commpre . "caller (.+)/i", $msg, $info))
$this -> caller_add($info[1]);
else if (preg_match("/^" . $this -> bot -> commpre . "caller del all/i", $msg))
$this -> clear_callers();
else if (preg_match("/^" . $this -> bot -> commpre . "callers clear/i", $msg))
$this -> clear_callers();
else if (preg_match("/^" . $this -> bot -> commpre . "caller del (.+)/i", $msg, $info))
$this -> caller_del($info[1]);
}
else
$this -> bot -> send_pgroup("You must be a member to use this command.");
}



/*
Add a caller
*/
function caller_add($name)
{
$name = ucfirst(strtolower($name));

if ($this -> bot -> aoc -> get_uid($name))
{
$this -> callers[$name] = 1;
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been added to caller list. " . $this -> show_callers());
}
else
$this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does not exist.");
}



/*
Remove a caller
*/
function caller_del($name)
{
$name = ucfirst(strtolower($name));

if ($this -> bot -> aoc -> get_uid($name) != -1)
{
if (isset($this -> callers[$name]))
{
unset($this -> callers[$name]);
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> has been removed from caller list. " . $this -> show_callers());
}
else
$this -> bot -> send_pgroup("<font color=#ffff00>" . $name . "</font> is not on list of callers. " . $this -> show_callers());
}
else
$this -> bot -> send_pgroup("Player <font color=#ffff00>" . $name . "</font> does not exist.");
}



/*
Clear list of callers
*/
function clear_callers()
{
$this -> callers = array();
$this -> bot -> send_pgroup("List of callers has been cleared.");
}



/*
Return the list of callers
*/
function show_callers()
{
$call = array_keys($this -> callers);
if (empty($call))
return "No callers on list.";
else
{
$list = "<font color=CCInfoHeadline>::: List of callers :::</font>\n\n";
$list .= "Macros:";
foreach ($call as $player)
$list .= " - <a href='chatcmd:///macro $player /assist $player'>$player</a>\n";
$list .= "Commands:";
foreach ($call as $player)
$list .= " - <a href='chatcmd:///assist $player'>$player</a>\n";
$list .= "\n<a href='chatcmd:///assist" . implode('\n /assist ', $call) . "'>Assist everyone</a>"
return "List of Callers :: " . $this -> bot -> make_blob("click to view", $list);
}
}
}
?>
--- End code ---

Navigation

[0] Message Index

Go to full version