Code: Select all
set chanrules {
"rules line 1"
"rules line 2"
}
bind pub - !rules <nick>
proc pub:t {nick uhost hand chan text} {
global chanrules
set rulenick [lindex [split $text " "] 0]
if {$text != "" && [onchan $rulenick $chan]} {
puthelp "NOTICE $rulenick :these are the rules of our channel. Pay attention!"
foreach line $chanrules { puthelp "NOTICE $rulenick :$line" }
return 0
}
foreach line $chanrules {puthelp "PRIVMSG $nick :$line" }
}
Code: Select all
namespace eval say { variable say
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
bind pub -|- !rules [namespace current]::rules
bind pub -|- !help [namespace current]::help
bind pub -|- !admin [namespace current]::admin
proc rules {nick uhost hand chan text} {
variable say
foreach line $say(rules) {
puthelp "NOTICE $nick :$line"
}
}
proc help {nick uhost hand chan text} {
variable say
foreach line $say(help) {
puthelp "NOTICE $nick :$line"
}
}
proc admin {nick uhost hand chan text} {
variable say
foreach line $say(admin) {
puthelp "NOTICE $nick :$line"
}
}
}
putlog "SayHelp ver 0.1 Loaded."
Code: Select all
namespace eval say { variable say ; array unset say "*"
################ Begin Settings ################
variable cmdchar "!" ;# Every command starts with this One Character #
## Add as many commands as you want:) ##
## - name each one uniquely, the name is also the trigger ##
## - add as many reply lines as you want to each command ##
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
variable dotarget 1 ;# 1 = target nick enabled # 0 = disabled #
################ End of Settings (Don't edit below) ################
foreach sayname [array names say] {
bind pubm - "?%~\\${cmdchar}${sayname}*" [namespace current]::sayit
}
proc sayit {nk uh hn ch tx} { variable cmdchar ; variable say
lassign [split $tx] cmd target ; variable dotarget
if {[string index $cmd 0] ne $cmdchar} { return 0 }
set match [lsearch -nocase -inline [array names say] [string range $cmd 1 end]]
if {$match eq ""} { return 0 }
if {$dotarget eq "0" || $target eq "" || ![onchan $target $ch]} {
set target $nk
}
foreach line $say($match) { puthelp "NOTICE $target :$line" }
return 0
}
}
putlog "SayHelp ver 1.01 Loaded."
Code: Select all
namespace eval say {
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
# don't edit past this line
foreach ele [binds [namespace current]::*] {
if {[scan $ele {%s%s%s%d%s} type flags cmd hits func] != 5} continue
unbind $type $flags $cmd $func
}
foreach name [array names say] {
bind pub - !${name} [namespace current]::say
}
proc say {nick uhost hand chan text} {
variable say
if {[scan $text {%s} who] != 1} {
set who $nick
}
if {![onchan $chan $who]} return
set cmd [string tolower [lindex [split $::lastbind !] 1]]
if {[lsearch [array names say] $cmd] > -1} {
foreach line $say($cmd) {
puthelp "NOTICE $who :$line"
}
}
}
}
Code: Select all
set say(something) {
"line 1"
"line 2"
"line 3"
}
I didn't want to try it, since the other one you provided worked perfectly. After weeks of hair-pulling insanity, I'm not changing a thing until I become much more fluent in tcl!SpiKe^^ wrote:I could sure use someone to test this script and report back here please:)
Code: Select all
######################################
## SayHelp ver 1.02 02Dec2018 ##
######################################
namespace eval say { variable say ; variable how ; variable who
array unset say "*" ; array unset how "*" ; array unset who "*"
################ Begin Script Settings ################
variable cmdchar "!" ;# All commands start with this One Character #
## Add as many commands as you want:) ##
## - name each one uniquely, the name is also the trigger ##
## - add as many reply lines as you want to each command ##
## The default reply method is PrivateNotice (send by notice to nick). ##
## There is an optional per-trigger setting available to change that Method. ##
## - add the following line to any command we Don't want send PrivateNotice. ##
## set how(<CommandName>) "<ReplyMethod>" ##
## - 3 valid reply methods: msg =PrivMsg || pub =PubNotc || pubmsg =PubMsg ##
## ex. set how(help) "msg" =send the !help reply by PrivateMessage. ##
## The default commands permissions are: Reply to Everyone on All triggers. ##
## There is an optional per-trigger setting available to limit cmd access. ##
## - add the following line to any command we Don't want Reply to Everyone. ##
## set who(<CommandName>) "<Flags/Modes>" ##
## - Flags can be any valid Eggdrop userfile flags. ##
## ex. set who(admin) "o|o" =check userfile for global or chan o flag. ##
## - Modes can be any of these: +o and/or: +v and/or: +h ##
## ex. set who(admin) "+o" =check for user has +o in the channel. ##
## Advanced example: set who(admin) "ov|ov +o +v" :Flags 1st, space sep. ##
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set how(rules) "msg"
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
set how(admin) "msg"
set who(admin) "+o"
variable dotarget 1 ;# 1 = target nick enabled # 0 = disabled #
################ End of Settings (Don't edit below) ################
foreach aname [array names say] {
bind pubm - "?%~\\${cmdchar}${aname}*" [namespace current]::sayit
if {[info exists how($aname)] && ![regexp -- {^(pubmsg|msg|pub)$} $how($aname)]} {
unset how($aname)
}
if {[info exists who($aname)]} {
set who($aname) [split [string trim $who($aname)]]
if {[string index [lindex $who($aname) 0] 0] eq "+"} {
set who($aname) [linsert $who($aname) 0 ""]
}
}
}
proc sayit {nk uh hn ch tx} { variable cmdchar ; variable say
lassign [split $tx] cmd target
if {[string index $cmd 0] ne $cmdchar} { return 0 }
set m [lsearch -nocase -inline [array names say] [string range $cmd 1 end]]
if {$m eq ""} { return 0 }
variable dotarget ; variable how ; variable who ; set ok 0
if {[info exists who($m)]} { set mode [lassign $who($m) flag]
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch]} { set ok 1
} elseif {[lsearch $mode "+o"] >= 0 && [isop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+h"] >= 0 && [ishalfop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+v"] >= 0 && [isvoice $nk $ch]} { set ok 1 }
if {$ok == 0} { return 0 }
}
set tgt $nk ; set hows "NOTICE"
if {[info exists how($m)]} {
if {[string match "pub*" $how($m)]} { set tgt $ch }
if {[string match "*msg" $how($m)]} { set hows "PRIVMSG" }
}
if {$dotarget eq "0" || $target eq "" || ![onchan $target $ch]} {
set target $tgt
}
foreach line $say($m) { puthelp "$hows $target :$line" }
return 0
}
}
putlog "SayHelp ver 1.02 Loaded."
Code: Select all
variable dotarget ; variable how ; variable who ; set ok 0
if {[info exists who($m)]} { set mode [lassign $who($m) flag]
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch} { set ok 1
} elseif {[lsearch $mode "+o"] >= 0 && [isop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+h"] >= 0 && [ishalfop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+v"] >= 0 && [isvoice $nk $ch]} { set ok 1 }
if {$ok == 0} { return 0 }
}
SpiKe^^ wrote:Dominatez:
Other than the missing bracket, is this script functioning as intended?