Update: This script is now part of the eggtcl project.

This is a currency converter written in TCL for Eggdrop, which is similar to the ucc.mrc I wrote for mIRC.

I used to use the xeucc.tcl, but that script no longer works and hasn’t been updated since 2008.

!ucc 9 usd gbp

Could not obtain results from XE.com, sorry!

Further more xeucc.tcl uses the XE.com website to gather the information, however they don’t like us doing this, and have since added the following message:

WARNING: Automated extraction of rates is prohibited under the Terms of Use.

Other scripts such as Incith’s Exchange also use a website. This one uses Yahoo Finance. The problem is that this website is subject to change at any time without prior notice.

Parsing a website that is subject to change is not always a good idea. Instead what is needed is an API which is easy to parse and extract the data and also unlikely to change formatting.

Although XE.com does have an API, it is not free. This is no good.

I have decided instead to use the Yahoo Developer Network Currency Converter API, which is much easier to parse and permits this kind of usage.

There is a choice of two URLs which you can call to get the data:

http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDGBP=X

http://download.finance.yahoo.com/d/?f=sl1d1t1&s=USDGBP=X

Both examples should provide you with a csv file to download which will contain the currency information.

I have used the second URL in my script.

Usage

.ucc

Usage: .ucc

.ucc 9 usd gbp

User, * UCC: 9 USD is 5.8905 GBP as of 2/25/2010 9:22am

Download

If you like it, or even if you don’t, please leave a comment below. Thanks.