Currency Converter

By Arigateaux on Sep 04, 2014

Based on Ayon's script, since it hasn't been worked on in a long time and it's the newest one available. Same commands still apply.

!convert N FROM TO
N is the number (can be decimal)
FROM is the origin currency
TO is the destination currency

Updates:

  • Changed the website due to possible Terms of Use violation, plus Google is easier to read.
  • Added a new alias
  • Re-wrote large chunks of the script.
on $*:text:/[`@!.]currency \d+(.\d+)? \w+/Si:#:{
  if (%aflood. [ $+ [ $nick ] ]) halt
  ;set -u5 %aflood. [ $+ [ $nick ] ] 1
  if (!$4) {
    .notice $nick Syntax: [`!@.]currency [AMOUNT] [FROM] [TO]
    return
  }
  sockclose currency
  sockopen currency www.google.com 80
  sockmark currency $+(/finance/converter?a=,$2,&from=,$upper($3),&to=,$upper($4))
  %# = #
}

on *:sockopen:currency:{
  var %% = sockwrite -n $sockname
  %% GET $sock($sockname).mark HTTP/1.0
  %% Connection: Keep-Alive
  %% $crlf
}

on *:sockread:currency:{
  var %s
  sockread %s
  if (*<div id=currency_converter_result>* iswm %s) {
    tokenize 32 $nohtml(%s) 
    msg %# $cx($1) $2-3 $cx($4) $5
  }
}

; Written by http://zigwap.com/mirc
alias noHTML return $regsubex($1, /<[^>]+(?:>|$)|^[^<>]+>/g, $null)

; Written by Ouims irc.SwiftIRC.net:#mSL
; Modified by evilMonkey irc.SwiftIRC.net:#mSL
alias cx {
  var %x = $1
  tokenize 46 %x
  if (.* iswm %x) tokenize 46 0 $+ %x
  return $iif($0 == 1,$bytes($1,b) $+ .00,$bytes($1,b) $+ . $+ $left($2,2) $+ $iif($len($2) == 1,0))))
}

Comments

Sign in to comment.
cptpan   -  Nov 17, 2015

This has suddenly stopped working for me :\

 Respond  
ovelayer   -  Feb 08, 2015

doesn't seem to be workin anymore
[3:46pm Sun] <~xXBERTOXx> !currency 4.50 euro dollars
[3:46pm Sun] <~BrAiNs> . .

cptpan  -  Feb 24, 2015

You need to use the right dollar text. 'dollars' doesn't mean anything. AUD or USD etc

[14:46] <@User> !currency 4.5 EUR USD
[14:46] <@Bot> 4.50 EUR = 5.10 USD

ovelayer  -  Feb 25, 2015

Ahh thanks

Sign in to comment

cptpan   -  Jan 23, 2015

This works great, and caters for btc! Nice one

 Respond  
jakcane   -  Sep 05, 2014

Works good! Even better idea, you know how you can type any calculation in the google search bar and it will return an answer? Instead of making just a currency you can make everything. type in 10 feet in yards or feet in 2 miles and it always returns an answer in that little box. Just a thought, there were some but they dont work no more. Anyways this one is nice!

Herc08  -  Sep 05, 2014

I think I might do that, haven't worked with sockets in years though...

jakcane  -  Sep 08, 2014

do it!

Sign in to comment

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.