Currency converter

By Ayon on Mar 25, 2010

This kinda explains itself. Add it to your bot then you can type !currency [amount] [from] [to] and it will return the converted info

Example:
[20:14] @FamilyGuy › !currency 1 eur usd
[20:14] @stillborn › Currency: 1.00 EUR = 1.33061 USD

UPDATE:

  • Changed from local vars to sockmark
  • Cleaned it up abit
on 1:TEXT:!currency *:#:{
  if (%aflood. [ $+ [ $nick ] ]) { halt }
  set -u5 %aflood. [ $+ [ $nick ] ] 1
  if (!$4) { .notice $nick Syntax: $+($pre,currency) [amount] [from_value] [to_value] | return }
  sockopen currency www.xe.com 80
  sockmark currency $+(/ucc/convert.cgi?Amount=,$2,&From=,$upper($3),&To=,$upper($4),&image.x=59&image.y=7&image=Submit) # $2 $upper($3) $upper($4)
}

on 1:SOCKOPEN:currency:{
  sockwrite -n $sockname GET $gettok($sock(currency).mark,1,32) HTTP/1.0
  sockwrite -n $sockname Host: www.xe.com:80
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname $crlf
}

on 1:SOCKREAD:currency:{
  var %sock.cur.source | sockread %sock.cur.source
  if (*<title>* iswm %sock.cur.source) { 
    .msg $gettok($sock(currency).mark,2,32) Currency: $remove(%sock.cur.source,<title>,</title>,XE.com: $gettok($sock(currency).mark,4,32) to $gettok($sock(currency).mark,5,32) rate: )
    sockclose currency
  }
}

Comments

Sign in to comment.
Outkax   -  Jul 25, 2014

Script don't runing in mIRC 7.31

 Respond  
RIcko   -  Sep 04, 2012

Currency: 301 Moved Permanently, try to update it since other people needs this.

 Respond  
Ayon   -  Mar 26, 2010

Updated the snippet now :) Info is in the description ;)

 Respond  
GuitarMasterx7   -  Mar 26, 2010

well das odd...
just yesterday we were discussing the value of other dollars in the US
and vise versa

u stalkin meh?
xD
nice work.

and yea using sockmarks saves space an time
from setting all those vars.
pretty fun to learn also =x
non-the-less good job =]

 Respond  
Slickone   -  Mar 26, 2010

um just another way of making it using sockmark
i know it an be made better but w/e

on $*:text:/^@Currency/iS:#:{ 
  if (!$hget(Currency,sets)) { 
    .hadd -mu4 Currency sets USD AUD CAD CHF CNY DKK EUR GBP HKD HUF INR JPY MXN MYR NOK NZD RUB SEK SGD THB ZAR
    if ($2 isnum && $istok($hget(Currency,sets),$3,32) && $istok($hget(Currency,sets),$4,32) && !$5) { 
      if ($sock(Currency)) sockclose Currency
      sockopen Currency www.xe.com 80
      sockmark Currency $+(/ucc/convert.cgi?Amount=,$2,&From=,$3,&To=,$4) msg #
    }
    else { msg # $iif($2 !isnum || $5,Syntax: @currency amount from to EX: @currency 2 usd aud,please enter Currencys: $hget(Currency,sets)) }
  }
}
on *:sockopen:Currency: {
  sockwrite -nt $sockname GET $gettok($sock(Currency).mark,1,32) HTTP/1.1
  sockwrite -nt $sockname Host: $+(www.xe.com,$str($crlf,2))
}
on *:sockread:Currency: {
  var %Currency | sockread %Currency
  if ($regex(%Currency,/<tr><td width=.+right.+>(.+)<.+WARNING:.+><\/h2><\/td>/)) { .hadd -mu4 Currency say $regml(1) }
  if ($regex(%Currency,/<td width=.+left.+>(.+)<.+WARNING:.+><\/h2><\/td>/)) { $gettok($sock(Currency).mark,2-,32) $hget(Currency,say) = $regml(1) | sockclose Currency }
}
 Respond  
henbone11   -  Mar 25, 2010

I am using NoNameScript over mirc. not sure if that makes a difference or not.

 Respond  
Ayon   -  Mar 25, 2010

Jethro_: it's because i know almost nothing about sockets.. done some minor stuff earlier.. but nothing major :) ill read up on sockmark :) thanks for the heads up

henbone11: weird.. works perfectly here.. are you running it from your main client or bot client? :)

 Respond  
henbone11   -  Mar 25, 2010

sorry, but it didn't work for me.

 Respond  
Jethro   -  Mar 25, 2010

Why not make the use /sockmark command and the $sock().mark identifier instead of making numerous vars?

 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.