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

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

Author Topic: New Orders.php  (Read 8868 times)

0 Members and 2 Guests are viewing this topic.

Offline MafooUK

  • BeBot Rookie
  • *
  • Posts: 7
  • Karma: +0/-0
New Orders.php
« on: June 29, 2009, 11:10:27 pm »
Released an updated version of Orders.php for Bebot 0.6.x, only been tested on 0.6.3 but should be no reason for it to not work on the whole 0.6.x

Includes self help and settings

have heavily tweaked the original from bebot 0.2.x
customized all the settings where appropriate, would love to know if anything else needs to be done.

for some reason I cannot upload the file so I have quoted it as code
Code: [Select]
<?
/*
*
* Orders.php - Cyclic Orders.
* Written by Andrew Zbikowski <[email protected]> (AKA Glarawyn, RK1)
* Updated by Mafo0, RK1 for 0.6.x
* Version 0.6.3 - 1
*
*/

$Orders = new Orders($bot);

/*
The Class itself...
*/
class Orders extends BaseActiveModule
{ // Start Class
var $bot;
    var $settime = 1;
    var $currentorders = "";
var $setby = "";

/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function __construct(&$bot)
{
parent::__construct(&$bot, get_class($this));

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

$this -> bot -> core("settings") -> create('Orders', 'Set', 'LEADER', 'Who should be able to set and clear orders', 'GUEST;MEMBER;LEADER;ADMIN;SUPERADMIN;OWNER');
$this -> bot -> core("settings") -> create('Orders', 'Repeat', '2mins', 'How often the orders should repeat, This argument needs to be a format as described by http://www.gnu.org/software/tar/manual/html_node/tar_109.html', '');
$this -> bot -> core("settings") -> create('Orders', 'Timeout', '30mins', 'How long to clear the orders, unless orders refresh or clear is used, This argument needs to be a format as described by http://www.gnu.org/software/tar/manual/html_node/tar_109.html', '');
$this -> bot -> core("settings") -> create('Orders', 'Channel', 'both', 'Which channel(s) to send the orders to', 'both;pgroup;guild');

$this -> register_event("pgjoin");

$this -> help['description'] = 'This module enables the raid leader to post current orders';
$this -> help['command']['orders'] = "Shows the current orders";
$this -> help['command']['orders set'] = "Sets the orders";
$this -> help['command']['orders clear'] = "Clears the orders";
$this -> help['command']['orders refresh'] = "resets the timer";

$this -> help['notes'].= "The time arguments needs to be a format as described by http://www.gnu.org/software/tar/manual/html_node/tar_109.html ";
$this -> help['notes'].= "This means that formats like most dates and also '1 month', 'next thursday' etc. are allowed.<br>";
}


/*
Unified message handler
$source: The originating player
$msg: The actual message, including command prefix and all
$origin: The channel the message arrived from. This can be either "tell", "pgmsg" or "gc"
*/
function command_handler($source, $msg, $origin)
{
$this->error->reset();

//parse_com() returns an array where the pattern is the keys and the values are split out from $msg
$com = $this->parse_com($msg, array('com', 'sub', 'msg'));

switch($com['com'])
{
case 'orders':
switch($com['sub'])
{
case 'set':
if($this -> bot -> core("security") -> check_access($source, $this -> bot -> core("settings") -> get('Orders', 'Set')))
return($this -> set_orders($source, $com['msg']));
else
{
$this -> error -> set("You must be ".$this -> bot -> core("settings") -> get('Orders', 'Set')." or higher to set the orders");
return($this->error->message());
}
break;
case 'clear':
if($this -> bot -> core("security") -> check_access($source, $this -> bot -> core("settings") -> get('Orders', 'Set')))
return($this -> clear_orders($source));
else
{
$this -> error -> set("You must be ".$this -> bot -> core("settings") -> get('Orders', 'Set')." or higher to clear the orders");
return($this->error->message());
}
break;
case 'refresh':
if($this -> bot -> core("security") -> check_access($source, $this -> bot -> core("settings") -> get('Orders', 'Set')))
return($this -> refresh_orders());
else
{
$this -> error -> set("You must be ".$this -> bot -> core("settings") -> get('Orders', 'Set')." or higher to refersh the orders");
return($this->error->message());
}
break;
default:
if(isset($this -> currentorders))
return($this -> bot -> send_output("", $this -> currentorders, $this -> bot -> core("settings") -> get('Orders', 'Channel')));
else
if($origin == 'tell')
return($this -> bot -> send_output($source, "There are no orders at this time", 'tell'));
else
return($this -> bot -> send_output($source, "There are no orders at this time", $this -> bot -> core("settings") -> get('Orders', 'Channel')));
}
break;
default:
// Just a safety net to allow you to catch errors where a module has registered  a command, but fails to actually do anything about it
$this -> error -> set("Broken plugin, recieved unhandled command: " . $com['com']);
return($this->error->message());
}
}

/*
This gets called on cron
*/
function cron()
{
$remander = $this -> settime - time() + $this -> bot -> core("time") -> parse_time($this -> bot -> core("settings") -> get('Orders', 'Timeout'));
if($this->settime != 1 && $remander > 0)
{
$this -> bot -> send_output("", $this->currentorders, $this -> bot -> core("settings") -> get('Orders', 'Channel'));
if ($remander <= $this -> bot -> core("time") -> parse_time($this -> bot -> core("settings") -> get('Orders', 'Repeat')))
$this -> bot -> send_output($this -> setby , "Your orders are going to time out in " . $remander . " seconds, use orders refresh to reset the timer", "tell");
}
else if ($this -> settime > 1)
{
$this->clear_orders();
}
}

/*
This gets called on pgjoin
*/
function pgjoin($name)
{
if ($this->settime != 1)
{
$this -> bot -> send_output($name, $this -> currentorders, "tell");
}
}


/*
This gets called when bot connects
*/
function connect()
{
$this -> $settime = 1;
$this -> $currentorders = "";
$this -> $setby = "";
}


    /*
        Set's orders
    */
    function set_orders($name, $message)
    {
if(
$this -> bot -> core("time") -> parse_time($this -> bot -> core("settings") -> get('Orders', 'Timeout')) <= 0
&& $this -> bot -> core("time") -> parse_time($this -> bot -> core("settings") -> get('Orders', 'Repeat')) <= 0
)
{
$this -> error -> set("The settings don't seem to be valid, fix this before using this command");
return($this->error->message());
}
$this -> register_event("cron", $this -> bot -> core("settings") -> get('Orders', 'Repeat'));
$this -> settime = time();
$this -> setby = $name;

        $ordershead .= "<br><font color=#4fd553>--------------------------------------------------</font><br>";
        $ordershead .= "<font color=#7ce2ec>";

$orders .= " (</font>";
        $orders .= "<font color=#ffffc9>";
        $orders .= $name;
        $orders .= "</font><font color=#7ce2ec>) </font>";
        $orders .= "<font color=#ffff45>";
        $orders .= $message;
        $orders .= "</font>";
        $orders .= "<br><font color=#4fd553>--------------------------------------------------</font><br>";

        $this -> currentorders = $ordershead . "CURRENT ORDERS!" . $orders;
        $this -> bot -> send_output($name, $ordershead . "NEW ORDERS!" . $orders, $this -> bot -> core("settings") -> get('Orders', 'Channel') );
    }

    /*
        Refesh orders
    */
    function refresh_orders()
    {
if(!isset($this->currentorders)
)
{
$this -> error -> set("You cannot refresh orders that don't exist");
return($this->error->message());
}
$this -> register_event("cron", $this -> bot -> core("settings") -> get('Orders', 'Repeat'));
$this -> settime = time();
    }


    /*
        Clears current orders.
    */
    function clear_orders($person)
    {
        $this -> settime = 1;
        $this -> currentorders = "";
$message = "Orders cleared";
if ($person)
$message .= "by " . $person;
        $this -> bot -> send_output($name, $message , $this -> bot -> core("settings") -> get('Orders', 'Channel') );
$this -> unregister_event("cron");
    }

    /*
        Sends the current orders.
    */
function send_orders()
{
if(isset($this -> currentorders))
{
$this -> bot -> send_output("", $this -> currentorders, $this -> bot -> core("settings") -> get('Orders', 'Channel'));
}
}
} // End of Class
?>
« Last Edit: June 29, 2009, 11:12:26 pm by MafooUK »

Offline Tyrence

  • BeBot User
  • **
  • Posts: 41
  • Karma: +0/-0
Re: New Orders.php
« Reply #1 on: March 01, 2010, 07:22:26 pm »
I think a description of this module and what it does would be nice :)

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: New Orders.php
« Reply #2 on: March 03, 2010, 03:29:44 am »
I think a description of this module and what it does would be nice :)
Could it be...

Quote
'This module enables the raid leader to post current orders';
'orders' = "Shows the current orders";
'orders set' = "Sets the orders";
'orders clear' = "Clears the orders";
'orders refresh' = "resets the timer";

"The time arguments needs to be a format as described by http://www.gnu.org/software/tar/manual/html_node/tar_109.html "
"This means that formats like most dates and also '1 month', 'next thursday' etc. are allowed."

But yeah... something about what the module can be used for would probably help too. :)

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: New Orders.php
« Reply #3 on: March 03, 2010, 03:43:58 am »
for some reason I cannot upload the file so I have quoted it as code

Try changing the ".php" to ".phps" on the end of the file. Sometimes firewall filters get in the way of distributing what may be considered live or executable code. :)

And also open click on the " + Additional Options... " Just below the box where you type in this window.

 

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


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 ]

* Who's Online
  • Dot Guests: 217
  • 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