mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2004
Posts: 2,019
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

i have been working on a trivia bot lately, and I found on this msgboard a solution by qwerty, where you can save the hash table with statistics to file, then use the /filter command on it to sort the items.

The hash table is like this:
item:nickname
data: user statistics pasted together by an equal sign
(necessary to perform the filter command)

Now this worx perfectly but I have only now noticed the following:

Suppose there is a nickname called [John]-Doe,
well u can add that nickname to the hash table, everything still ok. However, if u save the stats file to file using:

/hsave -i stats statistics.txt

and u open up the .txt file, it seems that the nickname has changed to ~John~-Doe.
In other words the [ ] have been replaced with ~~

If u do /hsave stats statistics.txt, then the hash table isnt saved as an ini file, and then the nickname remains unchanged. Unfortunately the hash table can only be sorted if the file is saved as an ini file.

Now i take it, that the reason for this is, that mirc might confuse [John] with a section, so it changes those signs to ~~ for ambiguity reasons.

My question to any of u willing to answer me is:

what would be the best (read: fastest) way to go around this.

Because it would be way too slow if i have to save the stats hash table line by line into a txt file, changing the [ ] signs into a temporarily other sign like $chr(255), then doing the sort, and then line by line change $chr(255) again to [ ] and put out the information.

Is there any other (way more efficient way)??

Help is greatly appreciated!

Last edited by FiberOPtics; 20/03/04 01:19 AM.

Gone.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I would change the method of making items out of nicks; instead of using plain $nick, I'd use
/hadd <table> $replace($encode($nick,m),=,.) <data>. Then, the saved .ini would look like

dGVzdFtuaWNrXQ..=3
YW5vdGhlcnRlc3Rbbmlja10.=5
....

To get the nick back, just use $decode($replace(<item>,.,=),m)

The $replace()'s are necessary because a MIME-encode string often contains "=" characters, which would conflict with the ini = (separator between item and data). It can never contain a dot or any other non-alphanumeric character though, thus will never cause problems in .inis.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2004
Posts: 2,019
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Thanks a lot!

When putting them into 2 lil custom identifiers, like

alias h.enc return $replace($encode($1,m),=,.)
alias h.dec return $decode($replace($1,.,=),m)

it is easy to change my script without too much hassle,

Arigatou


Gone.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Quote:
$replace($encode($nick,m),=,.)

Or just $remove() them smile
I've never had problems $decoding MIME-encoded strings with those ='s omitted. Maybe they are just redundant...

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It appears you're right and, as you suggested last night, they may be added just to make the string length a multiple of 4 smile


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard