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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Rapfnny
Voice
Posts: 8 Joined: Sat May 16, 2009 8:31 pm
Location: irc.Bob-Omb.net
Contact:
Post
by Rapfnny » Thu May 21, 2009 2:02 pm
Never mind I decided to finish it. Here's what i need help on next:
I decided to make it go by nicks. I wan't the nick to be removed from nicklog.db if it is kicked from the channel heres my current code which isn't working.
Code: Select all
bind kick - "#DontJoinItsATrap" unlog
proc unlog {nick uhost hand chan reason} {
set input [open nicklog.db]
set output [open nicklog.tmp w]
while {[gets $input line] >= 0} { if {[lsearch $line [string tolower $nick]] < 0} { puts $output $line } }
close $input
close $output
file rename -force nicklog.tmp nicklog.db
putserv "NOTICE $nick You have escaped ^_^"
}
It doesnt do anything at all when i kick someone.
Last edited by
Rapfnny on Sat May 23, 2009 10:35 pm, edited 3 times in total.
tomekk
Master
Posts: 255 Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:
Post
by tomekk » Thu May 21, 2009 2:09 pm
Rapfnny wrote: Here's my script:
[13:53] Tcl error [userip]: wrong # args: should be "userip nick uhost hand channel txt"
When its already there. >:\
What can I do to fix this?
from tcl-commands.txt:
(8) JOIN (stackable)
bind join <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel>
Description: triggered by someone joining the channel. The mask in
the bind is matched against "#channel nick!user@host" and can
contain wildcards.
Module: irc
change
Code: Select all
proc userip { nick uhost hand channel txt } {
to
Code: Select all
proc userip { nick uhost hand channel } {
Rapfnny
Voice
Posts: 8 Joined: Sat May 16, 2009 8:31 pm
Location: irc.Bob-Omb.net
Contact:
Post
by Rapfnny » Thu May 21, 2009 2:47 pm
Thanks! I edited the script and it works fine now. Here's the next thing i need help with.
Code: Select all
proc logip {ip} {
set file [open iplog.txt a+]
if {$ip != "0.0.0.0"} {
puts $file "$ip"
}
close $file
}
But I would like to know how I can make it search if $ip exists in the file, and if it does, it doesnt write $ip to the file twice.
Papillon
Owner
Posts: 724 Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no
Post
by Papillon » Thu May 21, 2009 5:19 pm
try something like this
Code: Select all
proc logip {ip} {
set file [open iplog.txt a+]
set info [split [read $file] \n]]
if {$ip != "0.0.0.0" && [string equal [lsearch -exact $info $ip] "-1"]} {
puts $file "$ip"
}
close $file
}
Elen sila lúmenn' omentielvo
tomekk
Master
Posts: 255 Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:
Post
by tomekk » Thu May 21, 2009 5:29 pm
try:
Code: Select all
proc logip {ip} {
if {$ip == "0.0.0.0"} {
return
}
set db_get [open iplog.txt r]
set all_ips [split [read $db_get] "\n"]
close $db_get
if {[lsearch $all_ips $ip] != -1} {
return
}
set file [open iplog.txt a+]
puts $file "$ip"
close $file
}
or, if want with "a+" without extra file reading:
Code: Select all
proc logip {ip} {
if {$ip == "0.0.0.0"} {
return
}
set file [open iplog.txt a+]
seek $file 0
set all_ips [split [read $file] "\n"]
if {[lsearch $all_ips $ip] != -1} {
close $file
return
}
seek $file 0 end
puts $file "$ip"
close $file
}