| View previous topic :: View next topic |
| Author |
Message |
Dominatez Halfop

Joined: 14 Jan 2019 Posts: 46 Location: United Kingdom
|
Posted: Sun Feb 24, 2019 8:35 pm Post subject: Topic Day Change |
|
|
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 ! |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Feb 25, 2019 12:44 pm Post subject: Re: Topic Day Change |
|
|
First:
Have you looked through all the topic related scripts found here?
http://tclarchive.org/search.php?Topic
There are 42. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Feb 25, 2019 6:03 pm Post subject: Re: Topic Day Change |
|
|
Try this.
| Code: |
# 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
}
}
###
|
And this looks kind of clunky. Maybe somebody else here will have better / other ideas.  _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Tue Feb 26, 2019 5:37 pm Post subject: |
|
|
try this :
| Code: |
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]"
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Feb 27, 2019 2:10 am Post subject: |
|
|
The cron mask should be {00 00 * * *} since he asked for every midnight.
| Code: |
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]"
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Feb 27, 2019 10:49 am Post subject: |
|
|
| caesar wrote: | ... since he asked for every midnight.
|
That he did.
However, I used [strftime %A] and am not sure what it will do right at midnight.
So, I set it for one minute more, and specifically noted it in comments. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
Dominatez Halfop

Joined: 14 Jan 2019 Posts: 46 Location: United Kingdom
|
Posted: Thu Mar 07, 2019 4:08 pm Post subject: |
|
|
| Tried it. Adjusted it. Doesn't do anything come 24:00 or 24:01 |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Mar 07, 2019 4:23 pm Post subject: |
|
|
| Dominatez wrote: | | Tried it. Adjusted it. Doesn't do anything come 24:00 or 24:01 |
Which "it" did you try? _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Mar 08, 2019 2:48 am Post subject: |
|
|
Check this out! Regsub
| Code: |
% 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
|
vs. string map
| Code: |
% 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
|
And if make a small change:
| Code: |
% 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
|
Btw, replace "foo" with $day  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
|