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 

Simple countdown script

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


Joined: 03 Oct 2012
Posts: 3

PostPosted: Wed Oct 03, 2012 7:07 pm    Post subject: Simple countdown script Reply with quote

I have searched the TCL archives and can't seem to find a countdown script that does what I want. It doesn't involve birthdays or any certain "date".
I run a channel that frequently does "listen-alongs" to albums.
I just need a bot that I can set a time, like an hour or so in advance, and it will make an announcement in the channel every 5 minutes until it gets to the last 10 seconds. Then set the channel +m and do a complete countdown for the last 10 seconds then -m.
I'm not sure how complicated this would be but it would be awesome.

An example would be like this:
**MyBot sets mode +m #chan
MyBot: 10
MyBot: 9
MyBot: 8
MyBot: 7
MyBot: 6
MyBot: 5
MyBot: 4
MyBot: 3
MyBot: 2
MyBot: 1
MyBot: GO!
**MyBot sets mode -m

If you can script this for me you are awesome!
Thanks!
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Sat Oct 06, 2012 1:20 pm    Post subject: Reply with quote

test it:
Code:
# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# if you want to use this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +countd
# and later .save

##############################################
bind pub -|- !countdown cd_main

set cd_set 0
set sec_index 0
set cd_chan ""
set ann_interval 300

setudef flag countd

proc one_second_timer { } {
        global cd_set sec_index cd_chan ann_interval

        if {$sec_index >= 0} {
                if {$sec_index == 11} {
                        putserv "MODE $cd_chan +m" -next
                }

                if {($sec_index <= 10) && ($sec_index > 0)} {
                        putserv "PRIVMSG $cd_chan :$sec_index"
                }

                if {$sec_index == 1} {
                        putserv "PRIVMSG $cd_chan :GO!"
                        set cd_set 0
                }

                if {$sec_index == 0} {
                        putserv "MODE $cd_chan -m"
                }

                if {([expr $sec_index % $ann_interval] == 0) && ($cd_set == 1)} {
                        putserv "PRIVMSG $cd_chan :*** countdown: [expr $sec_index / $ann_interval] minute/s to go!"
                }

                if {[string match *one_second_timer* [utimers]] != 1} {
                        utimer 1 one_second_timer
                }

                set sec_index [expr $sec_index - 1]
        }
}

proc cd_main { nick uhost hand chan arg } {
        global cd_set sec_index cd_chan

        if {![channel get $chan countd]} {
                return
        }

        set minutes [string trim [lindex [split $arg] 0]]
        set cd_chan $chan

        if {$minutes != ""} {
                if {[regexp {^([0-9]+)$} $minutes]} {
                        if {$cd_set == 0} {
                                putquick "PRIVMSG $nick :done! ($minutes minute/s for You)"
                                set cd_set 1
                                set sec_index [expr $minutes * 60]
                                utimer 1 one_second_timer
                        } {
                                putquick "PRIVMSG $nick :sorry - one countdown at the same time is max"
                        }
                } {
                        putquick "PRIVMSG $chan :$nick, use: !countdown <minute/s (number ;))>"
                }
        } {
                putquick "PRIVMSG $chan :$nick, use: !countdown <minutes>"
        }
}

putlog "countdown.tcl ver 0.1 by tomekk loaded"


No multichannel support.
One more thing, this script works in eggdrop memory - so, every restart etc. will reset the script.
Back to top
View user's profile Send private message Visit poster's website
alextide32
Voice


Joined: 03 Oct 2012
Posts: 3

PostPosted: Sat Oct 06, 2012 3:10 pm    Post subject: Reply with quote

Perfect! This is exactly what I was looking for!
There is one small issue that might be easily fixed, when the countdown is at 5 minutes out it says "1 minute/s to go!" and when it's 10 minutes out it says "2 minute/s to go!". I don't know how easy this is to fix but if you can't get it to work you can just take it out and it will be fine.
Also is there a way to make it so only people with +o flags on the bot can use it?
Thanks for taking the time to script this!
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Sat Oct 06, 2012 3:44 pm    Post subject: Reply with quote

1.
change:
Code:
bind pub -|- !countdown cd_main


to:
Code:
bind pub -|o !countdown cd_main



2.
change:
Code:
putserv "PRIVMSG $cd_chan :*** countdown: [expr $sec_index / $ann_interval] minute/s to go!"


to:
Code:
putserv "PRIVMSG $cd_chan :*** countdown: [expr [expr $sec_index / $ann_interval] * [expr $ann_interval / 60]] minute/s to go!"
Back to top
View user's profile Send private message Visit poster's website
alextide32
Voice


Joined: 03 Oct 2012
Posts: 3

PostPosted: Sat Oct 06, 2012 4:19 pm    Post subject: Reply with quote

Works perfectly! Thanks so much for your help!
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