Kiddo96 commented on a Page, Google Calculator  -  May 11, 2012

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)
Somsubhra1  -  Jan 11, 2016

Doesn't work.

Sign in to comment

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.