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.

Trivia TCL Script Modification

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
mondino
Voice
Posts: 12
Joined: Mon Jul 09, 2018 8:11 am
Location: Lebanon
Contact:

Trivia TCL Script Modification

Post by mondino »

Dears all;

I am using this trivia script - https://pastebin.com/RK6hRWPD - I want to modify it, such that it will be On and Off on a schedule. Like 2 hours on, and 1 hour off.

Anybody can help?

Thanks in advance
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Trivia TCL Script Modification

Post by CrazyCat »

Can be done quite easily:

1. comment the 2 binds (!start and !stop):

Code: Select all

#bind pubm $tgflagsstart "$tgchan %$tgcmdstart" tgstart
#bind pubm $tgflagsstop "$tgchan %$tgcmdstop" tgstop
2. add crontab binds:

Code: Select all

bind cron - "00 02,05,08,11,14,17,20,23 * * *" timetgstart
bind cron - "00 01,04,07,10,13,16,19,22 * * *" timetgstop
3. add the following procedures:

Code: Select all

proc timetgstart {min hour day month dow} {
   tgstart $::botnick "launch@127.0.0.1" * $::tgchan ""
}
proc timetgstop {min hour day month dow} {
   tgstop $::botnick "launch@127.0.0.1" * $::tgchan ""
}
I'd tried to modify the lesser the code, so the timetgstart and timetgstop fake a !start and !stop command.

Remember that if you just reload the script (via .tcl source or .rehash), you'll have to unbind manually the !start and !stop binds
User avatar
mondino
Voice
Posts: 12
Joined: Mon Jul 09, 2018 8:11 am
Location: Lebanon
Contact:

Re: Trivia TCL Script Modification

Post by mondino »

Hi CrazyCat;

I thank you so much for your reply.

I have put your code on my Trivia Eggdrop Bot, and I'm testing it. Till now, it is working very well.

I'll do some more modifications on it, like put in few output messages to tell the users when the bot is gonna be on OFF and ON modes, so they get to know when the game will be available and when not.

I, actually, don't want the game to be accessible (when someone types !start on channel) when the bot is on OFF mode, and if someone tries to start the game, the bot should give out a message saying: The game is on OFF mode now. It will be active again on "the remaining time for it to be ON again". When the bot is on "ON mode", It'll send out a message to channel before 10 mins and 2 mins of the bot going to OFF mode telling users that the bot is going to be on "OFF mode" after 10 mins and 2 mins.

I and willy will be trying to let the bot do that with your script above. I'll get back to you if anything needed.

I thank you again for your help.

Regards,
Post Reply