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.

Timed messages with expiration

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Timed messages with expiration

Post by BigToe »

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:
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.
w
willyw
Revered One
Posts: 1204
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Code: Select all

## 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.
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Hi willyw,

Thanks for the code.

I have one problem though:

Code: Select all

[
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..?
w
willyw
Revered One
Posts: 1204
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Indeed you are right,

Tcl version: 8.4.19 (header version 8.4.19)
Post Reply