BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => AO 0.6.x Custom/Unofficial modules => Anarchy Online Archive => AO official modules => Topic started by: Alreadythere on August 03, 2007, 07:31:58 pm

Title: Alternate Timer implementation
Post by: Alreadythere on August 03, 2007, 07:31:58 pm
I've rewritten my (never published) timer module for bebot, as that one did permanent SQL spam.

The module  saves timers in a table, supports notifies via timer classes (though there is no way to define any own classes besides the standard one yet, it's on my list of things to add) and it queries the SQL table only if any event (either timer finished or notification needed) is happening.

The implementation consists of two modules atm, one core module handling the backend stuff and offering functions to other modules to add and delete timer, and one GUI module handling all user interactions.

The module supports relaying timers to other bots using an existing relay. You need to setup a relay using the Relay_GUILD.php module. Then load the TimerRelay.php module from the link below, and enable the setting Relay of the timer module. All done.

Commands:

Core module (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/core/Timer_Core.php?view=co), save as .php in your core folder.
GUI module (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/modules/TimerGUI.php?view=co), save as .php in your modules folder.
Relay module (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/modules/TimerRelay_GUILD.php?view=co), save as .php in your modules folder.

Bot core (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/Sources/Bot.php?view=co), save as .php in your Sources folder.

Note: You'll need the most current version of the relay module from the SVN for the relaying to work. Get it here (http://svn.shadow-realm.org/index.py/BeBot/branches/0.4/modules/Relay_GUILD.php?revision=867), save as .php into the modules folder again.

Things on my TODO:
Title: Re: Alternate Timer implementation
Post by: Alreadythere on August 04, 2007, 06:31:05 pm
Added support to relay timer, read first post.

The module supports relaying timers to other bots using an existing relay. You need to setup a relay using the Relay_GUILD.php module. Then load the TimerRelay.php module from the link below, and enable the setting Relay of the timer module. All done.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on August 04, 2007, 08:04:59 pm
Added note about the need for the SVN version of the relay module.
Title: Re: Alternate Timer implementation
Post by: Newsworthy on August 05, 2007, 03:50:58 am
Love the module, thanks for posting! :)

Just one error I found, adding a timer via /tell, it doesn't like the format Mins:Secs. Only accepts when posted without the :

Example:

To [Scnet]: !timer 300 TEST
[Scnet]: Timer TEST with 00:05:00 runtime started!
To [Scnet]: !timer 01:00 TEST
Nothing happens.

Thanks :)
Title: Re: Alternate Timer implementation
Post by: Alreadythere on August 05, 2007, 09:46:40 am
That was actually a "feature", the regexp didn't accept 0 as first letter for a duration. Changed, updated file in first post.
Title: Re: Alternate Timer implementation
Post by: Khalem on August 05, 2007, 02:39:36 pm
Propose adding this to SVN trunk at the very least.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on August 05, 2007, 07:22:12 pm
Added to 0.5 and 0.4 lines.
Title: Re: Alternate Timer implementation
Post by: Khalem on August 06, 2007, 02:25:48 am
Reminder for myself and Alreadythere.

Module missing help.
Title: Re: Alternate Timer implementation
Post by: Parfet on August 06, 2007, 02:58:37 am
i made a start of help for this plugin myself, off the 1st(?) post, before the relay changes

Code: [Select]
$this -> help['description'] = 'Creates Timers.';
$this -> help['command']['timer #[mshd] title']="- adds a timer for # minutes (m), seconds (s), hours (h) or days (d). If no time unit is added it's # seconds.";
$this -> help['command']['timer #[:##[:##[:##]]] title']="- adds a timer using the format days:hours:minutes:seconds, with the lowest time unit always being seconds (so 1:20 means 1min 20secs, 1:03:05 means 1hour 3mins 5secs). On every : there have to follow exactly two numbers.";
$this -> help['command']['timers']="- lists all current timer for the bot and offers support to delete them. " . ucfirst(strtolower($this -> bot -> settings -> get("Timer", "DeleteRank"))) . " can delete timers of other users, users can always delete their own timers or a timer of one of their registered alts.";

granted this is mostly cut&paste from the first post
Title: Re: Alternate Timer implementation
Post by: Newsworthy on August 07, 2007, 07:15:29 am
Is there a way to reduce the amount of times it notifies you of the timer running out?

ie, removing the 10second counter, and having say, 5min, 1min, 30sec, end? Thanks :)
Title: Re: Alternate Timer implementation
Post by: Alreadythere on August 07, 2007, 10:42:00 am
Not yet, but it's on the list of things to add.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on September 18, 2007, 10:33:16 pm
Added functions to create timer classes as well as a LowSpam timer class, which notices less often about a running timer.

Edited the above links, they now always point to the most current version of the timer files in the 0.4 SVN branch.
Title: Re: Alternate Timer implementation
Post by: Ziodberg on September 20, 2007, 01:31:59 am
This ist not as it was intended, or is it?

[Carpe Noctem] Jalajala: !timer 30 bla
[Carpe Noctem] Aidbot: Teemer ##heeghleeght##bla eend##veet ##heeghleeght#eend##roonteeme-a sterted!
Bork Bork Bork!

I get the same kind of reply when i use !memberlist
Title: Re: Alternate Timer implementation
Post by: Alreadythere on September 24, 2007, 04:10:28 pm
Kill the string filter you are running, that will solve the problem for the moment.

It'll need a slight internal rework to do all replacement work before using the string filter, that's what's braking the bot right now.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on September 24, 2007, 04:27:29 pm
Fixed the core module to update the class cache for timer classes each time after a new entry is created. Otherwise the module wouldn't have any clue what to do with new classes till the next cache update.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on October 03, 2007, 12:27:22 pm
Added timer class as optional first parameter to !timer calls.

!timer lowspam 15m title will create a timer using the lowspam class, !timer 15m title will create a timer using the default class (whichever that is).

Just grab TimerGUI.php again.

The code below will create a timer class with only two notices at 5min and 10min till timer runs out. Use this and the definitions in Timer_Core.php, the city module and the orbital module as bases for any custom timer classes you want to create. Read up on the explanation on top of the Timer_Core.php too.
Code: [Select]
$classid = $this -> create_timer_class("AlmostNoSpam", "Timer class that only spams at 5 and 10mins left.");
$nextid = $this -> create_timer_class_entry($classid, -1, 300, "Timer", "has five minutes left");
$nextid = $this -> create_timer_class_entry($classid, $nextid, 600, "Timer", "has ten minutes left");
Title: Re: Alternate Timer implementation
Post by: Alreadythere on October 07, 2007, 02:17:53 pm
Added support for timed events. This way a module can register itself to the timer core for callbacks, and then use the add_timer() function to get the registered callback function called at a specific time. All that needs to be done in addition to the registering and the adding of the timer is the implementation of a timer() function in the module. For more information how to use this feature read the comment at the top of the core/Timer_Core.php file.

This is supposed to be an extension to the existing cron system. For repeating events use the current cron system, for events that only happen once or once in a while, perhaps even without a fixed duration between two events, it may be better to use the timer system instead of registering and unregistering a cron job and perhaps doing your own time calculation in there.

I changed the hooking of timers into the cron system, so for the most current version in the 0.4 branch to work at all you'll have to update your Bot.php too this time. I added a link to the most current version in the SVN in the first post.
Title: Re: Alternate Timer implementation
Post by: Trancillion on October 07, 2007, 07:45:53 pm
Seems like i have a problem with the timer :s whole minutes goes fine ut if i use for example 29:45 then it don't want to tell me the normale time it uoly tells it's 10 min left etc, any ides ? just me and my guild mates that has this problem with it ?

To [Noctrish]: !timer 20:00 Comatosed Soul
[Noctrish]: Timer Comatosed Soul with 00:20:00 runtime started!
[Noctrish]: Timer Comatosed Soul has 10 minutes left!
[Noctrish]: Timer Comatosed Soul has 5 minutes left!
[Noctrish]: Timer Comatosed Soul has two minutes left!
To [Noctrish]: !timer 29:45 mhm
[Noctrish]: Timer mhm with 00:29:45 runtime started!
[Noctrish]: Timer Comatosed Soul has one minute left!
[Noctrish]: Timer Comatosed Soul has 30 seconds left!
[Noctrish]: Timer Comatosed Soul has 10 seconds left!
[Noctrish]: Timer Comatosed Soul has finished!
[Noctrish]: Timer mhm has 20 minutes left!
[Noctrish]: Rotta!mhm!

the end line "Rotta!mhm!"  Rotta was one of my team mates timer that had the same problem as mhm.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on October 07, 2007, 08:02:28 pm
I'm not quite clear what the error is, or how to reproduce it. I did some testing with timers in the format X:YZ, and they worked as expected.

And what do you mean with it don't want to tell me the normale time it uoly tells it's 10 min left etc?
Title: Re: Alternate Timer implementation
Post by: Trancillion on October 08, 2007, 08:40:46 am
To [Noctrish]: !timer 29:45 mhm
[Noctrish]: Timer mhm with 00:29:45 runtime started!
[Noctrish]: Timer mhm has 20 minutes left!
[Noctrish]: Rotta!mhm!

is what i meant. it only tells when it' 20 min left, and the Small notice when it's over.

It should tell when it's 20min 10min 5min 2min 1min 30sec 10sec and give a finish message no?

if it help you and you want to try and find out the error, i can give you access to both database and the bot files.
Title: Re: Alternate Timer implementation
Post by: Alreadythere on October 09, 2007, 01:30:37 pm
Did this happen once only? Or is it happening regulary?
Title: Re: Alternate Timer implementation
Post by: Trancillion on October 09, 2007, 09:37:32 pm
from what my firend tells me it happens with every timer that is over 20min. I haven't had the time myselfe yet to check that out, tho he uses the !timer command alot pr day.
SimplePortal 2.3.7 © 2008-2024, SimplePortal