BeBot v0.2.11
<?
/*
* PrivGroup.php - Basic featureset for private group handeling (join/kick etc)
*
* 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: 2005-12-12 19:34:04 -0500 (Mon, 12 Dec 2005) $
* Revision: $Id: PrivGroup.php 37 2005-12-13 00:34:04Z shadowmaster $
*/
$privgroup = new PrivGroup($bot);
$commands["tell"]["join"] = &$privgroup;
$commands["tell"]["chat"] = &$privgroup;
$commands["tell"]["leave"] = &$privgroup;
$commands["tell"]["invite"] = &$privgroup;
$commands["tell2"]["leave"] = &$privgroup;
$commands["pgmsg"]["leave"] = &$privgroup;
$commands["pgmsg"]["invite"] = &$privgroup;
$commands["pgmsg"]["kick"] = &$privgroup;
$commands["gc"]["join"] = &$privgroup;
/*
The Class itself...
*/
class PrivGroup
{
var $bot;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function PrivGroup (&$bot)
{
$this -> bot = &$bot;
}
/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "join/i", $msg))
$this -> bot -> aoc -> privategroup_invite($name);
else if (preg_match("/^" . $this -> bot -> commpre . "chat/i", $msg))
$this -> bot -> aoc -> privategroup_invite($name);
else if (preg_match("/^" . $this -> bot -> commpre . "invite$/i", $msg))
$this -> bot -> aoc -> privategroup_invite($name);
else if (preg_match("/^" . $this -> bot -> commpre . "leave/i", $msg))
$this -> bot -> aoc -> privategroup_kick($name);
else if (preg_match("/^" . $this -> bot -> commpre . "invite (.+)$/i", $msg, $info))
$this -> invite($name, "tell", $info[1]);
else
$this -> bot -> send_help($name);
}
/*
This gets called on a tell with the command from person outside guild
*/
function tell2($name, $msg)
{
$this -> bot -> aoc -> privategroup_kick($name);
}
/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "leave/i", $msg))
$this -> bot -> aoc -> privategroup_kick($name);
else if (preg_match("/^" . $this -> bot -> commpre . "invite (.+)$/i", $msg, $info) && ($this -> bot -> is_member($name)))
$this -> invite($name, "pgmsg", $info[1]);
else if (preg_match("/^" . $this -> bot -> commpre . "kick (.+)$/i", $msg, $info) && ($this -> bot -> is_member($name)))
$this -> kick($name, $info[1]);
}
/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
if (preg_match("/^" . $this -> bot -> commpre . "join/i", $msg))
$this -> bot -> aoc -> privategroup_invite($name);
}
/*
Kicks a user
*/
function kick($name, $who)
{
if ($this -> bot -> raidbot || $this -> bot -> admin -> in_group($name, "admin") ||
$this -> bot -> admin -> in_group($name, "raidleader"))
$this -> bot -> aoc -> privategroup_kick($who);
else
$this -> bot -> send_tell($name, "You do not have permission to kick someone.");
}
/*
Invite a user to private group.
*/
function invite($from, $type, $who)
{
if (($this -> bot -> guildbot && $this -> bot -> is_member($from)) ||
$this -> bot -> admin -> in_group($from, "raidleader") ||
$this -> bot -> admin -> in_group($from, "admin") ||
$this -> bot -> admin -> in_group($from, "superadmin"))
{
$msg = "Player <font color=#ffff00>" . $who . "</font> does not exist.";
if ($this -> bot -> aoc -> get_uid($who))
{
$this -> bot -> aoc -> privategroup_invite($who);
$this -> bot -> send_tell($who, "You have been invited to the privategroup by " . $from . ".");
$msg = "<font color=#ffff00>" . $who . "</font> has been invited.";
}
}
else
$msg = "You do not have permission to use this command.";
if ($type == "tell")
$this -> bot -> send_tell($from, $msg);
else
$this -> bot -> send_pgroup($msg);
}
}
?>