!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
}
}

Comments

Sign in to comment.
Chris220   -  Jul 10, 2009
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.
 Respond  
Firstmate   -  Mar 14, 2009
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.
 Respond  
PATX   -  Mar 14, 2009
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)
 Respond  
Blitzjager   -  Mar 14, 2009
patx: This converts one unit to another. (Probably works for currencies too)
 Respond  
PATX   -  Mar 14, 2009
give it a 5. windows comes w/ a calculater
 Respond  
Prelude   -  Mar 14, 2009
Cool Firstmate. 7/10.
 Respond  
slacker   -  Mar 13, 2009
just a thought: maybe convert this into a nice dialog.
 Respond  
Aucun50   -  Mar 13, 2009
Neat
 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.