Code: Select all
# Feb. 25, 2019
# http://forum.egghelp.org/viewtopic.php?t=20596
##
# Is there a script that allows the bot to change the topic at 24:00
#
# Example.
#
# Today is Now Sunday. Welcome to our channel. Blah Blah Blah.
#
# So everyday at midnight it will only change the day and leave the rest of the topic intact !
##
#
##
# Note: With the current bind cron - "1 0 * * *" , it should trigger at 00:01 daily
##
#
# Set the channel that this script will work on.
set working_chan "#your_channel_name_here"
#
bind cron - "1 0 * * *" daily_topic_announce
proc daily_topic_announce {min hour day month weekday} {
global working_chan
if {![botonchan $working_chan]} {
return 0
}
if {![botisop $working_chan]} {
return 0
}
if {[regsub Sunday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Monday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Tuesday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Wednesday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Thursday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Friday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
if {[regsub Saturday [topic $working_chan] [strftime %A] outmsg]} {
putserv "topic $working_chan :$outmsg"
return 0
}
}
###
Code: Select all
set working_chan "#channel"
bind cron - {1 * * * *} daily_topic_announce
proc daily_topic_announce {min hr day mo yr} {
global working_chan
set day [strftime %A]
putserv "TOPIC $working_chan :$day [topic $working_chan]"
}
Code: Select all
set working_chan "#channel"
bind cron - {00 00 * * *} daily_topic_announce
proc daily_topic_announce {min hr day mo yr} {
global working_chan
if {![botonchan $working_chan] || ![botisop $working_chan]} return
set days { Monday Tuesday Wednesday Thursday Friday Saturday Sunday }
set day [strftime %A]
set topic [topic $working_chan]
foreach day $days { regsub $day $topic newTopic }
putserv "TOPIC $working_chan :[topic $newTopic]"
}
That he did.caesar wrote:... since he asked for every midnight.
Code: Select all
% proc swap args {
set topic "bla bla topic Thursday bla bla bla"
set days { Monday Tuesday Wednesday Thursday Friday Saturday Sunday }
foreach day $days {
regsub $day $topic newTopic
}
}
% time swap 1000
15.683 microseconds per iteration
Code: Select all
% proc swap args {
set topic "bla bla topic Thursday bla bla bla"
set days { Monday Tuesday Wednesday Thursday Friday Saturday Sunday }
foreach day $days {
set newTopic [string map [list $day "foo"] $topic]
}
}
% time swap 1000
7.406 microseconds per iteration
Code: Select all
% proc swap args {
set topic "bla bla topic Thursday bla bla bla"
set days { Monday Tuesday Wednesday Thursday Friday Saturday Sunday }
foreach day $days {
if {[string first $day $topic] > -1} {
set newTopic [string map [list $day "foo"] $topic]
break
}
}
}
% time swap 1000
3.001 microseconds per iteration