| View previous topic :: View next topic |
| Author |
Message |
TheOne1337 Voice
Joined: 14 Aug 2006 Posts: 5
|
Posted: Wed Oct 08, 2008 12:55 am Post subject: Eggdrop - Topic countdown |
|
|
Hi,
I made this TCL script with 0-hour experience. It works just the way i want but there is couple of mystery things. This is very RAW-code, cause all is hard coded directly to script, but it isn't problem to me.
Problems with this is, that it doesn't update topic only at 00:03. Today topic has changed today 3 times. First 00:03 then 00:06 and latest 07:07.
Second weird thing is that, when topic have changed at 00:03 and 00:06, ONLY diff1 has updated to topic. Other numbers are wrong, they haven't updated. But when today 07:07 script (For some reason?) has again changed topic, then all days was correct.
Can anyone explain what causes those things, cause i don't have any idea.
| Code: |
bind time - "03 00 * * *" time:topic
proc time:topic { min hour day month year } {
##Far Cry 2 Release date
set date1 [clock scan "2008-10-21"]
##Red Alert 3, Fallout 3 Release date
set date2 [clock scan "2008-10-28"]
##Call of Duty: World at War Release date
set date3 [clock scan "2008-11-11"]
##Grand Theft Auto IV (GTA 4) Release date
set date4 [clock scan "2008-11-18"]
##Date now
set now [clock seconds]
set diff1 [expr {(($date1 - $now)/60/60/24)+1}]
set diff2 [expr {(($date2 - $now)/60/60/24)+1}]
set diff3 [expr {(($date3 - $now)/60/60/24)+1}]
set diff4 [expr {(($date4 - $now)/60/60/24)+1}]
puthelp "TOPIC #my_channel :Far Cry 2 ($diff1 days) | Red Alert 3 ($diff2 days) | Fallout 3 ($diff2 days) | CoD: World at War ($diff3 days) | GTA IV ($diff4 days) | NFS: Undercover ($diff4 days)"
}
putlog "Topic countdown by me"
|
|
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Wed Oct 08, 2008 7:36 am Post subject: |
|
|
Firstly, you can get rid of all those ugly variables and use one simple expr whilst setting the topic:
| Code: | bind time - "03 00 * * *" time:topic
proc time:topic {min hour day month year} {
# lets do a little check to make sure it only runs at 00 hour 03 minute
if {$hour != "00" && $min != "03"} { return }
puthelp "TOPIC #my_channel :Far Cry 2 ([expr {([clock scan "2008-10-21"]-[clock seconds])/60/60/24+1}] days) | Red Alert 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | Fallout 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | CoD: World at War ([expr {([clock scan "2008-11-11"]-[clock seconds])/60/60/24+1}] days) | GTA IV ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | NFS: Undercover ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days)"
} |
Or, another way you code do this is to regsub the values into the topic:
| Code: | bind time - "03 00 * * *" time:topic
proc time:topic {min hour day month year} {
# lets do a little check to make sure it only runs at 00 hour 03 minute
if {$hour != "00" && $min != "03"} { return }
set topic "Far Cry 2 (:farcry2: days) | Red Alert 3 (:redalert3: days) | Fallout 3 (:fallout3: days) | CoD: World at War (:codwaw: days) | GTA IV (:gta4: days) | NFS: Undercover (:nfsuc: days)"
regsub -nocase -all :farcry2: "$topic" "[expr {([clock scan "2008-10-21"]-[clock seconds])/60/60/24+1}]" topic
regsub -nocase -all :redalert3:|:fallout3: "$topic" "[expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}]" topic
regsub -nocase -all :codwaw: "$topic" "[expr {([clock scan "2008-11-11"]-[clock seconds])/60/60/24+1}]" topic
regsub -nocase -all :gta4: "$topic" "[expr {([clock scan "2008-11-18"]-[clock seconds])/60/60/24+1}]" topic
puthelp "TOPIC #my_channel :$topic"
} |
_________________ r0t3n @ #r0t3n @ Quakenet |
|
| Back to top |
|
 |
TheOne1337 Voice
Joined: 14 Aug 2006 Posts: 5
|
Posted: Wed Oct 08, 2008 11:05 pm Post subject: |
|
|
Thanks for your help. I tried your first example. There is that time check " if {$hour != "00" && $min != "03"} { return }", but you don't even wanna know. I rehashed bot after i updated this script, but still my channel topic has changed 2 times at night.
(00:01:00) * MyBot changes topic to 'Far Cry 2 (12 days) | Red Alert 3 (20 days) | Fallout 3 (20 days) | CoD: World at War (34 days) | GTA IV (41 days) | NFS: Undercover (41 days)'
(00:03:04) * MyBot changes topic to 'Far Cry 2 (12 days) | Red Alert 3 (20 days) | Fallout 3 (20 days) | CoD: World at War (34 days) | GTA IV (41 days) | NFS: Undercover (41 days)'
Other funny thing is that only Far Cry 2 days have changed, all other is wrong. They haven't updatet. They should be 1 day less. |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Oct 10, 2008 3:29 am Post subject: |
|
|
Sounds like you have some left over binds and procs in your bot. Do a .restart or, if you don't want to restart, remove the binds by hand (.tcl binds time, .tcl unbind ...) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
TheOne1337 Voice
Joined: 14 Aug 2006 Posts: 5
|
Posted: Sun Oct 12, 2008 11:11 pm Post subject: |
|
|
You were right, there was many time binds, what i used when i debugged code. Restartting bot helped. Still i got this one problem.
This is my current script and only problem what i have, is that: When time hits 00:05 and topic updates, ONLY fyrst (Red Alert 3) days are changed. I made this manual bind "!topic_update" so i could update topic manually when i want, and i updated topic 06:00, but still only Red Alert 3 days are changed. Then i restarted bot, and made again manual update and tadaa, all days was updated. What is causing this? Topic is staying somekind of cache or why this could be possible that it needs to be restarted?
| Code: |
bind time - "05 00 % % %" topic:timer
bind msg - !topic_update topic:now
proc topic:now {nick host hand arg} {
if {![botisop #my_channel]} {return 0}
puthelp "TOPIC #my_channel :Far Cry 2 ([expr {([clock scan "2008-10-21"]-[clock seconds])/60/60/24+1}] days) | Red Alert 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | Fallout 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | CoD: World at War ([expr {([clock scan "2008-11-11"]-[clock seconds])/60/60/24+1}] days) | GTA IV ([expr {([clock scan "2008-11-18"]-[clock seconds])/60/60/24+1}] days) | NFS: Undercover ([expr {([clock scan "2008-11-18"]-[clock seconds])/60/60/24+1}] days)"
}
proc topic:timer {min hour day month year} {
if {$hour != "00" && $min != "05"} {return 0}
if {![botisop #my_channel]} {return 0}
puthelp "TOPIC #my_channel :Far Cry 2 ([expr {([clock scan "2008-10-21"]-[clock seconds])/60/60/24+1}] days) | Red Alert 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | Fallout 3 ([expr {([clock scan "2008-10-28"]-[clock seconds])/60/60/24+1}] days) | CoD: World at War ([expr {([clock scan "2008-11-11"]-[clock seconds])/60/60/24+1}] days) | GTA IV ([expr {([clock scan "2008-11-18"]-[clock seconds])/60/60/24+1}] days) | NFS: Undercover ([expr {([clock scan "2008-11-18"]-[clock seconds])/60/60/24+1}] days)"
}
putlog "Topic Countdown"
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|