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: Simple Tells in Guild Chat as Cron tasks  (Read 15940 times)

0 Members and 1 Guest are viewing this topic.

Offline Organizer

  • BeBot Apprentice
  • ***
  • Posts: 135
  • Karma: +0/-0
Simple Tells in Guild Chat as Cron tasks
« 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




« Last Edit: August 05, 2008, 03:57:33 pm by Organizer »

Offline Vrykolas

  • BeBot Apprentice
  • ***
  • Posts: 100
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #1 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.

Offline Organizer

  • BeBot Apprentice
  • ***
  • Posts: 135
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #2 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... :)

Offline Organizer

  • BeBot Apprentice
  • ***
  • Posts: 135
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #3 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?

Offline Vrykolas

  • BeBot Apprentice
  • ***
  • Posts: 100
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #4 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)

Offline Organizer

  • BeBot Apprentice
  • ***
  • Posts: 135
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #5 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 :)

Offline Organizer

  • BeBot Apprentice
  • ***
  • Posts: 135
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #6 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???

Offline Ossii

  • BeBot Rookie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #7 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.

Offline Kyr

  • BeBot Apprentice
  • ***
  • Posts: 177
  • Karma: +0/-0
Re: Simple Tells in Guild Chat as Cron tasks
« Reply #8 on: December 03, 2009, 08:51:01 am »
I think you should be able to do all of this with the commands:
  • !timer
  • !rtimer
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.

 

* 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: 107
  • 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