| View previous topic :: View next topic |
| Author |
Message |
freelance Voice
Joined: 23 Dec 2013 Posts: 12
|
Posted: Wed Jan 15, 2014 5:43 am Post subject: simple timed advertise script with trigger |
|
|
I was looking for an advertise script where a user can set the advertise message via a trigger and also have the timer set via the same trigger. How hard would it be to write a simple program to do the following.
<op> !notify <message> <timer> (time bind to time user used trigger, not to server clock.)
Example
12:55<op> !notify Forum is running slow, admins are working on the issue. 5 minutes
1:00<bot> Forum is running slow, admins are working on the issue
1:05<bot> forum is running slow, admins are working on the issue
1:10<bot> forum is running slow, admins are working on the issue
1:11<op>!notify off
Oh and it would need to be only able to be activated by an op. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Jan 15, 2014 10:55 pm Post subject: Re: simple timed advertise script with trigger |
|
|
Experiment with this:
| Code: |
# January 15, 2014
# http://forum.egghelp.org/viewtopic.php?t=19599
#############
# Usage:
# !notify <message> <number>
# !notify off
# !notify list
##############
bind pub o "!notify" pub_advert
proc pub_advert {nick uhost handle chan text} {
global botnick
if {![llength [split $text]] } {
putserv "privmsg $chan :Syntax: !notify <message> <number> or !notify off or !notify list"
return 0
}
if {[lindex [split $text] 0] == "off" && [llength [split $text]] == 1} {
if {![llength [timers]]} {
putserv "notice $nick :Sorry $nick, no matching timers found to kill"
return 0
}
foreach t_el [timers] {
if {[lindex $t_el 1 1] == $chan && [lindex $t_el 1 0] == "do_chan_announce"} {
killtimer [lindex $t_el 2]
putserv "notice $nick :killed timer id = [lindex $t_el 2]"
}
}
return 0
}
if {[lindex [split $text] 0] == "list" && [llength [split $text]] == 1} {
if {![llength [timers]]} {
putserv "notice $nick :Sorry $nick, no running timers for notify found"
return 0
}
foreach t_el [timers] {
putserv "notice $nick :$t_el"
}
return 0
}
set timer_min [lindex [split $text] end]
if {![string is integer $timer_min]} {
putserv "privmsg $chan :Sorry $nick, \"$timer_min\" is not a valid number for timer minutes."
putserv "privmsg $chan :Syntax: !notify <message> <number>"
return 0
}
set message [lrange [split $text] 0 end-1]
timer $timer_min [list do_chan_announce $chan $timer_min $message]
putserv "notice $nick :Timer is set. $botnick will announce in $chan \"$message\" every $timer_min minutes."
}
proc do_chan_announce {chan timer_min message} {
putserv "privmsg $chan :$message"
timer $timer_min [list do_chan_announce $chan $timer_min $message]
}
## References for you:
## http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
## http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
|
As it is above, bot will only respond to the !notify command when it is from a user that has +o in the bot's user list.
If the user is a chan op or not, in the channel is not relevant.
I hope this helps.
p.s. Tested briefly. It worked, and seemed to do what you requested. I hope nothing was lost in copy-n-paste to here. |
|
| Back to top |
|
 |
freelance Voice
Joined: 23 Dec 2013 Posts: 12
|
Posted: Thu Jan 16, 2014 12:02 am Post subject: |
|
|
| I put this in just as it was written but I can't get it to trigger when I do !notify. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Jan 16, 2014 12:24 am Post subject: |
|
|
| freelance wrote: |
I put this in just as it was written but I can't get it to trigger when I do !notify. |
| willyw wrote: |
As it is above, bot will only respond to the !notify command when it is from a user that has +o in the bot's user list.
|
Do you have +o in the bot's user list?
Does the bot recognize you?
(If you don't know how to check these things, just say so and we will cover it before you try to answer) |
|
| Back to top |
|
 |
freelance Voice
Joined: 23 Dec 2013 Posts: 12
|
Posted: Thu Jan 16, 2014 12:42 am Post subject: |
|
|
bot sees me as owner and i even added the +o flag to be sure. added the flag with .chattr freelance +o... my global flags are +hjlmnoptx
I do !notify test 5 - nothing
!notify list - nothing
!notify off - nothing |
|
| Back to top |
|
 |
freelance Voice
Joined: 23 Dec 2013 Posts: 12
|
Posted: Thu Jan 16, 2014 1:25 am Post subject: |
|
|
I was having a problem with the trigger
Changed it to bind pub - !notify pub_advert and it works.
*edit
went back and changed it to
bind pub o|o !notify pub_advert and now it works from bot userfile. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Jan 16, 2014 9:43 am Post subject: |
|
|
| freelance wrote: | bot sees me as owner and i even added the +o flag to be sure.
|
As owner, you probably (should have) already had the global +o flag.
| Quote: |
added the flag with .chattr freelance +o... my global flags are +hjlmnoptx
|
When I tested, my flags were : jlmnoptxMT
(ignore the MT flags, they are for other scripts)
| Quote: |
I do !notify test 5 - nothing
!notify list - nothing
!notify off - nothing |
Not sure as to why. .... did you .rehash? ... was the script even loaded? |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Thu Jan 16, 2014 9:52 am Post subject: |
|
|
| freelance wrote: | I was having a problem with the trigger
Changed it to bind pub - !notify pub_advert and it works.
|
That would do it.
Then, the bind would trigger for anybody.
| Quote: |
*edit
went back and changed it to
bind pub o|o !notify pub_advert and now it works from bot userfile.
|
That makes it such that the bind can trigger if the user has either the +o global flag or the +o channel flag for the current channel.
Whatever it takes...
I'm glad you got it working, and I hope that it helps. |
|
| Back to top |
|
 |
|