Trigger Script

By Vox91 on May 19, 2008

read inside the script itself :)

update to RC 2!

; ---------------------------------------------------------------------------------------------------------------
; General Info
; ---------------------------------------------------------------------------------------------------------------
;
; Addon Name: Trigger Script
; Created by: Patrick Rennings (Vox)
; Copyright: Memory Services
; Version: RC 2
;
; ---------------------------------------------------------------------------------------------------------------
; Contact Info
; ---------------------------------------------------------------------------------------------------------------
; 
; Contact info:
; irc: www.ogamenet.net - #AllNiteCafe // #vox (port 6667)
; /server -m www.ogamenet.net -j #AllNiteCafe
; email: vox@noxxie.nl 
;
; ---------------------------------------------------------------------------------------------------------------
; Script info
; ---------------------------------------------------------------------------------------------------------------
;
; This scripts take cares of any trigger you added. If you want that the bot reacts on the text "!vox" and that 
; the output will be "Is the creator of the bot." You just add it with the add trigger command. (See the next
; section for triggers info.) And the bot will trigger the text then when "!vox" is typed.
;
; Note: Any other command added within the same file will not be triggerd because of the usage "ON *:TEXT:*:#: {"
; this says that any text specified in the channel will activate the script.
;
; Note: Bug foud? Please report them, doenst matter how you report them (see Contact info how to contact) but 
; report them so it canbe fixxed in the next version.
;
; ---------------------------------------------------------------------------------------------------------------
; Availible Commands
; ---------------------------------------------------------------------------------------------------------------
; 
; !add <trigger> <text> :: This will add an trigger to the bot.
; !del <trigger> :: Allows you to remove a trigger that was set with the "add" command.
; !list [-ls] :: Allows you to view the triggers that are setted.
;
; if the -l is specified The whole list will be showen with the text that will be showen with the trigger. When
; the -s trigger is specified you can search trough the triggers. An parameter must be set. (!list -s [text])
;
; NOTE: All these commands command character the (!) can ben changed within this script (The alias section and
; then the alias "cmdchar". Here you can set everything you want (an 1 character cmdchar is recommand)
;
; :: Extra ::
; You can still keep this script only but put it "offline" in the alias section you will see an alias with the
; name "addon.status" when this setted to "off" the script will be "offline". When turned "on" the script can be
; used.
;
; ---------------------------------------------------------------------------------------------------------------
; Extra Parameters
; ---------------------------------------------------------------------------------------------------------------
;
; With the !add trigger script. You can use some extra parameters to be shown when the trigger will activate. 
; These are:
;
; <b> = Will show the text next in bold (An second <b> will remove the bold)
; <u> = Will show the text next with an underlinde (An second <u> will remove the underline)
; <nick> = This parameter will be replaced with the nick that activated the script.
; <host> = An parameter to replace this text with the hostmask of the users that is been specified.
; <chan> = This paramater will show the channel where the trigger is activated.
;
; ---------------------------------------------------------------------------------------------------------------
; Aliases
; ---------------------------------------------------------------------------------------------------------------

alias aversion { return RC 2 }
alias cmdchar { return ! }
alias trig.storage { 
  if (!$isdir(Storage)) {
    mkdir Storage
  }
  return Storage\trigger.hsh
}
alias addon.status { return on }

; ---------------------------------------------------------------------------------------------------------------
; on :XXX: events
; ---------------------------------------------------------------------------------------------------------------

on *:LOAD: {
  set %emailaddy $?="Wich email should they contact in case of script failure?"
  if (!$exists($trig.storage)) {

    if (!$hget(trigger.addon)) {
      hmake trigger.addon 1000
    }
    hload trigger.addon $trig.storage
  }
  else {
    hfree trigger.addon
    hmake trigger.addon 1000

    if (!$isfile($$mircdirStorage\trigger.hsh) { hsave trigger.addon $trig.storage }
    hload trigger.addon $trig.storage
  }
}

on *:START: {
  if (!$exists($trig.storage)) {
    if (!$hget(trigger.addon)) {
      hmake trigger.addon 1000
    }
    hload trigger.addon $trig.storage
  }
  else {
    hfree trigger.chan

    if (!$isfile($$mircdirStorage\trigger.hsh) { hsave trigger.addon $trig.storage }
    hmake trigger.addon 1000
    hload trigger.addon $trig.storage
  }
}

on *:UNLOAD: {
  if ($exists($trig.storage)) {
    var %remove $input(Do you want to remove the storage file?,yn)
    if (%remove == %true) { .remove -b $trig.storage }

    if ($hget(trigger.addon)) {
      hfree trigger.addon
      var %unload $input(Script has been unloaded.,o)
    }
  }
}

; ---------------------------------------------------------------------------------------------------------------
; The Trigger script
; ---------------------------------------------------------------------------------------------------------------

on *:TEXT:*:#: {
  if ($addon.status != on) && ($addon.status != off) { .msg $chan invalid configurations. | halt }
  elseif ($addon.status == off) { halt }

  elseif ($hget(trigger.addon, $remove($1, $chr(33))) != $null) { 
    if ($left($1,1) == $cmdchar) {
      .msg $chan ( $+ $remove($1, $chr(33)) $+ ) $replace($hget(trigger.addon, $remove($1, $chr(33))), <nick>, $nick, <chan>, $chan, <host>, $address($nick,2), <b>, , <u>, )
      halt 
    }
  }
  elseif ($1 == $cmdchar $+ add) { 
    if ($nick !isop $chan) { .notice $nick not enough access. | halt }
    elseif (!$3) { .notice $nick More parameters needed. | halt }
    elseif ($2 == $cmdchar $+ add) || ($2 == $cmdchar $+ del) || ($2 == $cmdchar $+ list) { .notice $nick Primary triggers cant be setted. | halt }
    elseif ($2 == $cmdchar $+ credits) { .notice $nick Primary triggers cant be setted. | halt }
    elseif ($hget(trigger.addon, $2) != $null) { .notice $nick Trigger already taken. | halt }

    hadd -m trigger.addon $2 $3-
    hsave trigger.addon $trig.storage

    .msg $chan A new Trigger was added by $nick (Trigger: $2 $+ , Text: $3-)
  }
  elseif ($1 == $cmdchar $+ del) {
    if ($nick !isop $chan) { .notice $nick not enough access. | halt }
    elseif (!$2) { .notice $nick More parameters needed. | halt }
    elseif (!$hget(trigger.addon, $2)) { .notice $nick This trigger doenst exist. | halt }

    hdel trigger.addon $2
    hsave trigger.addon $trig.storage

    .msg $chan The trigger $2 has been removed.
  }
  elseif ($1 == $cmdchar $+ list) {
    if (!$2) { 
      var %total $hget(trigger.addon, 0).item, %count = 0, %lists
      while (%count < %total) {
        inc %count
        %lists = $addtok(%lists, $hget(trigger.addon, %count).item $chr(45) , 32)
      }
      .notice $nick $iif(%lists == $null, No triggers found, $v1)
    }
    if ($2 == -l) {
      var %total $hget(trigger.addon, 0).item, %count = 0, %lists
      while (%count < %total) {
        inc %count
        .notice $nick  $+ $hget(trigger.addon, %count).item $+ : $hget(trigger.addon, $hget(trigger.addon, %count).item)
      }
      .notice $nick $iif(%total == 0, No triggers found, End of triggerlist.)
    }
    if ($2 == -s) {
      if (!$3) { .notice $nick more parameters needed. | halt }
      var %total $hget(trigger.addon, 0).item, %count = 0, %lists
      while (%count < %total) {
        inc %count
        if (* $+ $3 $+ * iswm $hget(trigger.addon, %count).item) {
          .notice $nick  $+ $hget(trigger.addon, %count).item $+ : $hget(trigger.addon, $hget(trigger.addon, %count).item)
        }
      }
      .notice $nick $iif(%total == 0, No triggers found, End of triggerlist.)
    }
  }
  if ($1 == $cmdchar $+ credits) {  .msg $chan 0,1-=[Trigger Addon :: Version: $aversion © by Patrick Rennings (Vox) :: www.ogamenet.net / #allnitecafe $&
    For any errors please report them to: %emailaddy $+ ]=- }
  else { $null }
}

Comments

Sign in to comment.
sumedh   -  Apr 20, 2015

can anyone fix this script pls?

 Respond  
jackster35-1   -  Jan 26, 2010

dont get it, its not working because when i type !test it dont say test :S

 Respond  
GrimReaper   -  Aug 01, 2009

I have been using the code. although... Everytime I quit my mIRC and my Bot's mIRC it doesn't save the Trigger's in the .hsh file. i have to save them to a seperate .txt file and then load them back into the .hsh file. Although to me it's micely presented. 8/10

Edited Comment,

I have had a look through the snippet. and notice'd there's no on *:EXIT: part to save it

you'll need to add

on *:EXIT:hsave trigger.addon $trig.storage

somewhere within your script.

i think lol

 Respond  
palawanisland   -  May 09, 2009

Error!
/hfree: no such table 'trigger.chan' (line 111, script1.ini)

 Respond  
Vox91   -  Mar 25, 2009

Usage of if (* iswm $cmdchar) { }

 Respond  
bhasonson   -  Jan 27, 2009

:O HOW? I tried modifying the script for quite a long time now...

 Respond  
Vox91   -  Jan 26, 2009

it is possible with a few modifications

 Respond  
bhasonson   -  Jan 25, 2009

Is it possible to make it so you can have multiline trigger?

 Respond  
Bullet_Dodger   -  Nov 10, 2008

Lolwut

 Respond  
iBook   -  Nov 06, 2008

I would almost recommend some working change on the !list command, just because some smaller networks put it in their spam filter in case of "P2P Filesharing," I just changed mine to !cmdlist and it worked!

 Respond  
Bullet_Dodger   -  Oct 18, 2008

Nice Job Typing Out That Bullshit at the start

 Respond  
Vox91   -  Aug 04, 2008

has een updated! :)

 Respond  
jthermane24   -  Jun 07, 2008

Hey I like the script and I really want to use this but I keep getting an error message /hadd: no such table \'trigger.addon\' (line 141, add.mrc) I have looked at the script and I can not figure out the reason. If anyone could help that would be great.

 Respond  
iBook   -  Jun 07, 2008

it gives me the error message \"/hadd: no such table \'trigger.addon\' (line 77, script1)\"

 Respond  
SnoooP   -  May 19, 2008

lol big into man :D hehe... nice code though

 Respond  
Vox91   -  May 19, 2008

it needs explanation otherwise questions will popup ^^

 Respond  
criminal   -  May 19, 2008

There\'s like 50% intro but the rest is okai

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.