mIRC Home    About    Download    Register    News    Help

Print Thread
#130386 17/09/05 07:29 AM
Joined: Apr 2005
Posts: 53
A
Babel fish
OP Offline
Babel fish
A
Joined: Apr 2005
Posts: 53
i need a script to resolve webchat IPs. Something like that:

I tipe !hex2dec c14d9486
and the bot answers: hex2dec: c14d9486 = 193.77.148.134

thanks smile

#130387 17/09/05 07:52 AM
Joined: Dec 2002
Posts: 83
D
Babel fish
Offline
Babel fish
D
Joined: Dec 2002
Posts: 83
You don't search a lot and we are not a scripter for you.

I find a text to explain how convert dec to hex. So, with reflexion, you can make in other sense.

Example 3: Primenet identifies its outgoing email server by the name: smtp.primenet.com, and by
the decimal IP address: 206.165.6.132. Convert the decimal address 206.165.6.132 to its
hexadecimal equivalent.
Treat each set of digits delimited by decimal points as a unique 3 digit decimal number. Convert each 3
digit decimal number into an equivalent 2 digit hexadecimal number.
Use the decimal to hexadecimal algorithm above to convert 206 decimal to its hexadecimal equivalent.
Step 1: 206/16=12.875. Keep the whole number, 12, and ignore the remainder.
Step 2: Convert decimal 12 to hexadecimal using Table 1.
DEC: 12
HEX: C
Step 3: 12x16=192.
Step 4: 206-192=14.
Step 5: Convert decimal 14 to hexadecimal using Table 1.
DEC: 14
HEX: E
The equivalent hexadecimal is CE.
Using the same procedure defined above, the remaining segments of the email address are converted as
follows:
DEC: 165
HEX: A5
DEC: 6
HEX: 06
DEC: 132
HEX: 84
The equivalent hexadecimal address is CE.A5.06.84.

#130388 17/09/05 09:17 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Assuming you want it to work in queries (private messages) only the code would be:

Code:
on *:text:!hex2dec &:?:msg $nick hex2dec: $2 = $longip($base($2,16,10))


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#130389 17/09/05 10:23 AM
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Syntax: $dec2hex(ip) or $hex2dec(ip)
dec2hex will return period denominated hex, $remove($dec2hex(ip)) can be used to return hex without periods. hex2dec will detect if periods are in the hex and return correctly for both

Code:
alias dec2hex {
  if (!$1) return
  else return $+($base($gettok($1,1,46),10,16,2),.,$base($gettok($1,2,46),10,16,2),.,$base($gettok($1,3,46),10,16,2),.,$base($gettok($1,4,46),10,16,2))
}
alias hex2dec {
  if (!$1) return
  return $iif($len($2) == 8, $longip($base($1,16,10)), $longip($base($remove($1,.),16,10)))
}


Sample triggers

Code:
on *:TEXT:!d2h *:# {
  if (!$2) msg # Syntax: !d2h <decip>
  else msg # Dec2Hex: $2 <> $dec2hex($2)
}
on *:TEXT:!h2d *:# {
  if (!$2) msg # Syntax: !h2d <hexip>
  else msg # Hex2Dex: $2 <> $hex2dec($2)
}


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
#130390 19/09/05 10:43 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Here's an alternative to your dec2hex code:

Code:
alias dec2hex { 
  tokenize 46 $$1
  scon -r var $(%a = %a,) $!base( $* ,10,16,2)
  return $replace(%a,$chr(32),.)
}


Gone.
#130391 22/09/05 01:34 PM
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Could you explain how that works, i understand the tokenize, replace and scon commands. but the '$(%a = %a,) $!base( $* ,10,16,2)' part is an unfamiliar way of processing to me.

Why is the scon neccersary for the variable to be set correctly, what purpose does the explanation mark have between the $ and the command name like that, and what is $* (possibly same as $1- but tells it to process the identifier its in for each? shrug). tia


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby

Link Copied to Clipboard