ctcpfinger.tcl

ctcpfinger.tcl

This script send a CTCP FINGER reply to the person who requested it. This script shows the actual idle time of the bot in the reply. Note: Don't use other scripts that answer to CTCP FINGER with this script. Tested on eggdrop1.4.0 with TCL 7.6

Postat de Copyright Categorie Review user Vizualizari Data
btc Teemu Hjelt protections Cod netestat 383 2023-12-25 00:18:05

# ctcpfinger.tcl v1.02 [4 December 1999]
# Copyright © 1999 Teemu Hjelt <temex@iki.fi>
#
# Latest version can be found from http://www.iki.fi/temex/tcls/
# 
# If you have any suggestions, questions or you want to report 
# bugs, please feel free to send me email to temex@iki.fi
#
# This script send a CTCP FINGER reply to the person
# who requested it. This script shows the actual idle
# time of the bot in the reply.
#
# Note: Don't use other scripts that answer to CTCP FINGER with this script.
#
# Tested on eggdrop1.4.0 with TCL 7.6
#
# Version history:
# v1.00 - The very first version!
# v1.01 - Fixed few very little bugs.
# v1.02 - Removed few useless things.

### General Settings ###

## Do you want to use your own e-mail in the finger-reply?
# Note: If you don't want to use your own e-mail then leave this empty. 
set cf_email ""

### Flood Protection Settings ###

## [0/1] Do you want to enable the flood protection?
# Note: This only protects your bot from CTCP FINGER flood.
set cf_fludprot 1

## Answer to how many CTCP FINGERS...
set cf_maxctcps 2

## ...in how many seconds?
set cf_maxtime 40

## [0/1] Do you want to ignore the flooder?
set cf_ignore 0

## How long do you want to ignore the flooder (min)?
set cf_ignoretime 10

## The users with the following global flags shouldn't be ignored.
# Note: Leave this empty if you want to ignore everybody.
set cf_globflags "m n o"

## The users with the following channel flags shouldn't be ignored.
# Note: Leave this empty if you want to ignore everybody.
set cf_chanflags "m n"

###### You don't need to edit below this ######

### Misc Things ###

set cf_ver "1.02"

### Bindings ###

bind ctcp - FINGER ctcp:cf_finger

### Main Procs ###

proc ctcp:cf_finger {nick uhost hand dest key arg} {
global botnick ctcp-finger 
global cf_nick cf_email cf_fludprot cf_maxctcps cf_maxtime cf_ctcpcount cf_blocking cf_ignore cf_ignoretime cf_globflags cf_chanflags
set hostmask "*!*[string range $uhost [string first "@" $uhost] end]"
	if {$cf_fludprot} {
		if {![info exists cf_ctcpcount]} { set cf_ctcpcount 0 }
		if {![info exists cf_blocking]} { set cf_blocking 0 }
		incr cf_ctcpcount 
		if {![string match *cf_decrflud* [utimers]]} { utimer $cf_maxtime cf_decrflud }
		if {$cf_ctcpcount > $cf_maxctcps} {
			if {$cf_ctcpcount == [expr $cf_maxctcps +1]} { 
				putlog "CTCPFinger: Blocking CTCP FINGERS for $cf_maxtime seconds." 
				cf_ktimer 
				utimer $cf_maxtime cf_decrflud
				set cf_blocking 1
			}
			if {$cf_ignore} { 
				if {$cf_globflags != ""} {
					foreach globflag $cf_globflags {
						if {[matchattr $hand $globflag]} {
							return 1
						}
					}
				}
				if {$cf_chanflags != ""} {
					foreach chan [channels] {
						foreach chanflag $cf_chanflags {
							if {[matchattr $hand |$chanflag $chan]} {
								return 1
							}
						}
					}
				}
				if {![isignore $hostmask]} { 
					newignore $hostmask $botnick "CTCP-$key flood" $cf_ignoretime 
					putlog "CTCPFinger: Ignoring $hostmask for CTCP-$key flood for $cf_ignoretime mins."
				}
			}
			return 1
		}
	}
	set cf_nick $nick
	bind raw - 317 raw:cf_317
	putserv "WHOIS $botnick"
	if {${ctcp-finger} == ""} { 
		return 0 
	} else { 
		return 1 
	} 
}

proc raw:cf_317 {from key arg} {
global realname username 
global cf_nick cf_email
set idletime [lindex $arg 2] 
	if {$cf_email == ""} {
		if {[catch {exec whoami} user]} { set user $username }
		if {[catch {exec hostname} host]} { set host [info hostname] }
		putserv "NOTICE $cf_nick :\001FINGER $realname ($user@$host) Idle $idletime seconds\001" 
	} else {
		putserv "NOTICE $cf_nick :\001FINGER $realname ($cf_email) Idle $idletime seconds\001"
	}
	unbind raw - 317 raw:cf_317
}

### Other Procs ###

proc cf_decrflud { } { 
global cf_ctcpcount cf_blocking
	if {$cf_ctcpcount > 0} {
		set cf_ctcpcount 0
		if {$cf_blocking} { 
			putlog "CTCPFinger: No longer blocking CTCP FINGERS." 
			set cf_blocking 0
		}
	} 
}

proc cf_ktimer { } {
	foreach utimer [utimers] {
		if {[string match *cf_decrflud* $utimer]} { 
			killutimer [lindex $utimer 2]
		}
	}
}

### End ###

putlog "TCL loaded: ctcpfinger.tcl v$cf_ver by Sup <temex@iki.fi>"
if {$cf_fludprot} { 
	putlog "   - Flood Protection: enabled. (Answering to $cf_maxctcps ctcps in $cf_maxtime seconds)" 
} else {
	putlog "   - Flood Protection: disabled." 
}