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.

simple timed advertise script with trigger

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
f
freelance
Voice
Posts: 12
Joined: Mon Dec 23, 2013 10:45 am

simple timed advertise script with trigger

Post by freelance »

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

Re: simple timed advertise script with trigger

Post by willyw »

Experiment with this:

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
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.
f
freelance
Voice
Posts: 12
Joined: Mon Dec 23, 2013 10:45 am

Post by freelance »

I put this in just as it was written but I can't get it to trigger when I do !notify.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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)
f
freelance
Voice
Posts: 12
Joined: Mon Dec 23, 2013 10:45 am

Post by freelance »

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
f
freelance
Voice
Posts: 12
Joined: Mon Dec 23, 2013 10:45 am

Post by freelance »

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

Post by willyw »

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.
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)
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?
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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.
*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.
Post Reply