TCL 'nin Türkçe'ye çevrilmiş hali, şu an kullandığım ve %100 çalışan son halini paylaşıyorum.
Komutlar şöyle;
!badekle Nick ( wildcard kullanımı var, Ni?k!*@* veya nick!ident@host şeklinde kullanabilirsiniz. )
!badsil Nick ( wildcard veya host & ip yazılabilir gene, silmek için bu da ) !banekle Nick ( aynı şekilde ekler lakin kalıcı ban ekler, -b yapılsa bile bot gene +b yapar kendisi ) !bansil Nick ( bu da kalıcı ban siler )
Kod: Kodu kopyalamak için üzerine çift tıklayın!
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BADNICK.TCL
set badnick_version "2.4.4"
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2006 AzaToM - ToM@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...].MindForge.org
# - skiidoo@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...].freenode.net
# - [Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# DESCRIPTION:
# Handles the banlist ...
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# CHANGELOG:
# v1.0 - John
# Script creation
# v2.1 - ToM
# Script rewriting: all e-ops is now handled by getmodes.tcl
# Added !ListBadNickS (with an S)
# Restructured and simplified the code
# RemBadNick & AddBadNick: Added a warning if no reason is given.
# v2.2
# Made the banlist items displaying a human readable format.
# ListBadNicks is now locked only while someone is already viewing a list.
# v2.3
# !ListBans has an argument ("all" or "full") to display the banlist with details
# v2.3.1
# We now check if the mask given to !addbadnick is a valid hostmask
# Removed the BadNick:filter proc - not used anywhere...
# v2.3.2
# Fixed the last active date.
# v2.3.3
# Gives the banlist length at the beginning of !ListBadNick
# v2.4.0
# Implements some switches: --all --full --sortby=*
# Fixes the last active date being 1970...
# v2.4.1
# Uses namespaces
# --last and maximal output lines setting
# v2.4.2
# Improves the mask correction
# If the ban already exists, updates its reason
# v2.4.3
# !RemBadNick accepts several masks, and returns a complete report
# !ListBadNicks --countonly
# Added short options (-h -a -f -c -l -s)
# v2.4.4
# Improves the mask correction
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# TODO:
# - Add a way to do it in PM.. bind msg o|o blahbadnick #chan *!*@*
# - !AddBan: check if an existing ban is not already covering the given mask
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# CONFIGURATION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
namespace eval ::badnick {
# BINDS
set binds(list) "!Liste !Topluliste !Banlananlar"
set binds(add) "!Badekle !Banekle"
set binds(delete) "!Badsil !Bansil"
# Maximal length of a banlist to be sent by PM (set to 0 to unlimit)
set cfg(maxlist) 120
# Admin channel where the reports will be sent
set cfg(adminchan) "#Opers"
# Debug messages go to (leave empty to disable)...
set cfg(debug) "#Opers"
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF CONFIGURATION - Do not edit below until you know what you are doing :)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# init on rehash
set ::badnick::listbadnick 0
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# BINDING
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proc ::badnick::binding { } {
variable binds
foreach { type triggers } [array get binds] {
foreach trigger $triggers {
bind pub - $trigger ::badnick::b${type}
}
}
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# LISTBANS - LISTBADNICK
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proc ::badnick::blist { nick uhost hand chan arg } {
if { ![isop $nick $chan] && ![ishalfop $nick $chan] } { return }
variable listbadnick
if { $listbadnick != 0 } {
putserv "PRIVMSG $nick :Ban listesine şu an başkası bakıyor, birazdan tekrar deneyin."
return
}
set listbadnick [unixtime]${chan}
set banlist [banlist $chan]
set banlistlength [llength $banlist]
if { $banlistlength == 0 } {
puthelp "privmsg $nick :Belirtilen $chan İçin ban listesi boş."
set listbadnick 0
return
}
proc isdigit {string} { regexp {^[0-9]+$} $string }
# Default options
set order "date"
set fulloutput 0
set range 0
# Default output
set out(range) ""
foreach argument $arg {
switch -glob -- [string tolower $argument] {
"-h" -
"--help" {
putserv "notice $nick :Kullanım: \002$::lastbind <seçenekler>\017. Geçerli seçenekler:"
putserv "notice $nick :\002--countonly\017 : Kanal için ban listesini gösterir: $chan)"
putserv "notice $nick :\002--full\017 : Her bandaki her boşluğu belirtir --all geneldir.)"
putserv "notice $nick :\002--sortby=<key>\017 : (<key> can be \002date\017, \002rdate\017, \002lastactive\017, \002rlastactive\017. Example: \002$::lastbind --sortby=rdate\017"
putserv "notice $nick :\002--last=<num>\017 : return only <num> results. Example: \002$::lastbind --last=5\017"
return
set listbadnick 0
}
"-c" -
"--countonly" { set length [llength [banlist $chan]]
putserv "notice $nick :$chan Ban Listesi [expr { ($length == 0) ? "no" : $length }] şeklinde.."
set listbadnick 0
return
}
"-f" -
"--full" -
"-a" -
"--all" { set fulloutput 1 }
"-s=*" -
"--sortby=*" {
switch -- $argument {
"--sortby=date" { set order "date" }
"--sortby=rdate" { set order "reverse date" }
"--sortby=lastactive" { set order "last active date" }
"--sortby=rlastactive" { set order "reverse last active date" }
default {
::badnick::report "$nick!$uhost @ $chan: Unknown --sortby argument: [lindex [split $argument "="] 1]"
putserv "notice $nick :Unknown --sortby argument: [lindex [split $argument "="] 1]"
}
}
}
"-l=*" -
"--last=*" {
set range [lindex [split $argument "="] 1]
if { ! [isdigit $range] } {
puthelp "notice $nick :The --last option accepts only integer digits."
::badnick::report "$nick!$uhost @ $chan: Unknown --last argument: $range"
set range 0
}
}
default {
::badnick::report "$nick!$uhost @ $chan: Unknown argument: $argument"
putserv "notice $nick :Unknown argument: $argument"
}
}
}
# Sort the banlist
switch -- $order {
"date" { set banlist [lsort -increasing -index 3 $banlist] }
"reverse date" { set banlist [lsort -decreasing -index 3 $banlist] }
"last active date" { set banlist [lsort -increasing -index 4 $banlist] }
"reverse last active date" { set banlist [lsort -decreasing -index 4 $banlist] }
default { putlog "Bad sort option: $order" }
}
set out(order) ", sorted by $order"
set length [llength $banlist]
if { $length != $banlistlength } {
set out(length) "$length bans on $banlistlength"
} else {
set out(length) "$banlistlength bans"
}
# Limit the output if requested
# Suggest --last if the ban list is too long
variable cfg
if { $range != 0 } {
set banlist [lrange $banlist end-[expr $range -1] end]
set out(range) ", last $range bans"
} elseif { $banlistlength > $cfg(maxlist) } {
puthelp "notice $nick :Ban listesi $banlistlength banları uzun, lütfen --last eçeneğini kullanın. Örnek: $::lastbind [join $arg] --last=$cfg(maxlist)"
set listbadnick 0
return
}
set out(start) [string map [list "@length" $out(length) "@order" $out(order) "@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]ge" $out(range)] "Dahili ban listesi başlangıcı: $chan (@length@order@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]ge):"]
puthelp "PRIVMSG $nick :$out(start)"
foreach ban $banlist {
# *!*@[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...] {"some tests in progress"} 0 1166470558 0 ToM
# hostmask, comment, expiration timestamp, time added, last time active, creator
# 0 1 2 3 4 5
# ban mask
set banmask [lindex $ban 0]
# comment
set bancomment [lindex $ban 1]
# expire - not used, all are perm
# set banexpire [ctime [expr [lindex $ban 2]]]
# time added
set bantimeadded [clock format [lindex $ban 3] -format "%Y/%m/%d %H:%M"]
# time last active
if { [lindex $ban 4] == 0 } {
set banlastactive "Never"
} else {
set banlastactive [clock format [lindex $ban 4] -format "%Y/%m/%d %H:%M"]
}
# creator
set bancreator [lindex $ban 5]
if { $fulloutput == 1 } {
puthelp "PRIVMSG $nick :$chan: $banmask ($bancomment) - by $bancreator ($bantimeadded - Son aktivite: $banlastactive)"
} else {
puthelp "PRIVMSG $nick :$chan: $banmask ($bancomment) by $bancreator"
}
}
puthelp "PRIVMSG $nick :Ban listesi sonu: $chan"
set listbadnick 0
return
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ADDBAN - ADDBADNICK
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proc ::badnick::badd { nick uhost hand chan arg } {
if { ![isop $nick $chan] && ![ishalfop $nick $chan] } {
return 0
}
set victim [lindex [split $arg] 0]
if { $victim == "" } {
puthelp "PRIVMSG $chan :Lütfen bir nick/maske ve sebep belirtin."
return 0
}
set reason [join [lrange [split $arg] 1 end]];
if { $reason == "" } {
puthelp "PRIVMSG $chan :Lütfen sebep de belirtin."
return 0
}
if { [string first "!" $victim ] == -1 && [string first "@" $victim ] == -1 } {
# Turn the single nick to a complete hostmask
set banmask "$victim!*@*"
} else {
# Trying to correct the wrong masks
set banmask $victim
if { [string equal [string range $banmask 0 0] "!"] } { set banmask "*$banmask" }
if { [string equal [string range $banmask end end] "!"] } { set banmask "$banmask*@*" }
if { [string equal [string range $banmask end end] "@"] } { set banmask "$banmask*" }
set banmask [string map {"!@" "!*@"} $banmask]
}
# Final test
if { ! [regexp -- {^[^!@]+![^!@]+@[^!@]+$} $banmask] } {
puthelp "PRIVMSG $chan :Görünen o ki \002$victim\002 Geçerli bir maske değil. Şöyle kullandığınızdan emin olun: nick!ident@host gibi."
::badnick::report "!AddBan: $nick!$uhost @ $chan: Yanlış maske: ($victim): $arg"
return 0
}
# Let's add the ban now !
if { [isban $banmask $chan] } {
set out "$banmask listede zaten var. Sadece sebebi \"$reason\". şeklinde değiştirdim."
} else {
set out "$banmask eklendi: $chan ban listesi."
}
newchanban $chan $banmask $nick $reason 0 none
puthelp "NOTICE $nick :$out"
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# REMBAN - REMBADNICK
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proc ::badnick::bdelete { nick uhost hand chan arg } {
if { ! [isop $nick $chan] && ! [ishalfop $nick $chan] } {
return 0
}
if { $arg == "" } {
puthelp "NOTICE $nick :Hangi banı temizleyeceğimiz söylemelisiniz. Örneğin: \002$::lastbind --help\017"
return 0
}
if { [lindex $arg 0] == "--help" || [lindex $arg 0] == "-h" } {
puthelp "NOTICE $nick :Kullanım: \002$::lastbind <masks>\017 (Aynı anda boşluk bırakarak birden fazla mask kullanabilirsiniz.)."
return 0
}
set removed [list] ; set notfound [list] ; set missed [list]
foreach mask [lrange $arg 0 end] {
if { [string first "!" $mask ] == -1 } {
append mask "!*@*"
}
if { [killchanban $chan $mask] } {
lappend removed $mask
} elseif { [isban $mask $chan] } {
# This should never happen
lappend missed $mask
} else {
lappend notfound $mask
}
}
proc banbans { masklist } {
return [expr { ([llength $masklist] == 1) ? "Ban" : "Bans" }]
}
if { [llength $removed] } {
putserv "notice $nick :[banbans $removed] başarıyla silindi: [join $removed ", "]"
}
if { [llength $notfound] } {
putserv "notice $nick :[banbans $notfound] \002Bulunamadı\017 in the $chan ban listesinde: [join $notfound ", "]"
}
if { [llength $missed] } {
putserv "notice $nick :\002Bir \0034hata\003 oluştu: [banbans $missed]\017: [join $missed ", "] ... :("
putserv "privmsg $::badnick::cfg(adminchan) :Şu banları silerken hata oluştu: [join $missed ", "] (isteyen kişi: $nick!$uhost kanal: $chan)"
}
return
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# TOOLS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
proc ::badnick::edebug { text } {
variable cfg
if { $cfg(debug) == "" } { return }
putserv "privmsg $cfg(debug) :\00315(badnick) $text\017"
}
proc ::badnick::report { text } {
variable cfg
if { $cfg(adminchan) == "" } { return }
putserv "privmsg $cfg(adminchan) :<BadNick.tcl> $text"
}
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# INIT
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
catch ::badnick::uninstall
::badnick::binding
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NAMESPACE MANAGEMENT
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind evnt - prerehash ::badnick::uninstall
proc ::badnick::uninstall { args } {
foreach bind [binds [namespace current]::*] {
foreach {a b c d e} $bind break
unbind $a $b $c $e
}
namespace delete [namespace current]
}