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.

Keyword trigger script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
c
clear
Voice
Posts: 1
Joined: Mon May 07, 2012 1:49 am

Keyword trigger script

Post by clear »

I am looking for a script that I can add keyword triggers to and when a user says one of the trigger words it will send a message to another channel the notes that I have added for said trigger word.
User avatar
Madalin
Master
Posts: 310
Joined: Fri Jun 24, 2005 11:36 am
Location: Constanta, Romania
Contact:

Post by Madalin »

I wrote my version of trigger script hope you like it.
Just tell me if it works for you.

Code: Select all

#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### ++++ TCL Name: Trigger
## ++++
# Commands:
#	!trigger activate 			(local or global owner)
#	!triger deactivate 			(local or global owner)
#	!trigger url www.chanrank.com 	(any user)
#	!triger -list 			(local or global owner)
#	!triger -del url 			(local or global owner)
#

####
# +++ This script can have the same commands saved on two different channels with different information (this means every channel has its own database)
####
# +++ Created: 1/26/2013
####

bind PUBM - * trigger:main

setudef flag trigger

proc trigger:main {nick uhost hand chan arg} {
	global trigger

	if {[string index $arg 0] in {! . `}} {

		### +++ Checking for triggers
		foreach c [channels] {
			if {[channel get $chan trigger]} {
				foreach n [array names trigger $c,*] {
					if {[string range $arg 1 end] == [lindex [split $n ","] 1]} {
						putserv "PRIVMSG $chan :$trigger($n)"
					}
				}
			}
		}

		set temp(cmd) [string range $arg 1 end]
		set temp(cmd) [lindex [split $temp(cmd)] 0]
		set arg [join [lrange [split $arg] 1 end]]
	} elseif {[isbotnick [lindex [split $arg] 0]]} {
		set temp(cmd) [lindex [split $arg] 1]
		set arg [join [lrange [split $arg] 2 end]]
	} else { return 0 }

	if {[info commands command:$temp(cmd)] != ""} { command:$temp(cmd) $nick $uhost $hand $chan $arg }
}

proc command:trigger {nick uhost hand chan arg} {
	global trigger

	switch -exact -- [lindex [split $arg] 0] {
		activate {
			if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
				channel set $chan +trigger

				putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312activated\003 succesfully"
			}
		}
		deactivate {
			if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
				channel set $chan -trigger

				putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312deactivated\003 succesfully"
			}
		}
		list -
		-list {
			if {[matchattr $hand n] || [matchattr $hand |N $chan]} {

				set l ""
				foreach a [array names trigger $chan,*] {
					lappend l "\00303[lindex [split $a ","] 1]\003"
				}

				if {$l == ""} {
					putserv "PRIVMSG $chan :\002$nick\002 - There are no trigger commands for this channel"
					return
				} else {
					putserv "PRIVMSG $chan :\002$nick\002 - Trigger command list: [join $l "\002,\002 "]"
				}
			}
		}
		del -
		-del {
			if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
				if {![info exists trigger($chan,[lindex [split $arg] 1])]} {
					putserv "PRIVMSG $chan :\002$nick\002 - There is no command \00312[lindex [split $arg] 1]\003 in my database"
				} else {
					unset -nocomplain trigger($chan,[lindex [split $arg] 1])
					trigger:save

					putserv "PRIVMSG $chan :\002$nick\002 - Command \00312[lindex [split $arg] 1]\003 erased succesfully"
				}
			}
		}
		default {
			if {[matchattr $hand n] || [matchattr $hand |N $chan]} {
				if {![info exists trigger($chan,[lindex [split $arg] 0])]} {
					set trigger($chan,[lindex [split $arg] 0]) "[join [lrange $arg 1 end]]"
					trigger:save

					putserv "PRIVMSG $chan :\002$nick\002 - You succesfully added trigger \00312[lindex [split $arg] 0]"
				} else {
					putserv "PRIVMSG $chan :\002$nick\002 - Command \00312[lindex [split $arg] 0]\003 already exists"
				}
			}
		}
	}
}

proc trigger:save {} {
	global trigger

	set ofile [open trigger w]
	puts $ofile "array set trigger [list [array get trigger]]"
	close $ofile
}

putlog "+++ Succesfully loaded: \00312Trigger TCL Script"
Post Reply