L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 02, 2008, 05:19:03 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > BeBot Hyborian Modules > Topic: Simple Tells in Guild Chat as Cron tasks
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Simple Tells in Guild Chat as Cron tasks  (Read 425 times)
0 Members and 1 Guest are viewing this topic.
Organizer
Apprentice
***
Offline Offline

Posts: 84


Simple Tells in Guild Chat as Cron tasks
« on: August 05, 2008, 08:55:47 AM »

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 Smiley

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:
<?

$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, 08:57:33 AM by Organizer » Logged
Vrykolas
BeBot Hyborian Developer
Apprentice
*******
Offline Offline

Posts: 100


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #1 on: August 05, 2008, 09:19:40 AM »

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.
Logged
Organizer
Apprentice
***
Offline Offline

Posts: 84


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #2 on: August 05, 2008, 11:31:20 AM »

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... Smiley
Logged
Organizer
Apprentice
***
Offline Offline

Posts: 84


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #3 on: August 05, 2008, 01: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?
Logged
Vrykolas
BeBot Hyborian Developer
Apprentice
*******
Offline Offline

Posts: 100


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #4 on: August 05, 2008, 06:18:46 PM »

try:
Code:
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)
Logged
Organizer
Apprentice
***
Offline Offline

Posts: 84


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #5 on: August 11, 2008, 06:05:59 PM »

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 Smiley
Logged
Organizer
Apprentice
***
Offline Offline

Posts: 84


Re: Simple Tells in Guild Chat as Cron tasks
« Reply #6 on: August 16, 2008, 10:10:36 AM »

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???
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > BeBot Hyborian Modules > Topic: Simple Tells in Guild Chat as Cron tasks
« previous next »
 
Jump to:  

Recent
Log playtime from buddys ...
by IKShadow
[Today at 06:48:12 AM]

[request] Raid timers
by Elesar1
[December 01, 2008, 04:41:09 PM]

Shared DB online list
by Temar
[December 01, 2008, 01:55:47 AM]

relay colors
by Temar
[December 01, 2008, 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]
Stats
Members
Total Members: 1244
Latest: Armonkens
Stats
Total Posts: 11145
Total Topics: 1505
Online Today: 25
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 3
Guests: 14
Total: 17
Agnot
Glarawyn

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.395 seconds with 29 queries. (Pretty URLs adds 0.027s, 4q)
Loading...