Code: Select all
# finger.tcl
# arfer <DALnet #Atlantis>
### ----------------------------------------------------------------------- ###
### -------------------- operation ---------------------------------------- ###
# finger.tcl will ban users joining a bot channel that do not reply to a ..
# .. /ctcp FINGER within a preconfigured time
### ----------------------------------------------------------------------- ###
### -------------------- installation ------------------------------------- ###
# 1. configure finger.tcl in a suitable text editor
# 2. put the configured finger.tcl in the bot's scripts subdirectory
# 3. add a line to the end of the bot's .conf file 'source scripts/finger.tcl'
# 4. restart the bot
# 5. requires '.chanset #channelname +finger' in the partyline for each chan ..
# .. you want the script to function on
### ----------------------------------------------------------------------- ###
### -------------------- changelog ---------------------------------------- ###
# 1.0 beta release
### ----------------------------------------------------------------------- ###
### -------------------- configuration ------------------------------------ ###
# set here the time allowed in seconds for a /ctcp finger response
# after this time, if there is no response, the user will be banned
# ensure this is long enough to allow for moderate lag
set vFingerReplyTime 20
# set here the bot user flag(s) exempt from bans by this script
set vFingerExempt fo
# set here the banmask to use
# allowed values are as follows
# 1 nick!*user@host
# 2 nick!*@host
# 3 *!*user@host
# 4 *!*@host
# 5 nick!*user@hostmask
# 6 nick!*@hostmask
# 7 *!*user@hostmask
# 8 *!*@hostmask
# 9 nick!*user@*
# 10 nick!*@*
# 11 *!*user@*
set vFingerBanMask 6
# set here the time in minutes a ban should last
set vFingerBanTime 10
### ----------------------------------------------------------------------- ###
### -------------------- code (DO NOT EDIT) ------------------------------- ###
setudef flag finger
set vFingerVersion 1.0
bind CTCR - FINGER pFingerResponse
bind JOIN - * pFingerJoin
proc pFingerBan {nick uhost chan} {
global vFingerBanMask vFingerBanTime
if {[botisop $chan]} {
if {[onchan $nick $chan]} {
set banmask [pFingerBanMask $nick $uhost $vFingerBanMask]
putquick "MODE $chan +b $banmask"
putkick $chan $nick "no /CTCP FINGER reply"
timer $vFingerBanTime [list putquick "MODE $chan -b $banmask"]
}
}
return 0
}
proc pFingerBanMask {nick uhost type} {
scan $uhost {%[^@]@%s} user host
set user [string trimleft $user ~]
switch -- [regexp -- {^([0-9]{1,3}\.){3}[0-9]{1,3}$} $host] {
0 {
switch -- [regexp -all -- {\.} $host] {
0 - 1 {set hostmask $host}
2 {set hostmask *.[join [lrange [split $host .] 1 end] .]}
default {set hostmask *.[join [lrange [split $host .] 2 end] .]}
}
}
1 {set hostmask [join [lrange [split $host .] 0 end-1] .].*}
default {}
}
switch -- $type {
1 {set mask ${nick}!*${user}@$host}
2 {set mask ${nick}!*@$host}
3 {set mask *!*${user}@$host}
4 {set mask *!*@$host}
5 {set mask ${nick}!*${user}@$hostmask}
6 {set mask ${nick}!*@$hostmask}
7 {set mask *!*${user}@$hostmask}
8 {set mask *!*@$hostmask}
9 {set mask ${nick}!*${user}@*}
10 {set mask ${nick}!*@*}
11 {set mask *!*${user}@*}
default {}
}
return $mask
}
proc pFingerCancel {nick uhost} {
global vFingerID
if {[info exists vFingerID($nick)]} {
unset vFingerID($nick)
foreach chan [channels] {
if {[channel get $chan finger]} {
pFingerBan $nick $uhost $chan
}
}
}
return 0
}
proc pFingerJoin {nick uhost hand chan} {
global vFingerReplyTime vFingerID vFingerExempt
if {[channel get $chan finger]} {
if {![isbotnick $nick]} {
if {![matchattr $hand $vFingerExempt $chan]} {
if {![info exists vfingerID($nick)]} {
set vFingerID($nick) 0
putquick "PRIVMSG $nick :\001FINGER\001"
utimer $vFingerReplyTime [list pFingerCancel $nick $uhost]
}
}
}
}
return 0
}
proc pFingerResponse {nick uhost hand dest keyword text} {
global vFingerID
if {[info exists vFingerID($nick)]} {
unset vFingerID($nick)
}
return 0
}
putlog "finger.tcl version $vFingerVersion by arfer loaded"
# eof