egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timed messages with expiration

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sat Oct 12, 2013 8:35 am    Post subject: Timed messages with expiration Reply with quote

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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Oct 13, 2013 1:57 pm    Post subject: Reply with quote

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. Smile

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
View user's profile Send private message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sun Oct 13, 2013 2:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sun Oct 13, 2013 2:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sun Oct 13, 2013 2:41 pm    Post subject: Reply with quote

Indeed you are right,

Tcl version: 8.4.19 (header version 8.4.19)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber