# irc_guard.tcl - IRC Koruma Botu
set guard_active 1
set ctcp_block 1
set proxy_list "data/proxy.txt"
set admins {admin1 admin2}
set log_file "data/security.log"
bind pub - !guard toggle_guard
bind pub - !ctcpkoruma toggle_ctcp
bind ctcp - VERSION block_ctcp
bind ctcp - FINGER block_ctcp
bind ctcp - USERINFO block_ctcp
bind join - * check_massjoin
bind msg - * check_kufur
proc toggle_guard {nick uhost hand chan arg} {
global guard_active admins
if {[lsearch -exact $admins $hand] != -1} {
set guard_active [expr {!$guard_active}]
putquick "PRIVMSG $chan :[expr {$guard_active ? "Koruma aktif" : "Koruma kapalı"}]"
}
}
proc toggle_ctcp {nick uhost hand chan arg} {
global ctcp_block admins
if {[lsearch -exact $admins $hand] != -1} {
set ctcp_block [expr {!$ctcp_block}]
putquick "PRIVMSG $chan :[expr {$ctcp_block ? "CTCP Koruma açık" : "Kapalı"}]"
}
}
proc block_ctcp {nick uhost hand dest keyword text} {
global ctcp_block log_file
if {$ctcp_block} {
set ip [lindex [split $uhost @] 1]
putquick "PRIVMSG $nick :CTCP istekleri engellenmiştir."
write_log "CTCP BLOCK: $nick ($ip) -> $keyword"
return 1
}
return 0
}
proc check_massjoin {nick uhost hand chan} {
global guard_active
if {!$guard_active} { return }
set host [lindex [split $uhost @] 1]
set count [llength [chanlist $chan $host]]
if {$count > 5} {
putquick "KILL $nick :Mass Join Koruması"
write_log "MASS JOIN: $nick @ $host"
}
}
proc check_kufur {nick uhost hand text} {
set kufurler {salak aptal orospu amk aq}
foreach kelime $kufurler {
if {[string match -nocase *$kelime* $text]} {
putquick "PRIVMSG $nick :Küfür tespit edildi, uzaklaştırılıyorsunuz."
putquick "KILL $nick :Küfür yasak!"
write_log "KÜFÜR: $nick -> $text"
return
}
}
}
proc write_log {text} {
global log_file
set now [clock format [clock seconds] -format "%Y-%m-%d %H:%M"]
set fp [open $log_file a]
puts $fp "$now - $text"
close $fp
}
bind evnt - init-server check_proxy_on_connect
proc check_proxy_on_connect {type} {
global proxy_list
foreach user [users] {
set host [getchanhost $user]
set ip [lindex [split $host @] 1]
if {[file exists $proxy_list]} {
set data [readfile $proxy_list]
foreach line $data {
if {[string match *$ip* $line]} {
putquick "KILL $user :Proxy bağlantı engellendi"
write_log "PROXY BLOCK: $user -> $ip"
putserv "PRIVMSG OperServ :AKILL ADD $ip 30m Proxy Engeli"
}
}
}
}
}
proc readfile {filename} {
set f [open $filename r]
set lines [split [read $f] "\n"]
close $f
return $lines
}