This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Eggdrop - Topic countdown

Help for those learning Tcl or writing their own scripts.
Post Reply
T
TheOne1337
Voice
Posts: 5
Joined: Mon Aug 14, 2006 1:25 pm

Eggdrop - Topic countdown

Post by TheOne1337 »

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: Select all

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"
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Firstly, you can get rid of all those ugly variables and use one simple expr whilst setting the topic:

Code: Select all

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: Select all

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
T
TheOne1337
Voice
Posts: 5
Joined: Mon Aug 14, 2006 1:25 pm

Post by TheOne1337 »

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.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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"?
T
TheOne1337
Voice
Posts: 5
Joined: Mon Aug 14, 2006 1:25 pm

Post by TheOne1337 »

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: Select all

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"
Post Reply