Code: Select all
#Set the channels for this script to work on
set op_chans "#chan1 #chan2 #chan3"
#Set the flag of the users who can use the !opper command
set op_flag "n"
#Set the blacklisted nicks which cannot be opped.
set blacklisted_nicks {
"nick1"
"nick2"
"nick3"
}
bind pub $op_flag "!opper" auto:op
proc auto:op {nick uhost hand chan text} {
global op_chans op_flag blacklisted_nicks
if {([lsearch -exact [string tolower $op_chans] [string tolower $chan]] == -1) || (![botisop $chan])} { return 0 }
if {([lindex $text 0] == "")} {
putserv "PRIVMSG $chan :\002ERROR:\002 No nick specified to op! Going ahead and opping $nick on $chan."
putserv "MODE $chan +o $nick"
return 0
}
if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] != -1)} {
putserv "PRIVMSG $chan :\002ERROR:\002 Unable to op the blacklisted nick: [lindex $text 0] on $chan."
return 0
}
if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] == -1)} {
putserv "PRIVMSG $chan :Opping $nick on $chan."
putserv "MODE $chan +o [lindex $text 0]"
return 0
}
return 0
}
That works so damn good. But is there something that I can put in there to reply to a non "n" user/non-blacklisted user. I.E. "\002You are not authorized to use this command.\002awyeah wrote:Here is one I can code just in 5 mins so give it a try:
Code: Select all
#Set the channels for this script to work on set op_chans "#chan1 #chan2 #chan3" #Set the flag of the users who can use the !opper command set op_flag "n" #Set the blacklisted nicks which cannot be opped. set blacklisted_nicks { "nick1" "nick2" "nick3" } bind pub $op_flag "!opper" auto:op proc auto:op {nick uhost hand chan text} { global op_chans op_flag blacklisted_nicks if {([lsearch -exact [string tolower $op_chans] [string tolower $chan]] == -1) || (![botisop $chan])} { return 0 } if {([lindex $text 0] == "")} { putserv "PRIVMSG $chan :\002ERROR:\002 No nick specified to op! Going ahead and opping $nick on $chan." putserv "MODE $chan +o $nick" return 0 } if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] != -1)} { putserv "PRIVMSG $chan :\002ERROR:\002 Unable to op the blacklisted nick: [lindex $text 0] on $chan." return 0 } if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] == -1)} { putserv "PRIVMSG $chan :Opping $nick on $chan." putserv "MODE $chan +o [lindex $text 0]" return 0 } return 0 }
Code: Select all
#Set the channels for this script to work on
set op_chans "#chan1 #chan2 #chan3"
#Set the blacklisted nicks which cannot be opped.
set blacklisted_nicks {
"nick1"
"nick2"
"nick3"
}
bind pub - "!opper" auto:op
proc auto:op {nick uhost hand chan text} {
global op_chans blacklisted_nicks
if {(![matchattr $hand n|n $chan])} { putserv "PRIVMSG $nick :\002You are not authorized to use this command.\002"; return 0 }
if {([lsearch -exact [string tolower $op_chans] [string tolower $chan]] == -1) || (![botisop $chan])} { return 0 }
if {([lindex $text 0] == "")} {
putserv "PRIVMSG $chan :\002ERROR:\002 No nick specified to op! Going ahead and opping $nick on $chan."
putserv "MODE $chan +o $nick"
return 0
}
if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] != -1)} {
putserv "PRIVMSG $chan :\002ERROR:\002 Unable to op the blacklisted nick: [lindex $text 0] on $chan."
return 0
}
if {([lindex $text 0] != "") && ([onchan [lindex $text 0] $chan]) && ([lsearch -exact [string tolower $blacklisted_nicks] [string tolower [lindex $text 0]]] == -1)} {
putserv "PRIVMSG $chan :Opping $nick on $chan."
putserv "MODE $chan +o [lindex $text 0]"
return 0
}
return 0
}
Thank you so much. I would be lieing if I didnt say I admire your talent with tcl. Anyway... thanks again.awyeah wrote:Basically we have binded for users with "n", so a normal user cannot trigger the bind. But we can add a new bind or modify the existing code to work on it.
I modified the existing one, here give it a go. It will only work for users who have a global|channel 'n' flag. Others will get an access denied message.