ComputerTech wrote:yeah blacktools already has this feature, But if you wanted to make the .chanset part a seperate script take a look in blacktools modules directory it would have it there.
ps: i got BlackShadow to modify his blacktools clonescanner into a seperate script
Code: Select all
bind pub n|n !chanset pub:chanset
proc pub:chanset {nick uhost hand chan arg} {
foreach {set value} [split $arg] {break}
if {![info exists value]} {
catch {channel set $chan $set} error
} {
catch {channel set $chan $set $value} error
}
if {$error == ""} {
puthelp "privmsg $chan :Successfully set $arg"
} {
puthelp "privmsg $chan :Error setting $arg: [lindex $error 0]..."
}
}
Code: Select all
set setting [string trimleft [lindex [split $text] 0] "+-"]
if {[channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already enabled on $chan."
} else {
channel set $chan $mode +$setting
putserv "NOTICE $nick :$setting is now enabled."
}
if {![channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already disabled on $chan."
} else {
channel set $chan $mode -$setting
putserv "NOTICE $nick :$setting is now disabled."
}
Tcl error [pub:chanset]: Unknown channel setting.
Code: Select all
bind pub n|n .chanset pub:chanset
proc pub:chanset {nick uhost hand chan text} {
set setting [string trimleft [lindex [split $text] 0] "+-"]
set value [lassign [split $text] mode]
if {![info exists value] || $value eq ""} {
catch {channel set $chan $mode} error
} else {
catch {channel set $chan $mode $value} error
}
if {[channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already enabled on $chan."
} else {
channel set $chan $mode +$setting
putserv "NOTICE $nick :$setting is now enabled."
}
if {![channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already disabled on $chan."
} else {
channel set $chan $mode -$setting
putserv "NOTICE $nick :$setting is now disabled."
}
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $text"
} else {
putnow "NOTICE $nick :Error setting $text: $error "
}
}
Code: Select all
bind pub n|n .chanset pub:chanset
proc pub:chanset {nick uhost hand chan text} {
set setting [string trimleft [lindex [split $text] 0] "+-"]
set value [lassign [split $text] mode]
if {![info exists value] || $value eq ""} {
catch {channel set $chan $mode} error
} else {
catch {channel set $chan $mode $value} error
}
if {[channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already enabled on $chan."
} else {
putserv "NOTICE $nick :$setting is now enabled."
}
if {![channel get $chan $setting]} {
putserv "NOTICE $nick :$setting is already disabled on $chan."
} else {
putserv "NOTICE $nick :$setting is now disabled."
}
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $text"
} else {
putnow "NOTICE $nick :Error setting $text: $error "
}
}
Unknown channel setting
17:16:35 (+Simo) : .chanset +youtube
17:16:37 -Hawk- : youtube is already enabled on #test.
17:16:37 -Hawk- : youtube is now disabled.
17:16:37 -Hawk- : Successfully set +youtube
17:16:58 (+Simo) : .chanset -youtube
17:16:58 -Hawk- : youtube is now enabled.
17:16:59 -Hawk- : youtube is already disabled on #test.
17:16:59 -Hawk- : Successfully set -youtube
Code: Select all
#
#Chanset TCL
#
# !chanset <+/-settting> ; setting <value>
#
# BLaCkShaDoW Production
#############################################################################
set set_flags "nm|nm"
#############################################################################
bind pub $set_flags !chanset set:proc
proc set:proc {nick host hand chan arg} {
set flag [lindex [split $arg] 0]
set str [join [lrange [split $arg] 1 end]]
set value ""
set error 0
if {$flag == ""} {
puthelp "NOTICE $nick :use !set <+/-settting> ; setting <value>"
return
}
if {[regexp {^[+-]} $flag]} {
set rem_flag [string map {"+" "" "-" ""} $flag]
set error [catch {channel get $chan $rem_flag} value]
}
if {$error == "1"} {
puthelp "NOTICE $nick :Invalid channel setting."
return
}
if {[regexp {^[+]} $flag]} {
if {$value == "1"} {
puthelp "NOTICE $nick :Setting \002$flag\002 is already set."
} else {
channel set $chan $flag
puthelp "NOTICE $nick :Enabled \002$flag\002 setting."
}
} elseif {[regexp {^[-]} $flag]} {
if {$value == "0"} {
puthelp "NOTICE $nick :Setting \002$flag\002 is already disabled."
} else {
channel set $chan $flag
puthelp "NOTICE $nick :Disabled \002$flag\002 setting."
}
} else {
set error [catch {channel get $chan $flag} value]
set rem_value [string map {" " ":"} $value]
if {$error == "1"} {
puthelp "NOTICE $nick :Invalid channel setting."
return
}
if {$str == ""} {
puthelp "NOTICE $nick :use !set <+/-settting> ; setting <value>"
return
}
if {[string equal -nocase $rem_value $str]} {
puthelp "NOTICE $nick :\002$flag\002 is already set to \002$str\002"
return
}
channel set $chan $flag $str
puthelp "NOTICE $nick :Set \002$flag\002 to \002$str\002"
}
}
putlog "Chanset TCL by BLaCkShaDoW Loaded. For more TCLs visit WwW.TclScripts.Net"
Code: Select all
namespace eval ChanSet {
bind pub n|n .set [namespace current]::chanset
proc chanset {nick uhost hand chan text} {
set pos [string first # $text]
if {!$pos} {
scan $text {%s%s} chan mode
} else {
scan $text {%s} mode
}
if {![info exists mode]} {
puthelp "NOTICE $nick :Error, usage: $::lastbind \[channel\] <channel mode> \[value\]. For example $::lastbind #foo +enforcebans, $::lastbind $chan blah 1 2 3, $::lastbind foo 2:5"
return
}
if {![string last - $mode]} {
set what [string map {- ""} $mode]
} else {
set what [string map {+ ""} $mode]
}
if {![validchan $chan]} {
puthelp "NOTICE $nick :Error, I'm not on $chan channel."
return
}
if {[string equal $mode $what]} {
set value [lrange $text [expr $pos +2] end]
}
if {[catch {set now [channel get $chan $what]} err]} {
puthelp "NOTICE $nick :Error, \002$what\002 is an unkown channel setting."
return
}
if {[info exists value]} {
if {[string equal -nocase $now $value]} {
puthelp "NOTICE $nick :Channel mode $what is already set to $now."
return
}
channel set $chan $mode $value
puthelp "NOTICE $nick :Channel mode $what has been set to $value for $chan cahnnel."
} else {
scan [string map {+ 1 - 0} $mode] {%d} change
if {[string equal $now $change]} {
puthelp "NOTICE $nick :Error, channel mode $what is already [expr {$now ? "enabled" : "disabled"}] for $chan channel"
return
}
channel set $chan $mode
puthelp "NOTICE $nick :Channel mode $what has been [expr {[string first + $mode] > -1 ? "enabled" : "disabled"}] for $chan channel."
}
}
}