| View previous topic :: View next topic |
| Author |
Message |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Mon Jan 28, 2013 6:09 pm Post subject: Create Trigger Script |
|
|
For any ideas for improving the code
For any bugs or questions please post here
| Code: |
#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### +++ Website: www.Ascenture.ro
## +++ TCL Name: Trigger
# +++ Version: 2.0
## ++++
# Commands:
# !trigger activate (local or global owner)
# !trigger deactivate (local or global owner)
# !trigger url www.ascenture.ro (any user)
# !trigger -list (local or global owner)
# !trigger -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: 5/19/2013
####
bind PUBM - * trigger:main
## ++ Set here what triggers you want the script to work with
set ascenture(trigger) {! . ` ?}
## ++ Set here the flag (local) for the activate/deactivate script (n = owner/m = master/o = operator)
set ascenture(flag-ad) "n"
## ++ Set here the flag (local) to use add/delete/list commands (n = owner/m = master/o = operator)
set ascenture(flag-adl) "n"
## ++ Set here the flag (local) to use the command like '!cmd NICKNAME' (n = owner/m = master/o = operator)
set ascenture(flag-cm) "n"
setudef flag trigger
proc trigger:main {nick uhost hand chan arg} {
global trigger ascenture
if {[string index $arg 0] in $ascenture(trigger)} {
### +++ Checking for triggers
if {[channel get $chan trigger]} {
foreach n [array names trigger $chan,*] {
set newvar [string map [list [string index $arg 0] ""] [lindex [split $arg] 0]]
if {[string match -nocase $newvar [lindex [split $n ","] 1]]} {
if {[llength [lindex [split $arg] 1]] && [matchattr $hand $ascenture(flag-cm)] || [matchattr $hand |$ascenture(flag-cm) $chan]} {
foreach n [split $trigger($n) "|"] { if {[llength $n]} { putserv "PRIVMSG $chan :[lindex [split $arg] 1]: \002$newvar\002 - $n" } }
} else {
set nr 0
foreach n [split $trigger($n) "|"] {
if {[llength $n]} {
incr nr
if {$nr == 1} {
putserv "PRIVMSG $chan :$nick: \002$newvar\002 - $n"
} else {
putserv "PRIVMSG $chan :$nick: $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 triggercmd:$temp(cmd)] != ""} { triggercmd:$temp(cmd) $nick $uhost $hand $chan $arg }
}
proc triggercmd:trigger {nick uhost hand chan arg} {
global trigger ascenture
switch -exact -- [lindex [split $arg] 0] {
activate {
if {[matchattr $hand $ascenture(flag-ad)] || [matchattr $hand |$ascenture(flag-ad) $chan]} {
channel set $chan +trigger
putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312activated\003 succesfully"
}
}
deactivate {
if {[matchattr $hand $ascenture(flag-ad)] || [matchattr $hand |$ascenture(flag-ad) $chan]} {
channel set $chan -trigger
putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312deactivated\003 succesfully"
}
}
list -
-list {
if {[matchattr $hand $ascenture(flag-adl)] || [matchattr $hand |$ascenture(flag-adl) $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 $ascenture(flag-adl)] || [matchattr $hand |$ascenture(flag-adl) $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 $ascenture(flag-adl)] || [matchattr $hand |$ascenture(flag-adl) $chan]} {
if {[lindex [split $arg] 1] == ""} { putserv "PRIVMSG $chan :\002$nick\002 - You did not provide ARGS for \00304[lindex [split $arg] 0]\003 command"; return }
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
}
catch {source trigger}
putlog "+++ Succesfully loaded: \00312Trigger TCL Script"
|
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Last edited by Madalin on Sat Aug 03, 2013 4:28 am; edited 1 time in total |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Mon May 20, 2013 6:05 am Post subject: |
|
|
Version 2.0 now you can define the access level for every command
It now can support lines for the command _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
sekai Voice
Joined: 25 Feb 2012 Posts: 7 Location: Brazil - SP
|
Posted: Fri Aug 02, 2013 10:21 pm Post subject: |
|
|
error for me.
!trigger active
| Quote: | | Tcl error [trigger:main]: syntax error in expression "[string index $arg 0] in $ascenture(trigger)": extra tokens at end of expression |
 |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Sat Aug 03, 2013 4:29 am Post subject: |
|
|
I modifyed some things and i tested every command and it worked. Ive tested the script on 2 systems one with FREEBSD one with CENTOS both with tcl version 8.5.9 and eggdrop v1.6.20
If you still encounter problems with the script please provide informations about the system/tcl/eggdrop version _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
sekai Voice
Joined: 25 Feb 2012 Posts: 7 Location: Brazil - SP
|
Posted: Wed Aug 07, 2013 4:46 pm Post subject: |
|
|
Thanks for reply, my error is my eggdrop, using eggdrop1.8 the tcl work fine, thank you Madalin . |
|
| Back to top |
|
 |
user18765 Voice
Joined: 15 Apr 2012 Posts: 9
|
Posted: Tue Dec 17, 2013 11:48 pm Post subject: Improvement |
|
|
Hi, I tried your TCL and I think it is very nice! I wanted to leave my feedback, and also push for a little improvement of its features!
There's just one feature I consider missing (I do some examples, too):
1) Management of new variables (e.g. $sender and $user)
!trigger irctutorial $user, this is a simple irc tutorial for newbies http://etc.
| Code: |
<normaluser> Hey! Can you tell me how to use IRC?
<owner> !irctutorial | normaluser
<bot> normaluser, this is a simple irc tutorial for newbies http://etc.
|
!trigger irctutorial $user, $sender told me to give you this: http://etc.
| Code: |
<normaluser> Hey! Can you tell me how to use IRC?
<owner> !irctutorial | normaluser
<bot> normaluser, owner told me to give you this: http://etc
|
| Quote: | | I would try to manage even 3rd party users, not only sender and addressee |
2) I would enable multiple input (and output) modes, to make everything more human
!trigger irctutorial Hi! $user, I think that this one could be good for you: http://etc.
| Code: |
<normaluser> Hello! Can you tell me how to use IRC?
<owner> Hey bot, give normaluser a good !irctutorial
<bot> Hi! normaluser, I think that this one could be good for you: http://etc
|
Commands must be more flexible , and not require boring fixed patterns.
Also, the owner could give a list of possible answers from which the bot can randomly choose. And for "input modes", I would employ a "keywords" technique. Keywords such as GIVE. Without any special symbol like ! . , at the beginning. Just language.
That's (almost eheh) all. I reserve the other ones for the next release XD
Bye.
Anonymous |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Wed Dec 18, 2013 6:41 am Post subject: |
|
|
Thanks for your ideas
The problem was that noone complained about the script atleast about the commands and what things needed improved. The idea was that if i knew exactly what the script would need i would have made it exactly like that but i didnt. This is exactly the script i used it a long time ago and decided to make it public and share it with others and since then noone said we need this we need that so trust me as soon as i will this script will be used i will improve its code/command to be more flexible and easy to use
Ideas noted and in the next version i will consider what you suggested of course  _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
user18765 Voice
Joined: 15 Apr 2012 Posts: 9
|
Posted: Sat Dec 21, 2013 7:28 pm Post subject: |
|
|
I'm having a problem with your script.
Eggdrop version ===> 1.6.21
Tcl Version ===> 8.5.13
I (the owner of the bot) don't have any problem. BUT other users do.
I wanted some users to be able to add/del triggers. So I changed the flags at the beginning of your script setting them all as "o" (operators). I then added those users to the operators group (from the party channel) with the command .adduser username operator
The user-adding process went fine, successfully. I then restarted the bot, but still the users weren't able to use any feature.
What do you think?
(bmn user) Thank you, bye  |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Sun Dec 22, 2013 6:22 am Post subject: |
|
|
Check the users if they really have that flag (local/global) and see in botnet chat if you have any error. Copy paste the script on http://paste.tclhelp.net if you know you have edited other things maybe you have an error or something (that website will tell you) _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
anotheregglover Voice
Joined: 13 Jan 2005 Posts: 38
|
Posted: Mon Dec 30, 2013 5:38 pm Post subject: |
|
|
thx for this script.
i am encountering a problem. i think everytime i restart or rehash the bot the added trigger commands are lost.
where does the script save the added trigger cmds?
Btw. egghelp.org archive still refers to version 1.0 |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Mon Dec 30, 2013 7:38 pm Post subject: |
|
|
Well yes ive send the new version to be uploaded instead of the old version but that didnt happened so i posted the script here. Use this version here on the forum and see if the problem still persists. I know there is no problem with this version _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
Jagg Halfop
Joined: 24 Jan 2004 Posts: 53
|
Posted: Mon Jan 20, 2014 7:21 pm Post subject: |
|
|
| ...are there " allowed as/in descriptions?! When I use " in desr the trigger isn't saved here. |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Tue Jan 21, 2014 5:54 am Post subject: |
|
|
Give me the exact usage you are using _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
Jagg Halfop
Joined: 24 Jan 2004 Posts: 53
|
Posted: Wed Jan 22, 2014 5:50 am Post subject: |
|
|
Hmmm, can't reproduce it again. Now everything looks good, even
| Code: | | !trigger that's: ("a test"), another test (-!user blubb 12-2): https://www.etestasfsdf.com next: test |
worked.
Sorry
...and thanks for this script! |
|
| Back to top |
|
 |
user18765 Voice
Joined: 15 Apr 2012 Posts: 9
|
Posted: Wed Jan 22, 2014 11:26 pm Post subject: Madalin trigger.tcl script Modified |
|
|
Hi. I modified Madalin's trigger script with a couple of minor changes.
He didn't think of the feature !cmd NICKNAME used by everybody, even users which aren't known by the bot. But I needed that feature. And I did the same for the !trigger -list command. I simply distinguished the ADD/DEL needed flag with the LIST needed flag. And, for these two, added the value "-" that means "All Users". Here's the source:
| Code: |
#### ++++ Author: MadaliN <madalinmen28@yahoo.com>
### +++ Website: www.Ascenture.ro
## +++ TCL Name: Trigger
# +++ Version: 2.0.1
## ++++
# Commands:
# !trigger activate (local or global owner)
# !trigger deactivate (local or global owner)
# !trigger url www.ascenture.ro (any user)
# !trigger -list (local or global owner)
# !trigger -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: 5/19/2013
####
bind PUBM - * trigger:main
## ++ Set here what triggers you want the script to work with
set ascenture(trigger) {! . ` ?}
## ++ Set here the flag (local) for the enable/disable the script (n = owner/m = master/o = operator)
set ascenture(flag-ed) "n"
## ++ Set here the flag (local) to use add/delete commands (n = owner/m = master/o = operator)
set ascenture(flag-ad) "n"
## ++ Set here the flag (local) to use list command (n = owner/m = master/o = operator/ "-" = everybody)
set ascenture(flag-l) "o"
## ++ Set here the flag (local) to use the command like '!cmd NICKNAME' (n = owner/m = master/o = operator/ "-" = everybody)
set ascenture(flag-cm) "-"
setudef flag trigger
proc trigger:main {nick uhost hand chan arg} {
global trigger ascenture
if {[string index $arg 0] in $ascenture(trigger)} {
### +++ Checking for triggers
if {[channel get $chan trigger]} {
foreach n [array names trigger $chan,*] {
set newvar [string map [list [string index $arg 0] ""] [lindex [split $arg] 0]]
if {[string match -nocase $newvar [lindex [split $n ","] 1]]} {
if {[llength [lindex [split $arg] 1]] && [matchattr $hand $ascenture(flag-cm)] || [matchattr $hand |$ascenture(flag-cm) $chan] || $ascenture(flag-cm) eq "-"} {
foreach n [split $trigger($n) "|"] { if {[llength $n]} { putserv "PRIVMSG $chan :[lindex [split $arg] 1]: \002$newvar\002 - $n" } }
} else {
set nr 0
foreach n [split $trigger($n) "|"] {
if {[llength $n]} {
incr nr
if {$nr == 1} {
putserv "PRIVMSG $chan :$nick: \002$newvar\002 - $n"
} else {
putserv "PRIVMSG $chan :$nick: $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 triggercmd:$temp(cmd)] != ""} { triggercmd:$temp(cmd) $nick $uhost $hand $chan $arg }
}
proc triggercmd:trigger {nick uhost hand chan arg} {
global trigger ascenture
switch -exact -- [lindex [split $arg] 0] {
activate {
if {[matchattr $hand $ascenture(flag-ed)] || [matchattr $hand |$ascenture(flag-ed) $chan]} {
channel set $chan +trigger
putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312activated\003 succesfully"
}
}
deactivate {
if {[matchattr $hand $ascenture(flag-ed)] || [matchattr $hand |$ascenture(flag-ed) $chan]} {
channel set $chan -trigger
putserv "PRIVMSG $chan :\002$nick\002 - TRIGGER script \00312deactivated\003 succesfully"
}
}
list -
-list {
if {[matchattr $hand $ascenture(flag-ad)] || [matchattr $hand |$ascenture(flag-ad) $chan] || $ascenture(flag-l) eq "-"} {
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 $ascenture(flag-ad)] || [matchattr $hand |$ascenture(flag-ad) $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 $ascenture(flag-ad)] || [matchattr $hand |$ascenture(flag-ad) $chan]} {
if {[lindex [split $arg] 1] == ""} { putserv "PRIVMSG $chan :\002$nick\002 - You did not provide ARGS for \00304[lindex [split $arg] 0]\003 command"; return }
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
}
catch {source trigger}
putlog "+++ Succesfully loaded: \00312Trigger TCL Script"
|
|
|
| Back to top |
|
 |
|