on *:TEXT:!esolve *:#: {
if (%e.calc == ON) { notice $nick Sorry, the Equation Calculator is being used. Try again later. | halt }
if (/ isin $2-) { notice $nick Sorry, the Division Operator ( "/" ) is not supported at this time. | halt }
set %e.calc ON
if ($sock(ESolve)) {
.sockclose ESolve
}
sockopen ESolve algebrahelp.com 80
set %e.3D % $+ 3D
set %e.2B % $+ 2B
set %e.nick $nick
set %e.equation1 $2
set %e.equation2 $replace(%e.equation1,$chr(61),%e.3D)
set %e.equation2 $replace(%e.equation2,$chr(43),%e.2B)
}
on *:SOCKOPEN:ESolve: {
sockwrite -n $sockname GET /calculators/equation/calc.do?equation= $+ %e.equation2 $+ &solvf=AUTO
sockwrite -n $sockname Host: algebrahelp.com
sockwrite $sockname $crlf
}
on *:SOCKREAD:ESolve: {
if ($sockerr) {
notice %e.nick There was an error while the socket was being read. ( $+ $sockerr $+ )
halt
}
else {
var %sockreader
sockread %sockreader
tokenize 32 %sockreader
if (*x*pre* iswm $1-) {
notice %e.nick The answer to %e.equation1 is $+ $nohtml($1-) $+ .
unset %e.*
sockclose ESolve
}
}
}
alias nohtml { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }