!gcalc
Platform: mIRC
Published Mar 13, 2009
Updated Mar 13, 2009
This makes use of Google's Calculator, which is pretty handy.
It can convert units as well as do simple math calculations.
Couple examples:
!gcalc 4 grams in tons
-Returns 4 grams = 4.40924524 × 10^-6 short tons
!gcalc 4*5
-Returns 4 * 5 = 20
Pretty simple. A note about the unit converter though, it *can not* do conversions if they are not in a similar type of measurements.
e.g. !gcalc 4 grams in gallons
I know it's possible to convert it longhand, but this script just retrieves google's response.
on *:TEXT:!gcalc *:#: {
if ($sock(google)) { sockclose google }
set %chan $chan
sockopen google google.com 80
sockmark google $2-
}
on *:sockopen:google: {
sockwrite -nt $sockname GET $+(/search?hl=en&q=,$replace($sock(google).mark,$chr(32),+),&btnG=Search)
sockwrite -nt $sockname Host: google.com
sockwrite -nt $sockname $crlf
}
on *:sockread:google: {
var %x
sockread %x
if ($regex(%x,/<h2.+?<font.+?<b>(.+?)<\/b/i)) {
var %t $regml(1)
%t = $regsubex(%t,/&#(.+);/,$chr($regml(1)))
%t = $remove($replace(%t,<sup>,^),</sup>)
msg %chan $nohtml(%t)
unset %chan
sockclose google
}
}