This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Catching IPs from text file

Help for those learning Tcl or writing their own scripts.
Post Reply
k
krouser
Voice
Posts: 4
Joined: Wed May 08, 2013 6:46 am

Catching IPs from text file

Post by krouser »

Hi guys, can someone show me if it is possible to catch/match IPs that were previously saved on a .txt file and trigger a ban on that IP for a certain amount of time?

Thanks in advance! :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

bind join * * ip:check

proc ip:check {nick uhost hand chan} {
	if {[isbotnick $nick] || [validuser $hand]} return
	set ip [lindex [split $uhost "@"] 1]
	set fh [open "ips.txt"]
	while {[gets $fh line] >= 0} {
		if {[string equal -nocase $line $ip]} {
		incr match
			break
		}
	}
	close $fh
	if {[info exists match]} {
		pushmode $chan +b $ip
	}
}
this would work for all channels the bot is on, but if you wish to make it work just on a single channel and you won't change your mind any time soon then change:

Code: Select all

bind join * * ip:check
to:

Code: Select all

bind join "#mychan *" * ip:check
Edit: typo.
Last edited by caesar on Wed May 08, 2013 9:20 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

The ability to store bans is built in Eggdrop. Won't this do it?

http://www.egghelp.org/commands/channels.htm#+ban
k
krouser
Voice
Posts: 4
Joined: Wed May 08, 2013 6:46 am

Post by krouser »

thanks a lot caesar! im lookin forward to try it out.. and you are right willyw it would but I need to check exactly how this whole .txt string matching thing works.. still learning here :)
Post Reply