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 45
-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
}
}
I'd like to implement this in my bot that is on my channel.
However, I cannot get the script working. I have copy and pasted it into my bot's script.
When someone types "!gcalc 5+4" or whatever, it does not show them any value. I'm unsure whether this is because it is not executing the msg, or not actually calculating it.
Thanks in advance for any help.
This site is for those who use mIRC more than how you say. I don't care if there's online ones. The purpose is to relay it to mIRC. It doesn't matter if you know good sites...
Of course there's scripts for things like weather and youtube. The point is it puts it all in mIRC.
So please, I can't change your score, but rate based off the code and effectiveness and whatever is actually relevant to the fact described above.
oooo my bad. i misunderstood sorry guys. as for the 5 it stays but there are some really good converters online so i personally do not need one in mirc or to have mirc search google for me. lol. but thats just me. but on the plus side the code it pretty good.
-- patx[at]patxbot.tk (http://patxbot.tk)