mIRC Home    About    Download    Register    News    Help

Topic Options
#205906 - 03/11/08 02:02 AM INI File Question
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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

Top
#205911 - 03/11/08 02:47 AM Re: INI File Question [Re: Buggs2008]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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)?

Top
#205920 - 03/11/08 05:53 AM Re: INI File Question [Re: Buggs2008]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
Posts: 214
Hello Horstl

The name of the ini file is: c:\mIRC\ipinfo.ini

[info]
nick=ip

Thanks a bunch

Cheers!

Jay


Edited by Buggs2008 (03/11/08 05:54 AM)

Top
#205922 - 03/11/08 06:41 AM Re: INI File Question [Re: Buggs2008]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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
}

Top
#205930 - 03/11/08 01:53 PM Re: INI File Question [Re: RusselB]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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

Top
#205933 - 03/11/08 04:40 PM Re: INI File Question [Re: Buggs2008]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#205934 - 03/11/08 05:36 PM Re: INI File Question [Re: Buggs2008]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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

Top
#205935 - 03/11/08 06:07 PM Re: INI File Question [Re: Buggs2008]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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.

Top
#205942 - 03/11/08 08:49 PM Re: INI File Question [Re: Buggs2008]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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!

Top
#205950 - 03/11/08 11:20 PM Re: INI File Question [Re: Buggs2008]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#205958 - 04/11/08 12:26 AM Re: INI File Question [Re: RusselB]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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

Top