# Script name : addban10-mbti.tcl
# Script Version: 1.0
# Script Author : The |mmortaL [asn@cdc.net] (PGP Public key Avaible, put "send key" in the subject.)
# Script Desc. : adds a DCC command called .addban.
# Script Synax : .addban [channel] <nick>
# Bind type: DCC
# Bind Flag: Channel/Global Op
# Bind Cmd : addban
# bind proc: dcc:addban
bind dcc O addban dcc:addban
proc dcc:addban {hand idx text} {
global botnick
# Global, or channel ban?
if {[string match *#* [lindex $text 0]]} {
# Extract the channel from $text, and make it all lowercase
set chan [string tolower [lindex $text 0]]
# is he an Global op? or a Channel op? If he isn't uh-oh
if {(![matchattr $hand o]) && (![matchchanattr $hand o $chan])} {
putdcc $idx "<**> Error: Your not a channel op on $chan, or a global op!"
return 0
}
# is the bot on $chan?!
if {![string match *$chan* [string tolower [channels]]]} {
putdcc $idx "<**> Error I'm not in $chan!"
putdcc $idx "<**> Syntax: .addban \[channel\] <nick> <reason>"
return 0
}
# Extract who we want to ban, and make it lowercase
set who [string tolower [lindex $text 1]]
# Ewps, forgot to say who to ban?!
if {$who == ""} {
putdcc $idx "<**> Syntax: .addban \[channel\] <nick> <reason>"
return 0
}
# Is the bot $who??
if {[string tolower $botnick] == $who} {
putdcc $idx "<**> I will not ban my self thank you very much!"
return 0
}
# is $who on $chan?
if {![onchan $who $chan]} {
putdcc $idx "<**> Error: $who is not on $chan"
return 0
}
# What is $who's Handle?
set hwho [nick2hand $who $chan]
# If who has a handle on the bot do:
if {$hwho != "*"} {
if {([matchattr $hwho o]) || ([matchchanattr $hwho o $chan]) || ([matchattr $hwho m]) || ([matchchanattr $hwho m $chan])} {
putdcc $idx "<**> $who ($hwho) is a operator, or master on $chan, I can't ban him!"
return 0 }
}
# Lets get the ban mask
set mask [getchanhost $who $chan]
# Make it in to a viable banning mask
set mask [maskhost $mask]
# Now mae it *!*, not *!
set mask [string trimleft $mask *!]
set mask *!*$mask
# Extract the reason
set reason [lrange $text 2 end]
# If the reason is nothing?
if {$reason == ""} {
set reason "$hand told me to!"
}
# Create the perm ban
newchanban $chan $mask $hand $reason 0
return 1
}
# Extract who
set who [lindex $text 0]
# Make it lower case
set who [string tolower $who]
# Make sure $hand is a global op
if {![matchattr $hand o]} {
putdcc $idx "<**> Error: Your not a Global Operator, you can't set global bans!!"
return 0
}
# Ewps, did I just type .addban?
if {$who == ""} {
putdcc $idx "<**> Syntax: .addban \[channel\] <nick> <reason>"
return 0
}
if {[string tolower $botnick] == $who} {
putdcc $idx "<**> I will not ban my self thank you very much!"
return 0
}
# Okay I need to extract the channel from $who's console
# the channel is the first paramter in [console $idx]
set chan [lindex [console $idx] 0]
# is $who on $chan?
if {![onchan $who $chan]} {
putdcc $idx "<**> Error: $who is not on $chan"
return 0
}
# What is $who's Handle?
set hwho [nick2hand $who $chan]
# If who has a handle on the bot do:
if {$hwho != "*"} {
if {([matchattr $hwho o]) || ([matchchanattr $hwho o $chan]) || ([matchattr $hwho m]) || ([matchchanattr $hwho m $chan])} {
putdcc $idx "<**> $who ($hwho) is a operator, or master on $chan, I can't ban him!"
return 0
}
}
# Lets get the ban mask
set mask [getchanhost $who $chan]
# Make it in to a viable banning mask
set mask [maskhost $mask]
# Now mae it *!*, not *!
set mask [string trimleft $mask *!]
set mask *!*$mask
# Extract the reason
set reason [lrange $text 1 end]
# If the reason is nothing?
if {$reason == ""} {
set reason "$hand told me to!"
}
# Create the perm ban
newban $mask $hand $reason 0
return 1
}