|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Hello all,
I would like to create an alias that would find an ip address based on a given nickname or ip address (/findip)
Example of what's in the ini file:
Nickname1=123.123.123.123 Nickname2=123.123.123.124 Nickname3=123.123.123.125
ex 1.) findip(123.123.123.123) will return Nickname 1
ex 2.) findip(Nickname) will return 123.123.123.123
My 2nd request is to make a request to search the ini file to re-write an ip address given a nickname
Example:
/rewrite_ip Nickname1 123.456.789.100
I appreciate all your help and support in advance.
Cheers,
Jay
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
What's the name of the [topic] above the ini entries? Are you storing "nick=ip" data in different inis? What's the path to the ini(s)?
|
|
|
|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Hello Horstl
The name of the ini file is: c:\mIRC\ipinfo.ini
[info] nick=ip
Thanks a bunch
Cheers!
Jay
Last edited by Buggs2008; 03/11/08 05:54 AM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
1st request alias findip {
if !$hget(IP) { .hmake IP 100 }
if $exists(c:\mIRC\ipinfo.ini) { .hload -i IP c:\mIRC\ipinfo.ini info }
var %return = $iif($hget(IP,$1),$hget(IP,$1),$hfind(IP,$1,1).data)
$iif($isid,return,echo -a) %return
} 2nd request alias rewrite_ip {
.writeini -n c:\mIRC\ipinfo.ini info $1 $2
}
|
|
|
|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Hello Russel,
Thank you so much for the example, one question for you though
is there anyway to avoid having to load a hash table each and every time?
Thanks again
Cheers
Jay
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
You could load the hash table when mIRC starts, but then the table won't reflect any changes made to the file between runs of the alias. Of course, you could add/remove from the hash table when you add/remove from the ini file, or work with just the hash table, using the ini file only on start & on exit/disconnect.
Technically you could do it using just the ini file, but the process of searching the file would take a lot longer, especially if you hae a large ini file.
|
|
|
|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Hi Russel,
Thanks for the advice on how to speed things up.
Ok im definetly into buying using hash tables to store/retrieve items.
Would it be possible for to you then re-write the code for me simple using all tables then as apposed to having ini and hash table?
Thanks for everything in advance.
Sorry for being such a pain!
Cheers,
Jay
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
Well, you can make it manually this way if you want: menu * {
-
Load_ip_info:hmake IP 100 | hload -i IP c:\mIRC\ipinfo.ini info
Rewrite_ip:writeini -n c:\mIRC\ipinfo.ini info $?="User nick:" $?="User ip:"
Find_ip { findip $?="User nick or IP:" }
}
alias findip {
$iif($isid,return,echo -a) $iif($hget(IP,$1),$hget(IP,$1),$hfind(IP,$1,1).data)
}
on *:DISCONNECT: { hfree IP }
And actually the hash table deletes itself upon mirc being closed, too.
|
|
|
|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Thanks Tomao,
I noticed it was still using an ini file, is there anyway to get it to use just a hash table database. Is there anyway to exclusively use just a hash table?
Thanks a bunch!
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Can you provide me with the method currently being used to add the information to the ini file? Also is there anything else being stored in the ini file? If so, what is being stored, under what topics and in what format?
Unless you want to lose all of the stored information each time the bot client closes, there will have to be a file of some type used.
|
|
|
|
Joined: Oct 2007
Posts: 214
Fjord artisan
|
OP
Fjord artisan
Joined: Oct 2007
Posts: 214 |
Hello Russell,
Currently, as I am in the experimental phases of this database, I am just manually adding a bunch of examples.
No, I have it setup such that there is only 1 field and a bunch of data below it:
[info] Jason=123.123.123.789 Jeff=124.125.126.127 Jackson=789.654.321.123
ect.
Thanks a bunch.
Cheers
|
|
|
|
|