API-Free Wolfram Alpha

Platform:  mIRC
Published  Jun 24, 2012
Updated  Jun 24, 2012
I recently posted a snippet using Wolfram Alpha's API. This version uses the main site, has unlimited calls, but is a bit slower.

Commands are !wa -query- or /wolfram -query- ;Wolfram Alpha!
;Using Wolfram Alpha main site to get result.
;Command !wa -query- or /wolfram -query-
on $*:text:/^!wa /Si:#,?:{
wolfram $2-
}
alias wolfram {
if $sock(wolfram) || $sock($+(wolfram,$nick)) {
sockclose $v1
}
sockopen $iif($event == text,$+(wolfram,$nick),wolfram) www.wolframalpha.com 80
sockmark $iif($event == text,$+(wolfram,$nick) $iif(#,msg #,msg $nick),wolfram echo -a) $1-
}
on *:sockopen:wolfram*:{
tokenize 32 $sock($sockname).mark
sockwrite -nt $sockname GET /input/?i= $+ $urlencode($3-) HTTP/1.1
sockwrite -nt $sockname Host: www.wolframalpha.com
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname $crlf
}
on *:sockread:wolfram*:{
tokenize 32 $sock($sockname).mark
var %wreader
sockread %wreader
if $regex($+(wolfram,$2),%wreader,/"stringified": "([^"]+?)"/) {
set $+(%,wresult,$2) $($+(%,wresult,$2),2) $regml($+(wolfram,$2),1) 04 $+ $chr(124) $+ 
}
}
on *:sockclose:wolfram*:{
tokenize 32 $sock($sockname).mark
$1-2 $iif($($+(%,wresult,$2),2),04 $+ $chr(124) $+  $regsubex($utf16($($+(%,wresult,$2),2)),/\\(.)/g,\1),No result was found.)
unset $+(%,wresult,$2)
}
alias urlencode return $regsubex($1,/(\W)/g,% $+ $base($asc(\1),10,16,2)))
alias UTF16 return $regsubex($1-,/\Q\\:\E([a-f\d]{4})/ig,$chr($base(\1,16,10)))

Comments

Sign in to comment.
ProIcons   -  Sep 20, 2012
I bought the Wolfram alpha and i made a similar script but the only diffrence was that i was interpreting the results from DLL i made for its CONSOLE :D so it was kinda better but still this is good
 Respond  
BLKoldSUN_   -  Jun 24, 2012
it's quit interesting :)
 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.