This is my version of a Google Calculator. It can do more than a regular calculator, such as calculating measures, converting etc. A few examples are coming.

The commands are either > !calc -calculation here-

or

/calculate -calculation here-

Use !calc in a channel, and it will message you there. In pm and it will respond you there. /calculate simply echos it to your active window.

If you find any bugs, please let me know.> !calc (4 + 6) * 6
(4 + 6) * 6 = 60

!calc meter to inches

1 meter = 39.3700787 inches

!calc meter to foot

1 meter = 3.2808399 feet

!calc eur to usd

1 Euro = 1.3491 U.S. dollars

!calc 2m

(2 meters)

Update - Made an update to my snippet as I found 2 bugs. Please see to it.

```
on $*:text:/^!calc /Si:#,?:{
calculate $2-
}
alias calculate {
if $sock(calculate) || $sock($+(calculate,$nick)) {
sockclose $v1
}
sockopen $iif($event == text,$+(calculate,$nick),calculate) www.google.com 80
sockmark $iif($event == text,$+(calculate,$nick) msg $iif(#,#,$nick),calculate echo -a) $1-
}
on *:sockopen:calculate*:{
tokenize 32 $sock($sockname).mark
sockwrite -nt $sockname GET $+(/ig/calculator?hl=en&q=,$urlencode($3-)) HTTP/1.1
sockwrite -nt $sockname Host: www.google.com
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname $crlf
}
on *:sockread:calculate*:{
sockread &greader
var %greader $bvar(&greader,1-).text
tokenize 32 $sock($sockname).mark
if $regex(answer $+ $2,%greader,/rhs: "(.*?)"/) && $regex(calc $+ $2,%greader,/lhs: "(.*?)"/) {
$1-2 $iif($regml(answer $+ $2,1) == $null,4Something is wrong with the calculation!,03 $&
$+ $csub($cchr($sup($replace($regml(calc $+ $2,1) = $v1,+,04+03,-,06-03,*,13*03,/,07/03,=,10=03)))))
sockclose $sockname
}
}
alias cchr return $regsubex($1,/\\x26#(\d+?);/g,$chr(\1))
alias sup return $regsubex($1,/\\x3csup\\x3e([\d-]+?)\\x3c\/sup\\x3e/Sg,12^\13)
alias urlencode return $regsubex($1,/(\W)/g,% $+ $base($asc(\1),10,16,2)))
alias csub return $regsubex($1,/\\x3csub\\x3e(.+?)\\x3c\/sub\\x3e/g,\1)
```

Sign in to comment.

Those are colour codes that seem to have dissapeared. Maybe a channel mode or something. Try this colour-free version:

```
on $*:text:/^!calc /Si:#,?:{
calculate $2-
}
alias calculate {
if $sock(calculate) || $sock($+(calculate,$nick)) {
sockclose $v1
}
sockopen $iif($event == text,$+(calculate,$nick),calculate) www.google.com 80
sockmark $iif($event == text,$+(calculate,$nick) msg $iif(#,#,$nick),calculate echo -a) $1-
}
on *:sockopen:calculate*:{
tokenize 32 $sock($sockname).mark
sockwrite -nt $sockname GET $+(/ig/calculator?hl=en&q=,$urlencode($3-)) HTTP/1.1
sockwrite -nt $sockname Host: www.google.com
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname $crlf
}
on *:sockread:calculate*:{
sockread &greader
var %greader $bvar(&greader,1-).text
tokenize 32 $sock($sockname).mark
if $regex(answer $+ $2,%greader,/rhs: "(.*?)"/) && $regex(calc $+ $2,%greader,/lhs: "(.*?)"/) {
$1-2 $iif($regml(answer $+ $2,1) == $null,Something is wrong with the calculation!,$&
$+ $csub($cchr($sup($regml(calc $+ $2,1) = $v1))))
sockclose $sockname
}
}
alias cchr return $regsubex($1,/\\x26#(\d+?);/g,$chr(\1))
alias sup return $regsubex($1,/\\x3csup\\x3e([\d-]+?)\\x3c\/sup\\x3e/Sg,^\1)
alias urlencode return $regsubex($1,/(\W)/g,% $+ $base($asc(\1),10,16,2)))
alias csub return $regsubex($1,/\\x3csub\\x3e(.+?)\\x3c\/sub\\x3e/g,\1)
```

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.

nope doesnt work anymore at all...