mIRC Home    About    Download    Register    News    Help

Print Thread
INI File Question #205906 03/11/08 02:02 AM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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

Re: INI File Question [Re: Buggs2008] #205911 03/11/08 02:47 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
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)?

Re: INI File Question [Re: Buggs2008] #205920 03/11/08 05:53 AM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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.
Re: INI File Question [Re: Buggs2008] #205922 03/11/08 06:41 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
1st request
Code:
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
Code:
alias rewrite_ip {
  .writeini -n c:\mIRC\ipinfo.ini info $1 $2
}

Re: INI File Question [Re: RusselB] #205930 03/11/08 01:53 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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

Re: INI File Question [Re: Buggs2008] #205933 03/11/08 04:40 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
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.

Re: INI File Question [Re: Buggs2008] #205934 03/11/08 05:36 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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

Re: INI File Question [Re: Buggs2008] #205935 03/11/08 06:07 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Well, you can make it manually this way if you want:

Code:
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.

Re: INI File Question [Re: Buggs2008] #205942 03/11/08 08:49 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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!

Re: INI File Question [Re: Buggs2008] #205950 03/11/08 11:20 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
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.

Re: INI File Question [Re: RusselB] #205958 04/11/08 12:26 AM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
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