Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- ## This FILE is part OF the Wolfpack module system
- ## Copyright (C) 1998-2003 Tothwolf <tothwolf@concentric.net>
- ## AND is distributed according to the GNU general public license.
- ## For full details, read the top OF wolfpack.tcl or the FILE called
- ## COPYING that was distributed WITH this code.
- ##
- ## $Id: pubcmds.tcl,v 1.14 2003/02/12 21:27:17 tothwolf Exp $
- ##
- # name: pubcmds
- # version: 1.6.0.0
- # config: pubcmds.conf
- # description: Provides secure public user AND channel commands.
- # requires: authCheck commandChar putList putnot splitList findUser \
- # getLastOn isNumber
- namespace eval pubcmds {
- ##
- ## Ops or voices a user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:UP {nick uhost hand chan arg} {
- if {[authCheck pub UP $nick $uhost $hand $chan]} then {
- if {[botisop $chan]} then {
- if {[matchattr $hand o|o $chan]} then {
- if {![isop $nick $chan]} then {
- pushmode $chan +o $nick
- putnot $nick "You have been been op'd on $chan."
- } else {
- putnot $nick "You already have op on $chan."
- }
- } elseif {[matchattr $hand v|v $chan]} then {
- if {![isvoice $nick $chan]} then {
- pushmode $chan +v $nick
- putnot $nick "You have been voiced on $chan."
- } else {
- putnot $nick "You already have voice on $chan."
- }
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Deops or devoices a user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:down {nick uhost hand chan arg} {
- if {[authCheck pub down $nick $uhost $hand $chan]} then {
- if {[botisop $chan]} then {
- if {[matchattr $hand o|o $chan]} then {
- if {[isop $nick $chan]} then {
- pushmode $chan -o $nick
- putnot $nick "You have been deop'd on $chan."
- } else {
- putnot $nick "You do not have op on $chan."
- }
- } elseif {[matchattr $hand v|v $chan]} then {
- if {[isvoice $nick $chan]} then {
- pushmode $chan -v $nick
- putnot $nick "You have been devoiced on $chan."
- } else {
- putnot $nick "You do not have voice on $chan."
- }
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Ops the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:op {nick uhost hand chan arg} {
- if {[authCheck pub op $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]op <nick>"
- } elseif {[botisop $chan]} then {
- if {![isbotnick $who]} then {
- if {[onchan $who $chan]} then {
- if {![isop $who $chan]} then {
- pushmode $chan +o $who
- putnot $nick "Gave op to $who on $chan."
- } else {
- putnot $nick "$who is already op'd on $chan."
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I can't op myself!"
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Deops the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:deop {nick uhost hand chan arg} {
- if {[authCheck pub deop $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]deop <nick>"
- } elseif {[botisop $chan]} then {
- if {![isbotnick $who]} then {
- if {[onchan $who $chan]} then {
- if {[isop $who $chan]} then {
- if {(![matchattr [nick2hand $who $chan] m|m $chan]) || \
- (![string compare [string tolower $hand] \
- [string tolower [nick2hand $who $chan]]])} then {
- pushmode $chan -o $who
- putnot $nick "Took op from $who on $chan."
- } else {
- putnot $nick "You can't deop a master."
- }
- } else {
- putnot $nick "$who is not op'd on $chan."
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I won't deop myself!"
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Voices the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:voice {nick uhost hand chan arg} {
- if {[authCheck pub voice $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]voice <nick>"
- } elseif {[botisop $chan]} then {
- if {![isbotnick $who]} then {
- if {[onchan $who $chan]} then {
- if {![isvoice $who $chan]} then {
- pushmode $chan +v $who
- putnot $nick "Gave voice to $who on $chan."
- } else {
- putnot $nick "$who is already voiced on $chan."
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I can't voice myself!"
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Devoices the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:devoice {nick uhost hand chan arg} {
- if {[authCheck pub devoice $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]devoice <nick>"
- } elseif {[botisop $chan]} then {
- if {![isbotnick $who]} then {
- if {[onchan $who $chan]} then {
- if {[isvoice $who $chan]} then {
- pushmode $chan -v $who
- putnot $nick "Took voice from $who on $chan."
- } else {
- putnot $nick "$who is not voiced on $chan."
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I won't devoice myself!"
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Bans the given nick or mask: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:ban {nick uhost hand chan arg} {
- if {[authCheck pub ban $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set reason [join [lrange $arg 1 end]]
- if {![string compare "" $reason]} then {
- set reason requested
- }
- set parts [scan $who "%\[^!\]!%\[^@\]@%s" bannick banuser banhost]
- if {($parts != 1) && ($parts != 3)} then {
- putnot $nick "Usage: [commandChar pub]ban <nick|mask> \[reason\]"
- } elseif {[botisop $chan]} then {
- if {$parts == 1} then {
- if {[onchan $who $chan]} then {
- if {[isbotnick $who]} then {
- putnot $nick "I won't ban myself!"
- return 1
- } elseif {[matchattr [nick2hand $who $chan] m|m $chan]} then {
- putnot $nick "I won't ban a master."
- return 1
- } elseif {[matchattr [nick2hand $who $chan] o|o $chan]} then {
- putnot $nick "I won't ban an op."
- return 1
- } elseif {[matchattr [nick2hand $who $chan] b]} then {
- putnot $nick "I won't ban another bot."
- return 1
- } else {
- set mask *!*[string trimleft [maskhost [getchanhost $who $chan]] *!]
- }
- } else {
- putnot $nick "Unable to ban $who: invalid nick/banmask."
- return 1
- }
- } elseif {$parts == 3} then {
- foreach badmask "\\* \\*.?? \\*.\\*.?? \\*.??? \\*.\\*.???" {
- if {[string match $badmask $banhost]} then {
- putnot $nick "Unable to ban $who: invalid banmask."
- return 1
- }
- }
- foreach nickname [chanlist $chan] {
- if {[string match $who $nick![getchanhost $nick $chan]]} then {
- if {[isbotnick $nickname]} then {
- putnot $nick "I won't ban myself!"
- return 1
- } elseif {[matchattr [set hand2 [nick2hand $nickname $chan]] m|m $chan]} then {
- putnot $nick "I won't ban a master."
- return 1
- } elseif {[matchattr $hand2 o|o $chan]} then {
- putnot $nick "I won't ban an op."
- return 1
- } elseif {[matchattr $hand2 b]} then {
- putnot $nick "I won't ban another bot."
- return 1
- }
- }
- }
- set mask $who
- }
- if {![isban $mask $chan]} then {
- if {[onchan $who $chan]} then {
- if {[isop $who $chan]} then {
- newchanban $chan $mask $hand $reason 0
- putquick "MODE $chan -o+b $who $mask"
- putnot $nick "Added ban $mask on $chan."
- } else {
- newchanban $chan $mask $hand $reason 0
- putquick "MODE $chan +b $mask"
- putnot $nick "Added ban $mask on $chan."
- }
- } else {
- newchanban $chan $mask $hand $reason 0
- putquick "MODE $chan +b $mask"
- putnot $nick "Added ban $mask on $chan."
- }
- } else {
- resetbans $chan
- putnot $nick "$mask is already banned on $chan."
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Unbans the given nick or mask: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:unban {nick uhost hand chan arg} {
- if {[authCheck pub unban $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]unban <nick|mask>"
- } elseif {[botisop $chan]} then {
- if {[onchan $who $chan]} then {
- set mask [maskhost [getchanhost $who $chan]]
- } else {
- set mask $who
- }
- if {[ischanban $mask $chan]} then {
- killchanban $chan $mask
- pushmode $chan -b $mask
- putnot $nick "Removed ban $mask from $chan."
- } else {
- putnot $nick "$mask is not banned on $chan."
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Kicks the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:kick {nick uhost hand chan arg} {
- if {[authCheck pub kick $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set reason [join [lrange $arg 1 end]]
- set OK 0
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]kick <nick> \[reason\]"
- } elseif {[botisop $chan]} then {
- if {[onchan $who $chan]} then {
- if {![isbotnick $who]} then {
- if {[matchattr $hand m|m $chan]} then {
- set OK 1
- }
- set khand [nick2hand $who $chan]
- if {($ok) || (![matchattr $khand m|m $chan])} then {
- if {($ok) || (![matchattr $khand o|o $chan])} then {
- if {($ok) || (![matchattr $khand b])} then {
- if {![string compare "" $reason]} then {
- set reason requested
- }
- if {[isop $who $chan]} then {
- putquick "MODE $chan -o $who"
- putkick $chan $who $reason
- putnot $nick "Kicked $who from $chan."
- } else {
- putkick $chan $who $reason
- putnot $nick "Kicked $who from $chan."
- }
- } else {
- putnot $nick "I won't kick another bot."
- }
- } else {
- putnot $nick "I won't kick an op."
- }
- } else {
- putnot $nick "I won't kick a master."
- }
- } else {
- putnot $nick "I won't kick myself!"
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Kickbans the given nick: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:kickban {nick uhost hand chan arg} {
- if {[authCheck pub kickban $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set reason [join [lrange $arg 1 end]]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]kickban <nick> \[reason\]"
- } elseif {[botisop $chan]} then {
- if {[onchan $who $chan]} then {
- if {![isbotnick $who]} then {
- if {![matchattr [nick2hand $who $chan] m|m $chan]} then {
- if {![matchattr [nick2hand $who $chan] o|o $chan]} then {
- if {![matchattr [nick2hand $who $chan b]]} then {
- set mask [maskhost [getchanhost $who $chan]]
- if {![isban $mask $chan]} then {
- if {![string compare "" $reason]} then {
- set reason requested
- }
- if {[isop $who $chan]} then {
- newchanban $chan $mask $hand $reason 0
- putquick "MODE $chan -o+b $who $mask"
- putkick $chan $who $reason
- } else {
- newchanban $chan $mask $hand $reason 0
- putquick "MODE $chan +b $mask"
- putkick $chan $who $reason
- }
- putnot $nick "Added ban $mask and kicked $who from $chan."
- } else {
- resetbans $chan
- putnot $nick "$who is already banned on $chan."
- }
- } else {
- putnot $nick "I won't kickban another bot."
- }
- } else {
- putnot $nick "I won't kickban an op."
- }
- } else {
- putnot $nick "I won't kickban a master."
- }
- } else {
- putnot $nick "I won't kickban myself!"
- }
- } else {
- putnot $nick "$who is not on $chan."
- }
- } else {
- putnot $nick "I can't help you right now since I'm not an op on $chan."
- }
- return 1
- }
- return 0
- }
- ##
- ## Changes a mode ON the channel: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:mode {nick uhost hand chan arg} {
- global botnick
- if {[authCheck pub mode $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set mode [lindex $arg 0]
- set what [join [lrange $arg 1 end]]
- if {![string compare "" $mode]} then {
- putnot $nick "Usage: [commandChar pub]mode <+-mode(s)> \[arguments\]"
- } else {
- if {![matchattr $hand m|m $chan]} then {
- if {![regexp ".*o.*" $mode]} then {
- if {![regexp ".*v.*" $mode]} then {
- if {![regexp ".*b.*" $mode]} then {
- if {![string compare "" $what]} then {
- putquick "MODE $chan $mode"
- putnot $nick "Set mode $mode on $chan."
- } else {
- if {![regexp .*[string tolower $botnick].* [string tolower $what]]} then {
- putquick "MODE $chan $mode $what"
- putnot $nick "Set mode $mode $what on $chan."
- } else {
- putnot $nick "I won't do modes against myself!"
- }
- }
- } else {
- set reason "Only masters can ban or unban users with this command."
- }
- } else {
- set reason "Only masters can voice or devoice users with this command."
- }
- } else {
- set reason "Only masters can op or deop users with this command."
- }
- } else {
- if {![string compare "" $what]} then {
- putquick "MODE $chan $mode"
- } else {
- putquick "MODE $chan $mode $what"
- }
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Displays/changes the topic ON the channel: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:topic {nick uhost hand chan arg} {
- if {[authCheck pub topic $nick $uhost $hand $chan]} then {
- set topic [string trimright $arg]
- if {![string compare "" $topic]} then {
- set oldtopic [topic $chan]
- if {[string compare "" $oldtopic]} then {
- putnot $nick "Topic for $chan: $oldtopic"
- } else {
- putnot $nick "No topic is set for $chan."
- }
- } elseif {![string compare none $topic]} then {
- putserv "TOPIC $chan :"
- putnot $nick "Cleared topic ON $chan."
- } else {
- putserv "TOPIC $chan :$topic"
- putnot $nick "Changed topic ON $chan to: $topic"
- }
- return 1
- }
- return 0
- }
- ##
- ## Shows a user's flags: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:access {nick uhost hand chan arg} {
- if {[authCheck pub access $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set chan2 [lindex $arg 1]
- if {[string compare "" $chan2]} then {
- set chan $chan2
- }
- if {[validchan $chan]} then {
- if {![string compare "" $who]} then {
- set user $hand
- } elseif {[matchattr $hand m|m $chan]} then {
- set user [findUser $who $chan]
- } else {
- putnot $nick "Only a master CAN specify another user."
- return 1
- }
- if {[validuser $user]} then {
- scan [chattr $user $chan] "%\[^|\]|%s" gflags cflags
- if {![string compare "-" $gflags]} then {
- set gflags none
- }
- if {![string compare "-" $cflags]} then {
- set cflags none
- }
- putnot $nick "Global flags for $user: $gflags"
- putnot $nick "Channel flags for $user ON $chan: $cflags"
- } else {
- putnot $nick "I don't know who $who is."
- }
- } else {
- putnot $nick "$chan is NOT a valid channel."
- }
- return 1
- }
- return 0
- }
- ##
- ## Makes the bot cycle the channel: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:cycle {nick uhost hand chan arg} {
- if {[authCheck pub cycle $nick $uhost $hand $chan]} then {
- putquick "PART $chan"
- putquick "JOIN $chan"
- putnot $nick "Finished cycling $chan."
- return 1
- }
- return 0
- }
- ##
- ## Adds a new user to the userfile: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:adduser {nick uhost hand chan arg} {
- variable configData
- if {[authCheck pub adduser $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set host [lindex $arg 1]
- if {(![string compare "" $who]) || \
- ((![onchan $who $chan]) && (![string compare "" $host]))} then {
- putnot $nick "Usage: [commandChar pub]adduser <nick> \[host\] | <hand> <host>"
- } elseif {[string length $who] <= $configData(handlen)} then {
- if {![validuser $who]} then {
- if {![string compare "" $host]} then {
- if {[onchan $who $chan]} then {
- set host [maskhost [getchanhost $who $chan]]
- adduser $who $host
- putnot $nick "Added user: $who WITH host: $host"
- } else {
- putnot $nick "$who is NOT ON $chan."
- }
- } else {
- adduser $who $host
- putnot $nick "Added user: $who WITH host: $host"
- }
- } else {
- putnot $nick "I already know a $who."
- }
- } else {
- putnot $nick "Handle must be no longer THAN $configData(handlen) characters."
- }
- return 1
- }
- return 0
- }
- ##
- ## Removes a user from the userfile: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:deluser {nick uhost hand chan arg} {
- if {[authCheck pub deluser $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]deluser <nick|hand>"
- } else {
- set user [findUser $who $chan]
- if {[validuser $user]} then {
- if {![matchattr $user m|m $chan]} then {
- deluser $user
- putnot $nick "Deleted user: $user"
- } else {
- putnot $nick "You CAN't delete a master."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Adds a host for a user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:addhost {nick uhost hand chan arg} {
- if {[authCheck pub addhost $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set host [lindex $arg 1]
- if {(![string compare "" $who]) || (![string compare "" $host])} then {
- putnot $nick "Usage: [commandChar pub]addhost <nick|hand> <hostmask>"
- } else {
- set user [findUser $who $chan]
- if {[validuser $user]} then {
- if {(![matchattr $user m|m $chan]) && \
- ([string compare [string tolower $hand] [string tolower $user]])} then {
- if {[lsearch -exact [string tolower [getuser $user HOSTS]] \
- [string tolower $host]] == -1} then {
- setuser $user HOSTS $host
- putnot $nick "Added $host to $user."
- } else {
- putnot $nick "$host is already a valid host for $user."
- }
- } else {
- putnot $nick "You CAN't change hosts for masters."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Removes a host for a user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:delhost {nick uhost hand chan arg} {
- if {[authCheck pub delhost $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set host [lindex $arg 1]
- if {(![string compare "" $who]) || (![string compare "" $host])} then {
- putnot $nick "Usage: [commandChar pub]delhost <nick|hand> <hostmask>"
- } else {
- set user [findUser $who $chan]
- if {[validuser $user]} then {
- if {(![matchattr $user m|m $chan]) && \
- ([string compare [string tolower $hand] [string tolower $user]])} then {
- if {[lsearch -exact [getuser $user HOSTS] $host] != -1} then {
- delhost $user $host
- putnot $nick "Removed $host from $user."
- } else {
- putnot $nick "$host is NOT a valid host for $user."
- }
- } else {
- putnot $nick "You CAN't change hosts for masters."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Shows a user's whois info: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- # FIXME: handle long HANDLEN handles
- proc pub:whois {nick uhost hand chan arg} {
- global whois-fields
- if {[authCheck pub whois $nick $uhost $hand $chan]} then {
- set who [lindex [split [string trimright $arg]] 0]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]whois <nick|hand>"
- } else {
- set user [findUser $who $chan]
- if {[validuser $user]} then {
- if {[passwdok $user ""]} then {
- set pass no
- } else {
- set pass yes
- }
- set notes [llength [listnotes $user -]]
- set flags [chattr $user]
- set lasttmp [getLastOn $user ""]
- set lastwhere [lindex $lasttmp 1]
- if {![string compare "" $lastwhere]} then {
- set laston [lindex $lasttmp 0]
- } else {
- set laston "[lindex $lasttmp 0] ($lastwhere)"
- }
- foreach channel [channels] {
- set chanflags [lindex [split [chattr $user $channel] |] 1]
- set chanlaston [getLastOn $user $channel]
- if {[string compare "-" $chanflags]} then {
- set chanlist($channel) "$chanflags $chanlaston"
- }
- }
- set hosts [getuser $user HOSTS]
- regsub -all -- " " $hosts ", " hosts
- set xtrafields [string tolower ${whois-fields}]
- foreach field [lsort [getuser $user XTRA]] {
- if {[lsearch -exact $xtrafields [string tolower [lindex $field 0]]] != -1} then {
- lappend xtradata $field
- }
- }
- if {![matchattr $user b]} then {
- set info [getuser $user INFO]
- } else {
- set botflags [getuser $user BOTFL]
- foreach {botaddress botport1 botport2} [getuser $user BOTADDR] {break}
- }
- putnot $nick "HANDLE PASS NOTES FLAGS LAST"
- putnot $nick "[format "%-9s %-4s %5s %-15s %s" $user $pass $notes $flags $laston]"
- foreach {name data} [array get chanlist] {
- foreach {flags laston} $data {break}
- putnot $nick "[format " %-17s %-15s %s" $name $flags $laston]"
- }
- if {([info exists hosts]) && ([string compare "" $hosts])} then {
- putList putnot $nick [splitList $hosts 35 , ", "] " HOSTS: " " "
- }
- if {[info exists xtradata]} then {
- foreach field $xtradata {
- putnot $nick " [lindex $field 0]: [lrange $field 1 end]"
- }
- }
- if {([info exists info]) && ([string compare "" $info])} then {
- putnot $nick " INFO: $info"
- }
- if {([info exists botflags]) && ([string compare "" $botflags])} then {
- putnot $nick " BOT FLAGS: $botflags"
- }
- if {([info exists botaddress]) && \
- (([string compare "" $botaddress]) && \
- ([string compare "" $botport1]) && \
- ([string compare "" $botport2]))} then {
- putnot $nick " ADDRESS: $botaddress"
- putnot $nick " telnet: $botport1, relay: $botport2"
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Adds +o or +oa for the given user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:addop {nick uhost hand chan arg} {
- variable configData
- if {[authCheck pub addop $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set chan2 [lindex $arg 1]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]addop <nick|hand> \[chan\]"
- } else {
- set user [findUser $who $chan]
- if {[string compare "" $chan2]} then {
- if {[validchan $chan2]} then {
- set where $chan2
- } else {
- putnot $nick "Invalid channel: $chan2"
- return 1
- }
- } else {
- set where $chan
- }
- if {[validuser $user]} then {
- if {![matchattr $user |o $where]} then {
- if {$configData(autoop)} then {
- chattr $user |+oa $where
- } else {
- chattr $user |+o $where
- }
- putnot $nick "Added op for $user."
- } else {
- putnot $nick "$user already had op ON $where."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Removes +oa for the given user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:delop {nick uhost hand chan arg} {
- if {[authCheck pub delop $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set chan2 [lindex $arg 1]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]delop <nick|hand> \[chan\]"
- } else {
- set user [findUser $who $chan]
- if {[string compare "" $chan2]} then {
- if {[validchan $chan2]} then {
- set where $chan2
- } else {
- putnot $nick "Invalid channel: $chan2"
- return 1
- }
- } else {
- set where $chan
- }
- if {[validuser $user]} then {
- if {[matchattr $user |o $where]} then {
- chattr $user |-oa $where
- putnot $nick "Removed op from $user."
- } else {
- putnot $nick "$user didn't have op ON $where."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Adds +v for the given user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- ##
- proc pub:addvoice {nick uhost hand chan arg} {
- if {[authCheck pub addvoice $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set chan2 [lindex $arg 1]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]addvoice <nick|hand> \[chan\]"
- } else {
- set user [findUser $who $chan]
- if {[string compare "" $chan2]} then {
- if {[validchan $chan2]} then {
- set where $chan2
- } else {
- putnot $nick "Invalid channel: $chan2"
- return 1
- }
- } else {
- set where $chan
- }
- if {[validuser $user]} then {
- if {![matchattr $user |v $where]} then {
- chattr $user |+v $where
- putnot $nick "Added voice for $user."
- } else {
- putnot $nick "$user already had voice ON $where."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- ##
- ## Removes +v for the given user: pub
- ##
- ## Args: nick, user@host, handle, channel, arg
- ## Returns: 1 if the user is auth'd
- ## 0 otherwise
- proc pub:delvoice {nick uhost hand chan arg} {
- if {[authCheck pub delvoice $nick $uhost $hand $chan]} then {
- set arg [split [string trimright $arg]]
- set who [lindex $arg 0]
- set chan2 [lindex $arg 1]
- if {![string compare "" $who]} then {
- putnot $nick "Usage: [commandChar pub]delvoice <nick|hand> \[chan\]"
- } else {
- set user [findUser $who $chan]
- if {[string compare "" $chan2]} then {
- if {[validchan $chan2]} then {
- set where $chan2
- } else {
- putnot $nick "Invalid channel: $chan2"
- return 1
- }
- } else {
- set where $chan
- }
- if {[validuser $user]} then {
- if {[matchattr $user |v $where]} then {
- chattr $user |-v $where
- putnot $nick "Removed voice from $user."
- } else {
- putnot $nick "$user didn't have voice ON $where."
- }
- } else {
- putnot $nick "I don't know who $who is."
- }
- }
- return 1
- }
- return 0
- }
- # Configuration defaults, values and descriptions
- array set configDefaults {
- autoop {switch 0 {} {0/1} {add +a flag when adding the user as an op?}}
- handlen {handlen 9 {} handlen {max handle length}}
- }
- # Bind defaults
- array set bindDefaults {
- pub:up {{pub -|- up {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:down {{pub -|- down {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:op {{pub o|o op {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:deop {{pub o|o deop {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:voice {{pub o|o voice {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:devoice {{pub o|o devoice {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:ban {{pub o|o ban {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:unban {{pub o|o unban {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:kick {{pub o|o kick {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:kickban {{pub o|o kickban {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:mode {{pub o|o mode {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:topic {{pub o|o topic {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:access {{pub o|o access {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:cycle {{pub m|m cycle {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:adduser {{pub m|m adduser {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:deluser {{pub m|m deluser {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:addhost {{pub m|m addhost {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:delhost {{pub m|m delhost {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:whois {{pub m|m whois {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:addop {{pub m|m addop {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:delop {{pub m|m delop {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:addvoice {{pub m|m addvoice {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- pub:delvoice {{pub m|m delvoice {cmdchr {cmdsub {{commandChar pub} ^}}} {}}}
- }
- # Help Data
- array set helpData {
- pub:up {{} {ops or voices the user using the command}}
- pub:down {{} {deops or devoices the user using the command}}
- pub:op {{<nick>} {ops the given nick}}
- pub:deop {{<nick>} {deops the given nick}}
- pub:voice {{<nick>} {voices the given nick}}
- pub:devoice {{<nick>} {devoice the given nick}}
- pub:ban {{<nick|mask> [reason]} {bans the given nick or mask from the channel with an optional reason}}
- pub:unban {{<nick|mask>} {unbans the given nick or mask from the channel}}
- pub:kick {{<nick> [reason]} {kicks the given nick from the channel the an optional reason}}
- pub:kickban {{<nick> [reason]} {kicks and bans the given nick from the channel with an optional reason}}
- pub:mode {{<+-mode(s)> [argument(s)]} {changes the mode on the channel}}
- pub:topic {{[topic]} {sets the topic on the channel to the topic given, or if none specified, will tell you the current topic}}
- pub:access {{[nick|hand] [chan]} {shows access flags for the given nick/hand on the given channel}}
- pub:cycle {{} {makes the bot cycle the channel}}
- pub:adduser {{<nick> [host] | <hand> <host>} {adds a user to the bot's userlist}}
- pub:deluser {{<nick|hand>} {removes a user from the bot's userlist}}
- pub:addhost {{<nick|hand> <host>} {adds a host for the given user}}
- pub:delhost {{<nick|hand> <host>} {removes a host for the given user}}
- pub:whois {{<nick|hand>} {shows information for the given user}}
- pub:addop {{<nick|hand>} {adds op access for the given user for the current channel}}
- pub:delop {{<nick|hand>} {removes op access for the given user for the current channel}}
- pub:addvoice {{<nick|hand>} {adds voice access for the given user for the current channel}}
- pub:delvoice {{<nick|hand>} {removes voice access for the given user for the current channel}}
- }
- } ;# namespace pubcmds
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement