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 

Topic Day Change

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


Joined: 14 Jan 2019
Posts: 27
Location: United Kingdom

PostPosted: Sun Feb 24, 2019 8:35 pm    Post subject: Topic Day Change Reply with quote

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


Joined: 15 Jan 2009
Posts: 1031

PostPosted: Mon Feb 25, 2019 12:44 pm    Post subject: Re: Topic Day Change Reply with quote

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


Joined: 15 Jan 2009
Posts: 1031

PostPosted: Mon Feb 25, 2019 6:03 pm    Post subject: Re: Topic Day Change Reply with quote

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. Smile
_________________
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
View user's profile Send private message
simo
Master


Joined: 22 Mar 2015
Posts: 330

PostPosted: Tue Feb 26, 2019 5:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3581
Location: Mint Factory

PostPosted: Wed Feb 27, 2019 2:10 am    Post subject: Reply with quote

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

_________________
I tawt I taw a puddy tat!
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1031

PostPosted: Wed Feb 27, 2019 10:49 am    Post subject: Reply with quote

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. Smile
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
View user's profile Send private message
Dominatez
Voice


Joined: 14 Jan 2019
Posts: 27
Location: United Kingdom

PostPosted: Thu Mar 07, 2019 4:08 pm    Post subject: Reply with quote

Tried it. Adjusted it. Doesn't do anything come 24:00 or 24:01
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1031

PostPosted: Thu Mar 07, 2019 4:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3581
Location: Mint Factory

PostPosted: Fri Mar 08, 2019 2:48 am    Post subject: Reply with quote

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 Smile
_________________
I tawt I taw a puddy tat!
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