BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Age of Conan Archive => BeBot Hyborian modules => Topic started by: Organizer on August 05, 2008, 03:55:47 pm

Title: Simple Tells in Guild Chat as Cron tasks
Post by: Organizer on August 05, 2008, 03:55:47 pm
I'm a total noob on this, I know some simple PHP and essential stuff but coding anything from scratch is unfortunately not me. My issues now is that I would like our guild bot to spam some text strings at certain intervals.

For instance if we have some important news that we would like to give more focus than using the !news or guild announcement system for: e.g. that we would like the bot to send out a tell every 3 hours e.g. saying "quick reminder everyone; we're building the Guild city on next Tuesday, be there at 21:00 CET". Optimally it should of course also allow chat link codes in this text.

While I'm willing to set and change these texts in the PHP myself all manually, I can't even work our how a cron tasks get started/programmed. So maybe someone can help me out with the basic of doing something manual :)

If in the Module form I guess some more commands would be required:

// add a new timed chat message to the list
!cron add <interval> <message>


// list of messages with a Delete or Pause/Resume link option, also shows their ID
!cron list

// deletes a certain message ID, same as clicking the Delete link in the list
!cron del <id>

// places a messages on hold, same as clicking Pause link in the list
!cron pause <id>

// resumes a messages on hold, same as clicking Resume link in the list
!cron resume <id>

// changes text or interval of a message
!cron change interval <id> <new interval>
!cron change message <id> <new message>

So if someone wants to take on this module or not I don't know, but maybe someone can help me with a manually edited cron module for now?

What I tried to create myself is simple manually updated one ->

Code: [Select]
<?

$cron_messages = new cron_messages($bot);

class cron_messages Extends BaseActiveModule
{
var $bot;

function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));
$this -> register_event('cron', '2min');
}


function cron()
{
$this -> bot -> send_gc( "just a test ");
}

}
?>

This gives me the error:

Fatal error: Class cron_messages contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (BaseActiveModule::command_handler) in G:\arabia_source_files\bebot052r13\custom\modules\crons.php on line 23




Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Vrykolas on August 05, 2008, 04:19:40 pm
you're on track with what you have, however for a class that extends BaseActiveModule (one that can recieve commands) you have to write a function called command_handler (even if there's nothing in it)

You may find some more useful bits and pieces here (http://bebot.link/wiki/base_module).
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Organizer on August 05, 2008, 06:31:20 pm
Thanks got it to work by as you said just adding the command_handler without any information inside, so this is good enough for now at least... :)
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Organizer on August 05, 2008, 08:03:26 pm
One issue someone might be able to hint on... if I reset the bot I presume this script just resets and start spamming out, is there a way to sort of not start directly, easily set a delay before first run?
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Vrykolas on August 06, 2008, 01:18:46 am
try:
Code: [Select]
function cron()
{
if(!isset($delay_until))
static $delay_until = time() + 300;

if($delay_until <= $time())
$this -> bot -> send_gc( "just a test ");
}

for a 5 min delay (just off the top of my head & not tested)
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Organizer on August 12, 2008, 01:05:59 am
Thanks Vrykolas, managed in the end to get it to work, did not fix it with static though as I got an error on that, but made a global variable outside the loop and that worked...

New questions, is there a logical way for this cron task to e.g. trigger the function of another module? E.g. that I want the city.php module to trigger its basic function of displaying the City status or even get it to trigger quotes.php or chuck.php to give a quote? I tried to call the function by name but that logically apparently not working as the function is not in that file... any tips welcome :)
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Organizer on August 16, 2008, 05:10:36 pm
hi guys, guess you all think it was to noobish a question, but I'm still looking into how I can trigger a function of another module... e.g have this module trigger a quote every hour or similar. Is there some way to do this or would that part have to be a cron task of the quote module and just impossible to trigger from my little cron text module???
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Ossii on December 02, 2009, 04:18:32 pm
Hi, does anyone know if this script will still work? Or anyone have another more recent script to "spam" guildchat with messages every xxx minutes. Typically, "Have you signed up for this weeks raid" every 2 hours for example.
Title: Re: Simple Tells in Guild Chat as Cron tasks
Post by: Kyr on December 03, 2009, 08:51:01 am
I think you should be able to do all of this with the commands:
Not logged in atm to test if I have those right but there are commands for sending messages on a timer and a repeat timer.
SimplePortal 2.3.7 © 2008-2024, SimplePortal