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.

Doing a whois to print out to a file

Help for those learning Tcl or writing their own scripts.
Post Reply
f
fayettemat
Voice
Posts: 27
Joined: Tue Jan 09, 2007 6:10 pm

Doing a whois to print out to a file

Post by fayettemat »

ok here's the break down: I have an Eggdrop that I use for a protection bot and convince bot, it is Opered so I am not worried about it flooding but I cannot get the dumb bot to send the text I want to a file

Code: Select all

 bind JOIN - * whois:nick
proc whois:nick { nick  uhost hand chan arguments } 
	{
	set target == "$nick"
	putquick "WHOIS $target $target" -next
	bind RAW - 401 whois:nosuch
	bind RAW - 311 whois:info
	}
proc whois:nosuch { from keyword arguments } 
	{
	putquick "There is so such nick name!"
	#unbind the raw#
	unbind RAW - 401 whois:nosuch
	}
proc whois:info { from keyword arguments }
	{
		set chan $chan
		set nick $nick
		set ident [lindex [split $arguments] 2]
		set host [lindex [spllit $arguments] 3]
		set realname [string range [join [lrange $arguements 5 end]] 1 end]
		#unbind The Raw#
		unbind RAW - 311 whois:info
		#saving to a file#
		set line_to_add "$nick\!$ident\@$host * $realname"
		set fname "testfile.txt"
		set fp [open $fname "a"]
		puts $fp $line_to_add
		close $fp
		#end saving to a file#
	}
#thanks to egghelp.org for the writting to file learning and MeTroiD for his #whois script I used both in an attempt to make this script!#
putlog "Whois on join ver 1.0b1"
as you can see what I am trying to do is to have it automatic in saving the users host upon joining, the reason I use this is because when I get complaints about spam from certian nicks I want to be able to have their full host and /whois <nick> only lasts for about 24 hrs
ps: it wont load lately
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

What's the problem you're facing?
User avatar
et109
Voice
Posts: 7
Joined: Sun Feb 25, 2007 9:47 am
Location: Pennsylavnia

whois info

Post by et109 »

if the code you are using is a match to this code, you have a typo in proc whois:info

Code: Select all

      set host [lindex [spllit $arguments] 3]
should be

Code: Select all

      set host [lindex [split $arguments] 3]
f
fayettemat
Voice
Posts: 27
Joined: Tue Jan 09, 2007 6:10 pm

Post by fayettemat »

ok I'll try that Et and Sir_Fz the problem is that its not writing to a file and now it says that my code is invalid and I looked at that and I'm going to try again will edit post with results: wish me luck!
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You might want to also catch your unbinds, otherwise the bot could crash if it tries to unbind something that's not already bound:

catch {unbind RAW - 401 whois:nosuch}
f
fayettemat
Voice
Posts: 27
Joined: Tue Jan 09, 2007 6:10 pm

Post by fayettemat »

rosc2112 wrote:You might want to also catch your unbinds, otherwise the bot could crash if it tries to unbind something that's not already bound:

catch {unbind RAW - 401 whois:nosuch}
so I would just catch {unbind RAW - 401 whois:nosuch} at the end of the file?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Not at the end. In the same place as the original unbind, just enclose it with catch {} so it doesn't crash the bot.

http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm
f
fayettemat
Voice
Posts: 27
Joined: Tue Jan 09, 2007 6:10 pm

Post by fayettemat »

if I bound this to a pubm bind and striped the colors and codes it would be a handy ban script wouldnt it? (the bots a server admin)
Post Reply