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.

Topic Day Change

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Topic Day Change

Post by Dominatez »

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

Re: Topic Day Change

Post by willyw »

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

Re: Topic Day Change

Post by willyw »

Try this.

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
        }

}
###
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 !
s
simo
Revered One
Posts: 1069
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

try this :

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]" 
}

User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The cron mask should be {00 00 * * *} since he asked for every midnight.

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]"
}
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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 !
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Tried it. Adjusted it. Doesn't do anything come 24:00 or 24:01
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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 !
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Check this out! Regsub

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
vs. string map

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
And if make a small change:

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
Btw, replace "foo" with $day :)
Once the game is over, the king and the pawn go back in the same box.
Post Reply