Code: Select all
set socksfile "socks.txt"
set socksreason "Don't use socks!"
set socksbantime 1440
bind join * * sock:check
proc sock:check {nick uhost handle channel} {
set file [open "$::socksfile" r]
if {![file exists $::socksfile]} {
putlog "\002Error\002: $::socksfile dose not exist!"
return 0
}
while {![eof $file]} {
set text [split [read $file] "\n"]
if {![string match "[lindex [split $uhost @] 1]" [split $text]]} { return }
set mask "*!*@[lindex [split $uhost @] 1]"
newchanban $channel $mask Socks "$::socksreason" $::socksbantime
}
}
Code: Select all
set socksfile "socks.txt"
set socksreason "Don't use socks!"
set socksbantime 1440
bind join * * sock:check
proc sock:check {nick uhost handle channel} {
if {![botisop $channel]} { return }
if {![file exists $::socksfile]} {
putlog "\002Error\002: $::socksfile dose not exist!"
return 0
}
set file [open "$::socksfile" r]
while {![eof $file]} {
set lines [split [read $file] "\n"]
foreach line $lines {
if {$line == "" || ![string match "[lindex [split $uhost @] 1]" $line]} { continue }
set mask "*!*@[lindex [split $uhost @] 1]"
newchanban $channel $mask Socks "$::socksreason" $::socksbantime
break
}
}
}
Code: Select all
bind msg m socks msg:socks
proc msg:socks {nick host hand text} {
if {![file exists $::socksfile]} {
putserv "PRIVMSG $nick :\002Error\002: $::socksfile dose not exist!"
return 0
}
if {[llength $text] <1} {
putserv "PRIVMSG $nick :\002Usage\002: socks <add|del|check> <socks>"
return 0
}
switch -- [string tolower [lindex $text 0]] {
"add" {
if {[lindex $text 1] == ""} {
putserv "PRIVMSG $nick :\002Usage\002: socks <add> <socks>"
return 0
}
set sock "[lindex $text 1]"
set file [open "$::socksfile" r]
while {![eof $file]} {
set line [gets $file]
if {[string match [lindex $text 1] $line]} {
putserv "PRIVMSG $nick :'$sock' socks is already in the list."
return 0
}
}
catch {close $file}
set file [open "$::socksfile" a]
puts $file $sock
putserv "PRIVMSG $nick :Socks '$sock' was added to the list."
catch {close $file}
}
"del" {
if {[lindex $text 1] == ""} {
putserv "PRIVMSG $nick :\002Usage\002: socks <del> <socks>"
return 0
}
set found 0
set index ""
set sock "[lindex $text 1]"
set file [open $::socksfile r]
while {![eof $file]} {
set lines [split [read $file] "\n"]
foreach line $lines {
if {$line == ""} { continue }
if {$line == $sock} {
set found 1
} else { lappend index $line }
}
if {$found == 0} {
putserv "PRIVMSG $nick :'$sock' was not found in the list."
return }
}
catch {close $file}
set file [open $::socksfile w]
foreach line $index {
puts $file $line
}
catch {close $file}
putserv "PRIVMSG $nick :Socks '$sock' was removed."
}
"check" {
if {[lindex $text 1] == ""} {
putserv "PRIVMSG $nick :\002Usage\002: socks <check> <socks>"
return 0
}
set sock "[lindex $text 1]"
set file [open "$::socksfile" r]
while {![eof $file]} {
set line [gets $file]
if {[string match [lindex $text 1] $line]} {
putserv "PRIVMSG $nick :Socks '$sock' was found in the list."
return 0
}
}
catch {close $file}
putserv "PRIVMSG $nick :Socks '$sock' was not found in the list."
}
}
}
Code: Select all
bind join * * sock:check
proc sock:check {nick uhost handle channel} {
utimer 2 "sock:ban $nick $uhost $channel"
}
proc sock:ban {nick uhost channel} {
if {![botisop $channel]} { return }
if {![file exists $::socksfile]} {
putlog "\002Error\002: $::socksfile dose not exist!"
return 0
}
set file [open "$::socksfile" r]
while {![eof $file]} {
set lines [split [read $file] "\n"]
foreach line $lines {
if {$line == "" || ![string match "[lindex [split $uhost @] 1]" $line]} { continue }
set mask "*!*@[lindex [split $uhost @] 1]"
if {[ischanban $mask $channel]} { return }
newchanban $channel $mask Socks "$::socksreason" $::socksbantime
break
}
}
}