Currency converter.

By ReQueST on Jul 10, 2005

This script converts 1 currency to another.

Easy usage: !conv [amount] [cur1] [cur2]

Example: !conv 1000 EUR USD <-- Will convert a thousand Euro's to US Dollars.

;Place this line in Variables:
; %convert.currency AUD CAD CHF CNY DKK EUR GBP HKD HUF INR JPY MXN MYR NOK NZB RUB SEK SGD THB USD ZAR ZMK XPT XPD SDR XCD XAU XAG VEB TWD TTD TRL SKK SDD SAR RUR ROL PLN PKR PHP NZD LBP KRW JOD JMD ISK ILS IDR FJD EGP DZD CZK CYP BSD BRL BMD BGN BBD ARS
;Have fun!

on *:TEXT:!conv*:#: { 
  if ($2 && $3 && $4) {
    if ($remove($2,$chr(44)) isnum) {
      if ($3 isin %convert.currency && $4 isin %convert.currency) { 
        if (%conv.busy == 0) { 
          msg $chan Converting $2 $3 to $4 $+ .
          set %conv.chan $chan 
          set %conv.nick $nick
          set %conv.amount $remove($2,$chr(44))
          set %conv.from $3
          set %conv.to $4
          set %conv.busy 1
          sockopen Converter xe.com 80
        }
        else { msg $chan Currently busy. Please be patient. }
      }
      else { msg $chan Error! Not a valid currency! (Allowed: %convert.currency $+ ) }
    }
    else { msg $chan Error! $2 isn't a valid number! }
  }
  else { msg $chan Error! Missing an input. }
}

on *:SOCKOPEN:Converter:{
  set %conv.submit $+(Amount=,%conv.amount,$chr(38),From=,%conv.from,$chr(38),To=,%conv.to,$chr(38),Submit=Submit)  
  sockwrite -n $sockname POST /ucc/convert.cgi HTTP/1.1
  sockwrite -n $sockname Host: www.xe.com
  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $calc($len(%conv.submit) + 1) 
  sockwrite -n $sockname
  sockwrite -n $sockname %conv.submit
}

on *:SOCKREAD:Converter:{
  var %tmp
  sockread %tmp
  ;echo 4 -ag %tmp
  if (%conv.to $+ </span><br> isin %tmp) { msg %conv.chan Converted amount of: %conv.amount $upper(%conv.from) = $gettok($gettok(%tmp,3,32),2,62) $upper(%conv.to) $+ . }
  if (</html> isin %tmp) { set %conv.busy 0 | sockclose $sockname }
} 

Comments

Sign in to comment.
VinX   -  Aug 02, 2009

19:56:44 [~VinX] !conv 500 INR USD
19:56:46 [~XXX] Error! Not a valid currency! (Allowed: )

 Respond  
guest598594   -  Sep 04, 2007

this could come in handy :P

 Respond  
xDaeMoN   -  Jul 10, 2005

Another thing, change this \"if (%conv.busy == 0) { \" to \"if (!%conv.busy) { \" so it would check if the variable is $null or zero. Currently, it checks if there is already a variable set but if there is not then it the script would always say that it\'s busy. Other than that, its a nice script.

 Respond  
ReQueST   -  Jul 10, 2005

Yeah i know.. Dunno why i did that lol.. Normally i use $1-4, but $4 would work to.

 Respond  
xDaeMoN   -  Jul 10, 2005

Just a suggestion, instead of \"if ($2 && $3 && $4) {\", you could use \"if ( $4 ) {\".

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.