ipone wrote:The use of this script is that you can check the host of some user and see what nick that user have been using from that host.
Why not just use
bseen or
gseen and let either of them do this for you? After all this is why seen scripts were made, to handle just this very task...
!seen nickname - will give the most recent host associated with the nickname and the last time that person was online.
!seen *!*@some.host.here.com - will give the most recent nicknames associated with that host and the last time that person was online.
Code: Select all
set findnick [lsearch -glob [split [string tolower $nicklist]] *$nick*]
set finduhost [lsearch -glob [split [string tolower $uhostlist]] *uhost*]
Also, this part of your code is flawed. You use [string tolower] on a list, then you split the list into a list?? Perhaps you meant to do it the way I have below?
Code: Select all
set findnick [lsearch -exact [split [string tolower [join $nicklist]]] [string tolower $nick]]
set finduhost [lsearch -exact [split [string tolower [join $uhostlist]]] [string tolower $uhost]]
Notice I've used a join to turn the list into a string, which allows us to use the string command string tolower. Then we split the newly created string back into a list so lsearch can process it. This is how you should do it. Realize as well that you may need to test for -1 on both findnick and finduhost as that is the result of a negative lsearch (result not found). Also changed your glob wildcard search into an exact search because of the flaw explained below occuring here as well.
Also, while we are on the subject of flaws, you might want to change this approach.
Code: Select all
foreach user $nicklist {
if {[string match -nocase "*$user*" $nick]} {
set nickfound 1; break
}
}
You are string matching using wildcards which is bad. This means if someone has the nickname GGD they will match for the nickname EGGDROP as well. This is likely not what you had in mind. Perhaps the code below is better.
Code: Select all
foreach user $nicklist {
if {[string equal -nocase $user $nick]} {
set nickfound 1; break
}
}
And finally, how exactly is this supposed to work?
Code: Select all
set nicklist [list]
foreach entry $data {
lappend nicklist [lindex [split $entry :] 0]
}
set uhostlist [list]
foreach entry $data {
lappend uhostlist [lindex [split $entry :] 1]
}
You realize you haven't opened the file for reading right? You haven't stored the file into a variable you can process. Literally what happens when eggdrop executes this, is that foreach will run only once because there is only one entry in $data that being "nicklist.txt". Entry will become "nicklist.txt". Then you attempt to split entry and lindex position 0 for nicklist, and position 1 for uhostlist using a colon as a delineator. Suffice it to say nicklist will always be literally "nicklist.txt" and uhostlist will be an empty null. The problem there is explained below, space vs colon. But for now what you need to do is open and read the file into a variable as I have done below.
Code: Select all
set file [open $data r]
set text [split [read $file] \n]
close $file
You would then use $text to build your nick and uhost lists exactly as your doing which will now be based on contents of the file, not on the contents of the filename..
Now, just for sake of being complete here comes that issue of spaces vs colons:
The problem is your splitting on colon (:
) not on space ( ). If you want the split to work you will need to change that to this:
Or you can simply remove those colons from the split as I have below:
Code: Select all
set nicklist [list]
foreach entry $data {
lappend nicklist [lindex [split $entry] 0]
}
set uhostlist [list]
foreach entry $data {
lappend uhostlist [lindex [split $entry] 1]
}
I realize this is alot for you to take in and possibly confusing as hell to anyone new to tcl. But afterall, this was posted in the scripting help section and hopefully some of what I've written helps..
One tiny little little detail I completely overlooked so here it is at the bottom. go figure..haha
Code: Select all
proc join_onjoin {nick uhost hand chan} {
global data
set filename $data
set txt [open $filename "a"]
puts $txt "$nick $uhost"
close $txt
}
You've ended the procedure prematurely and left the rest of the code hanging in global space which runs once invoked at script load or rehash/restart. That part of the code won't be invoked by a bind to your join_onjoin procedure. You also have one too many bracings. The one happening after "close $txt" should be removed. Your also appending the file before you have tested to see if the nick is already contained within it. You will definitely need to relocate that part a little bit further down in the code.