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 

Help - tcl addtrigger

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
sekai
Voice


Joined: 25 Feb 2012
Posts: 7
Location: Brazil - SP

PostPosted: Sat Feb 25, 2012 6:21 am    Post subject: Help - tcl addtrigger Reply with quote

Hi, i need help, this tcl don't works for me:

Code:
#set here the character that should beggins every trigger:
set triggerchar "!"

#####channels where the triggers will be used:####
bind pubm - "#sala $triggerchar*" triggers:pubm:trigger

#####here starts the script######

####Procedure that puts a new line in the file of triggers for the channel where the trigger was written
proc triggers:add { nick chan arg } {
   set triggerlog "triggerlog.txt"
   set file "[string trimleft $chan #]triggers.txt"
   set write [open $file a]
   if { [string range $arg 0 [expr [string first " " $arg]-1]] == "" || [lrange $arg 1 end] == "" } {
      close $write
      return 0
   }
   puts $write "[string range $arg 0 [expr [string first " " $arg]-1]]#[lrange $arg 1 end]"
   close $write
   puthelp "NOTICE $nick : A trigger [lindex $arg 0] foi adicionada com sucesso a lista de trigger do $chan."
   set tlog [open $triggerlog a]
   puts $tlog "Logger:$nick adicionou uma trigger no $chan. ($arg)"
   close $tlog
   putlog "Logger:$nick adicionou uma trigger no $chan. ($arg)"
}


####This procedure will be in charge of removing triggers for the chan where the command was written.
proc triggers:rem { nick chan trigger } {
   set triggerlog "triggerlog.txt"
   set file [string trimleft $chan #]triggers.txt
   set tempfile [string trimleft $chan #]trigger.bak
   set readfirst [open $file r]
   set linenumb 0
   set count 0
   puthelp "NOTICE $nick :Iniciando: Removendo trigger."
   while { ![eof $readfirst] } {
      gets $readfirst line
      set helpwanted [string range $line 0 [expr [string first # $line]-1]]
      if { $trigger != $helpwanted } {
         if { $linenumb==0 } {
            set writetemp [open $tempfile w]
            puts $writetemp $line
            close $writetemp
            incr linenumb
         } else {
            set writetemp [open $tempfile a]
            puts $writetemp $line
            close $writetemp
            incr linenumb
         }
      } else {
         incr count
         set tlog [open $triggerlog a]
         puts $tlog "Logger:$nick removeu uma trigger do $chan. ($helpwanted [string range $line [expr [string first # $line]+1] end])"
         close $tlog
         putlog "Logger:$nick removeu uma trigger do $chan. ($helpwanted [string range $line [expr [string first # $line]+1] end])"
         puthelp "NOTICE $nick :($count):!addtrigger $helpwanted [string range $line [expr [string first # $line]+1] end]"
      }
   }
   close $readfirst
   set readfirst2 [open $tempfile r]
   set linenumb2 0
   while { ![eof $readfirst2] } {
      gets $readfirst2 line
      if { [string first # $line] != -1 } {
         if { $linenumb2==0 } {
            set writetemp [open $file w]
            puts $writetemp $line
            close $writetemp
            incr linenumb2
         } else {
            set writetemp [open $file a]
            puts $writetemp $line
            close $writetemp
         }
      }
   }
   if { $linenumb2==0 } {
      set writetemp [open $file w]
      close $writetemp
   }   
   close $readfirst2
   puthelp "NOTICE $nick :Fim: Trigger removida."
}



####Procedure that will get all the triggers from the file and present them to the user who asked for the list of possible commands for the chan.
proc triggers:list { nick chan } {
   set read [open [string trimleft $chan #]triggers.txt r]
   set text ""
   while { ![eof $read] } {
      gets $read line
      set text "$text [lindex [split $line #] 0]"
   }
   close $read
   set finish [string range $text 1 [expr [string length $text]-2]]
   set long [split $finish]
   if { [llength $long] > 30 } {
      for { set c 0} { $c<[llength $long] } { incr c 30 } {
         if { $c==0 } {
            puthelp "NOTICE $nick : Triggers: 4[lrange $long $c [expr $c+29]]"
         } else {
            puthelp "NOTICE $nick : 4[lrange $long $c [expr $c+29]]"
         }
      }
   } else {
      puthelp "NOTICE $nick :Triggers: 4$finish"
   }
}

####Procedure that shows in the chan the text or the action associated with the trigger written in the channel
proc triggers:pubm:trigger { nick uhost handle chan arg } {
   global globalProtect nickProtect triggerchar
   set way ""
   set notice 0
   set ok 0
   set trigger "[string tolower [string range [lindex $arg 0] 1 end]]"
   if { [isop $nick $chan] || [ishalfop $nick $chan] } {
      if { $trigger=="listtrigger" } {
         [triggers:list $nick $chan]
         return 0
      } elseif { $trigger=="addtrigger" } {
         [triggers:add $nick $chan [join [lrange [split $arg] 1 end]]]
         return 0
      } elseif { $trigger=="remtrigger" } {
         [triggers:rem $nick $chan [join [lrange [split $arg] 1 end]]]
         return 0
      }
   } elseif { [isvoice $nick $chan] } {
      #Voices avoid protection.
   } else {
      if { [info exists nickProtect($uhost)] == 1 } {
         putlog "Nick Trigger flood($uhost,$nickProtect($uhost))"
         if { $nickProtect($uhost) == 2 } {
            return 0
         }
         incr nickProtect($uhost)
      } else {
         set nickProtect($uhost) 1
         utimer 5 "unset nickProtect($uhost)"
      }
      if { [info exists globalProtect] == 1 } {
         if { $globalProtect == 4 } {
            putlog "Global Trigger flood($uhost,$globalProtect)"
            return 0
         }
         incr globalProtect
      } else {
         set globalProtect 1
         utimer 10 "unset globalProtect"
      }
   }
   #ways the resulting help text should be sent
   if { [llength $arg] < 2 } {
      if { [isop $nick $chan] || [ishalfop $nick $chan] ||[isvoice $nick $chan] } {
         set way "PRIVMSG $chan :\001ACTION"
         set notice 0
      } else {
         set way "NOTICE $nick :$nick:"
         set notice 1
      }
   } else {
      if { [onchan [lindex $arg 1] $chan] && ( [isop $nick $chan] || [ishalfop $nick $chan] || [isvoice $nick $chan] ) } {
         if { [lindex $arg 2]=="c" } {
            set way "PRIVMSG $chan :\001ACTION [lindex $arg 1]"
            set notice 3
         } elseif { [lindex $arg 2]=="p" } {
            set way "PRIVMSG [lindex $arg 1] :"
            set notice 2
         } else {
            set way "NOTICE [lindex $arg 1] :$nick:"
            set notice 1
         }
      } else {
         return 0
      }
   }
   #now it searches the txt file for the trigger  wrotten in the channel and if it finds something associated with that trigger,
   #it sends it back to the server in the way it was define above.
   if { $way!="" && [file exists [string trimleft $chan #]triggers.txt] } {
      set read [open [string trimleft $chan #]triggers.txt r]
      while  { ![eof $read] } {
         gets $read line
         set helpwanted [string range $line 0 [expr [string first # $line]-1]]
         if { [string tolower [lindex $helpwanted 0]]==[string tolower [string trimleft [lindex $arg 0] $triggerchar]] } {
            set ok 1
            puthelp "$way [string range $line [expr [string first # $line]+1] end]"
         }
      }
      set final [not $notice $ok $nick $arg]
      close $read
   }
}

proc not { notice ok nick arg } {
   if { $notice==1 && $ok==1 } {
      puthelp "NOTICE $nick : :) [lindex $arg 1]"
   } elseif { $notice==2 && $ok==1 } {
      puthelp "NOTICE $nick : :) [lindex $arg 0] [lindex $arg 1]"
   }
}

putlog "Triggers.tcl script loaded."


I need that tcl in my help chan.

Thks for help! :D
Back to top
View user's profile Send private message MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sat Feb 25, 2012 9:52 am    Post subject: Reply with quote

Could you describe the issue or error you get? Or maybe what's not working at all or properly?
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
sekai
Voice


Joined: 25 Feb 2012
Posts: 7
Location: Brazil - SP

PostPosted: Sat Feb 25, 2012 11:09 am    Post subject: Reply with quote

caesar wrote:
Could you describe the issue or error you get? Or maybe what's not working at all or properly?


Not work, i type "!addtrigger teste messenger" and.... nothing Sad
Back to top
View user's profile Send private message MSN Messenger
sekai
Voice


Joined: 25 Feb 2012
Posts: 7
Location: Brazil - SP

PostPosted: Tue Feb 28, 2012 9:49 am    Post subject: Reply with quote

If not how to fix, would use another command that works like this?
Back to top
View user's profile Send private message MSN Messenger
Madalin
Master


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

PostPosted: Sat Feb 02, 2013 7:01 am    Post subject: Reply with quote

You can try this script http://forum.egghelp.org/viewtopic.php?t=19313
It does what you want and more
_________________
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
sekai
Voice


Joined: 25 Feb 2012
Posts: 7
Location: Brazil - SP

PostPosted: Fri Feb 15, 2013 10:51 am    Post subject: Reply with quote

Thank you for reply, i will test now Cool
Back to top
View user's profile Send private message MSN Messenger
sekai
Voice


Joined: 25 Feb 2012
Posts: 7
Location: Brazil - SP

PostPosted: Thu Jul 31, 2014 9:24 pm    Post subject: is ok now! Reply with quote

Hi!

2 years ago i make this topic requesting help, today, i found the "error" in this tcl lol .

the error is in 5º line:

Quote:
bind pubm - "#sala $triggerchar*" triggers:pubm:trigger


remove this * :

Quote:
bind pubm - "#sala $triggerchar" triggers:pubm:trigger


save the tcl and rehash your bot.

Now, type:

!addtrigger command text here

and your bot will create and add the trigger "command" in "channel.txt" .

after type:

!comand

and your bot will send the text in your channel Very Happy .

I do not know who created this tcl, but thank you for sharing with us all.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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