Code: Select all
# 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
freelance wrote: I put this in just as it was written but I can't get it to trigger when I do !notify.
Do you have +o in the bot's user list?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.
As owner, you probably (should have) already had the global +o flag.freelance wrote:bot sees me as owner and i even added the +o flag to be sure.
When I tested, my flags were : jlmnoptxMTadded the flag with .chattr freelance +o... my global flags are +hjlmnoptx
Not sure as to why. .... did you .rehash? ... was the script even loaded?I do !notify test 5 - nothing
!notify list - nothing
!notify off - nothing
That would do it.freelance wrote:I was having a problem with the trigger
Changed it to bind pub - !notify pub_advert and it works.
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.*edit
went back and changed it to
bind pub o|o !notify pub_advert and now it works from bot userfile.