| View previous topic :: View next topic |
| Author |
Message |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sat Oct 12, 2013 8:35 am Post subject: Timed messages with expiration |
|
|
Hello
I need a script that I can define a message to be sent out at an interval of every few minutes defined by me to a chat room, and it expires when the time is over.
Here is an example:
| Quote: |
Defined channel is: #england
!timer 60 12.10.2013 12:00 This message will be sent out to #England every 60 minutes untill October 12th at 12:00
|
Help. thanks. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sun Oct 13, 2013 1:57 pm Post subject: |
|
|
| Code: |
## October 12, 2013
### http://forum.egghelp.org/viewtopic.php?t=19527
## Set channel here
set defined_chan "#eggdrop"
bind pub - "!timer" timed_announcer
proc timed_announcer {nick uhost handle chan text} {
global defined_chan
if {$chan != $defined_chan} {
return 0
}
if {$text == ""} {
putserv "privmsg $defined_chan :Sytax: !timer <interval> <DD.MM.YYYY> <HH:MM> <message text>"
return 0
}
set announce_interval [lindex [split $text] 0]
set expire_date [lindex [split $text] 1]
set expire_time [lindex [split $text] 2]
set announce_text [lrange [split $text] 3 end]
reset_timed_announce $announce_interval $expire_date $expire_time $announce_text
putserv "privmsg $nick :Timer started. Interval = $announce_interval Expiration date = $expire_date Expiration time = $expire_time"
putserv "privmsg $nick :Text to be announced: $announce_text"
}
proc reset_timed_announce {announce_interval expire_date expire_time announce_text} {
global defined_chan
putserv "privmsg $defined_chan :$announce_text"
set expire_hour [lindex [split $expire_time :] 0]
set expire_minute [lindex [split $expire_time :] 1]
set quit_time [clock scan "$expire_date $expire_hour $expire_minute" -format %e.%N.%Y%H%M]
if {$quit_time > [unixtime]} {
timer $announce_interval [list reset_timed_announce $announce_interval $expire_date $expire_time $announce_text]
return 0
} else {
return 0
}
}
|
Tested only briefly.
Give it a good test.
I suspect that there are other ways to do this. It will be interesting to see what else you get here.
I hope this helps. |
|
| Back to top |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sun Oct 13, 2013 2:13 pm Post subject: |
|
|
Hi willyw,
Thanks for the code.
I have one problem though:
[code][
Tcl error [timed_announcer]: bad switch "-format": must be -base or -gmt
/code]
My Input was:
!timer 240 13.10.2013 20:00 message here
What did I do wrong? it seems to fit the syntax according to the script..? |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sun Oct 13, 2013 2:28 pm Post subject: |
|
|
In partyline, do:
.status
and see the version of TCL
The bot I ran it on is:
Tcl version: 8.5.8 (header version 8.5.8 )
I wonder if that could be it.
Perhaps you are using 8.4 ... I'd have to go look it up, but I'm thinking that the clock command options changed from 8.4 to 8.5 |
|
| Back to top |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sun Oct 13, 2013 2:41 pm Post subject: |
|
|
Indeed you are right,
Tcl version: 8.4.19 (header version 8.4.19) |
|
| Back to top |
|
 |
|