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

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

Author Topic: Custom Timers  (Read 48992 times)

0 Members and 3 Guests are viewing this topic.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Custom Timers
« on: November 27, 2005, 11:54:44 pm »
This will add the commands !timer and !timers to your bot.

You can set a timer by using "!timer 0:5:0 Test" to add a 5 minutes timer and so on.

The script will notify the chat group every 2/1 hours, and 30/15/5 minutes before timer expires.

Also you can use "!timer <ID>" to check remaining time.
« Last Edit: January 24, 2006, 10:33:18 pm by Wanuarmi »

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Custom Timers
« Reply #1 on: November 27, 2005, 11:55:33 pm »
help/timer.txt
help/timers.txt

Code: [Select]
<font color=CCInfoHeader><pre>timer | <pre>timers</font>
<font color=CCInfoText>Shows current timers.

<font color=CCInfoHeader><pre>timer &lt;HH:MM:SS&gt; &lt;description&gt;</font>
<font color=CCInfoText>Sets a timer. The timer will be announced 1 hour, 30 minutes, 15 minutes and 5 minutes before it ends.

<font color=CCInfoHeader><pre>timer del &lt;ID&gt;</font>
<font color=CCInfoText>Deletes a timer. Use the ID from the timers list.
« Last Edit: December 15, 2005, 12:07:15 am by Wanuarmi »

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Custom Timers
« Reply #2 on: November 27, 2005, 11:57:18 pm »
Nice one. Will play with it later :)
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Custom Timers
« Reply #3 on: December 07, 2005, 04:43:32 am »
This module is screwed. If there's no Timers in the DB it spams the console with:
Warning: Invalid argument supplied for foreach() in \Bebot\modules\CustomTimers.php on line 69

Also gives the same warning at start up but on line 164.

Suggest you test for Timer entries before you process those code pieces.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Custom Timers
« Reply #4 on: December 07, 2005, 08:52:59 am »
try placing

Code: [Select]


if (!empty($this -> timers)) {


}



around those foreach statements, my php doesnt show warnings

I wonder if anyone else is using this, I used it for about two weeks before posting, and so far I havent had problems with it

btw thanks khalem :) tell me if you guys find other problems with it

im not updating it to fix warnings unless thats the way most windows users have php setted for

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Custom Timers
« Reply #5 on: December 07, 2005, 09:22:37 am »
The Default for PHP.exe CLI is to show all warnings. Since most Windows users use the very minimal php.ini that comes with the Bot, it's best just to clean the code up so the Warnings don't happen... least the log fills up with a Warning for each time the cron job runs.

I had already placed those if() statements in the copy I'm running btw just so php wasn't spamming the hell out of the php window on my server.
Just wanted you to know it was broken if used as is. The same warnings would appear on Linux/Unix machines also, but I think most users of Linux use a global php.ini that has Warnings like that turned off.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Custom Timers
« Reply #6 on: December 15, 2005, 12:11:11 am »
updated, fixed xenixa's bug and did some minor tweakings so the code looks better
« Last Edit: December 15, 2005, 12:12:55 am by Wanuarmi »

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Custom Timers
« Reply #7 on: January 09, 2006, 08:55:56 pm »
updated, added command !timer <ID> that will show how much time until expiration

Offline jokerjr

  • BeBot Rookie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Custom Timers
« Reply #8 on: January 13, 2006, 01:06:36 am »
I use this module a lot thanks I love it.

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Custom Timers
« Reply #9 on: January 24, 2006, 10:29:47 pm »
thanks man, I appreciate it :)

updated, fixed a bug with dates, using gmdate() now instead of date()

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Custom Timers
« Reply #10 on: February 07, 2006, 01:46:34 am »
Hm, tried it on my bot and the time is 6 hours off.

My timezone is set to GMT -6...

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Custom Timers
« Reply #11 on: February 07, 2006, 05:50:38 pm »
this module uses GMT 0, for it to work on your timezone you would need to change all gmdate() for date() and gmmktime() for mktime()

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Custom Timers
« Reply #12 on: February 08, 2006, 12:17:21 am »
My point is the way you've coded it isn't time zone neutral. I had similar issues when working on my spawn time guesstimator, who would have thought a simple thing like time could have gotten so confusing? :)

The problem is gmmktime() assumes you are passing a GMT timestamp, and using just gmmktime() is fine if your system clock is set to GMT. If however you're system's clock is set to the local time zone, it seems you actually get local time, not GMT. The documentation leads me to believe that you should be getting a GMT timestamp, but in practice gmmktime() is giving me local time.

Using time() would be the correct method as time() always returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT), and hence will always be GMT time no matter what the system time zone is set to.

So in the end, the correct fix is to continue using gmdate(), but use time() instead of gmmktime(). I made this change on my bot and it works fine, and it should work no matter what my time zone the system is using.

(And please feel free to correct me if I've interpreted the PHP documentation incorrectly!)

* Although civil time, e.g., the Greenwich Time Signal in Great Britain, is now based on UTC, it is still popularly called GMT. See UTC and GMT at Wikipedia. :)

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
Re: Custom Timers
« Reply #13 on: February 08, 2006, 03:09:59 am »
I hate php date functions, I always lose time with them trying to get them right. You seem to be right with the time() function, though times are right on my bot and my server's local time isnt gmt. Ill check this out better later.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Custom Timers
« Reply #14 on: February 08, 2006, 10:01:21 pm »
I hate php date functions, I always lose time with them trying to get them right.

I totally agree.  ;D

 

* Recent Posts
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 ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

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