egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Keyword trigger script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
clear
Voice


Joined: 07 May 2012
Posts: 1

PostPosted: Mon May 07, 2012 1:54 am    Post subject: Keyword trigger script Reply with quote

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.
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Sat Jan 26, 2013 6:11 pm    Post subject: Reply with quote

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

Code:

#### ++++ 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"

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber