I have this TCL script called Commands.TCL
perhaps you might know this..
OK
The thing is...
this dude reports with NOTICE, or PRIVATE MESAGGE
and I want to reports on channel..
i switched this code
Code: Select all
puthelp "NOTICE $nick
Code: Select all
puthelp "MSG $chan
When I switch this
Code: Select all
puthelp "NOTICE $nick
Code: Select all
puthelp "PRIVMSG $nick
The entired code below:
Code: Select all
##
#
# commands.tcl v1.2 - by strikelight ([sL] @ EFNet) (09/21/03)
#
# For eggdrop1.1.5-eggdrop1.6.x
#
# Contact:
# - E-Mail: strikelight@tclscript.com
# - WWW : http://www.TCLScript.com
# - IRC : #Scripting @ EFNet
#
##
#
# Description:
#
# This script will allow channel administrators to maintain a list of
# available triggers for the channel, and allow users to view the list
# of available triggers.
#
##
#
# History:
#
# (09/21/03)/v1.2 - Cosmetic fixes
#
# (10/20/02)/v1.1 - Fixed bug with error on startup:
# "can't read 'eggversion': no such variable"
# (Why didn't anyone else report this a long time ago?)
# - Added option to change the trigger command
#
# (5/27/02)/v1.0 - Initial Release
#
##
#
# Usage:
#
# Edit the configuration below, and
# type "!commands help" in a channel
#
# (Modify '!commands help' with the trigger you choose below in the config)
#
##
## CONFIGURATION ##
# Trigger to use?
set commands_trigger "!commands"
# Flag required to add/remove triggers
set commands_adminflag "m"
## END OF CONFIG ##
set commands_version "1.2"
set eggversion [string trimleft [lindex $version 1] 0]
bind pub - $commands_trigger commands:pub
proc handisop {hand chan} {
return [expr {[validchan $chan] && [isop [hand2nick $hand $chan] $chan]}]
}
if {($eggversion >= 1030000)} {
proc matchchanattr {handle flags channel} { return [matchattr $handle |$flags $channel] }
}
proc isoporvoice {nick chan} {
return [expr {[validchan $chan] && ([isop $nick $chan] || [isvoice $nick $chan])}]
}
proc handisoporvoice {hand chan} {
return [expr {[validchan $chan] && [isoporvoice [hand2nick $hand $chan] $chan]}]
}
proc mymatchattr {hand flags {chan ""}} {
if {[regsub -all {[^&|().a-zA-Z0-9@+#-]} $flags {} f]} {
putloglev o * "error: (matchattr): illegal character in flags: $flags"
return 0
}
regsub -all -- {[|&]} $f {&&} f
regsub -all -- {#-} $f {-#} f
regsub -all -- {-} $f {!} f
regsub -all -- {#?[a-zA-Z0-9]} $f {(&)} f
regsub -all -- {\(#([a-zA-Z0-9])\)} $f {[matchchanattr $hand \1 $chan]} f
regsub -all -- {\(([a-zA-Z0-9])\)} $f {[matchattr $hand \1]} f
regsub -all -- {\.} $f {1} f
regsub -all -- {@} $f {[handisop $hand $chan]} f
regsub -all -- {\+} $f {[handisoporvoice $hand $chan]} f
return [expr $f]
}
proc commands:load {} {
global commands
catch {unset commands}
if {![file exists "commands.dat"]} {
set outfile [open "commands.dat" w]
close $outfile
}
set infile [open "commands.dat" r]
set buffer [read $infile]
close $infile
set buffer [split $buffer "\n"]
foreach line $buffer {
if {$line != ""} {
set dline [split $line "|"]
set dchan [string tolower [lindex $dline 0]]
set dcmd [lindex $dline 1]
set ddesc [lindex $dline 2]
set commands($dchan,$dcmd) $ddesc
}
}
return 1
}
proc commands:save {} {
global commands
set outfile [open "commands.dat" w]
foreach item [array names commands *,*] {
set dchan [lindex [split $item ","] 0]
set dcmd [lindex [split $item ","] 1]
set ddesc $commands($item)
if {($dchan != "") && ($dcmd != "") && ($ddesc != "")} {
puts $outfile "$dchan|$dcmd|$ddesc"
}
}
close $outfile
return 1
}
proc commands:longestcmd {chan} {
global commands
set i 0
foreach item [array names commands [string tolower $chan],*] {
set ditem [join [lindex [split $item ","] 1]]
if {[string length $ditem] > $i} { set i [string length $ditem] }
}
return $i
}
proc commands:iscommand {command chan} {
global commands
return [info exists commands([string tolower $chan],$command)]
}
proc commands:add {command desc chan} {
global commands
if {[commands:iscommand $command $chan]} { return 0 }
set commands([string tolower $chan],$command) "$desc"
return 1
}
proc commands:del {command chan} {
global commands
if {![commands:iscommand $command $chan]} { return 0 }
catch {unset commands([string tolower $chan],$command)}
return 1
}
proc commands:pub {nick uhost hand chan rest} {
global commands commands_adminflag commands_trigger
set cmd [string tolower [lindex [split $rest] 0]]
set chan [string tolower $chan]
switch $cmd {
help {
set tt $commands_adminflag
puthelp "NOTICE $nick :+- \002commands.tcl\002 help"
puthelp "NOTICE $nick :: [format %-39s "$commands_trigger"] - list of commands available in channel"
if {[mymatchattr $hand $tt|#$tt $chan]} {
puthelp "MSG $nick :: [format %-39s "$commands_trigger add {<command>} <description>"] - add a command to channel"
puthelp "NOTICE $nick :: [format %-39s "$commands_trigger del {<command>}"] - remove a command for channel"
}
puthelp "NOTICE $nick :+- end of help."
return
}
add {
set tt $commands_adminflag
if {![mymatchattr $hand $tt|#$tt $chan]} { return }
set command [lindex $rest 1]
set desc [join [lrange $rest 2 end]]
if {($command == "") || ($desc == "")} {
puthelp "NOTICE $nick :Usage: $commands_trigger add {<command>} <description>"
puthelp "NOTICE $nick :Eg. : $commands_trigger add {/ctcp lamer test} does something"
return
}
set res [commands:add $command "$desc" $chan]
if {!$res} {
puthelp "NOTICE $nick :\002$command\002 is already marked as a command for $chan."
return
} else {
puthelp "NOTICE $nick :Added \002$command\002 as a command for $chan."
commands:save
return
}
}
del {
set tt $commands_adminflag
if {![mymatchattr $hand $tt|#$tt $chan]} { return }
set command [lindex $rest 1]
if {$command == ""} {
puthelp "NOTICE $nick :Usage: $commands_trigger del <command>"
return
}
set res [commands:del $command $chan]
if {!$res} {
puthelp "NOTICE $nick :\002$command\002 is not a command for $chan."
return
} else {
puthelp "NOTICE $nick :Deleted \002$command\002 as a command for $chan."
commands:save
return
}
}
default {
set lngth [commands:longestcmd $chan]
if {!$lngth} { return }
if {$lngth < 8} { set lngth 8 }
puthelp "NOTICE $nick :+- commands for \002$chan\002:"
puthelp "NOTICE $nick :: \037[format %-${lngth}s "command\037"] - \037description\037"
foreach item [lsort [array names commands $chan,*]] {
puthelp "NOTICE $nick :: \002[format %-${lngth}s "[lindex [split $item ","] 1]"]\002 - $commands($item)"
}
puthelp "NOTICE $nick :+- end of commands."
return
}
}
}
commands:load
putlog "commands.tcl v$commands_version by strikelight now loaded."
Thank you for your helps