Hi this is a simple script that took me no longer than 10 mins, Literally..
This is as simple as putting a few sockets together and letting it read information off a website.
It works like this, it works in a bot:
(19:37:52) <~dronez4> !bin 100100
(19:37:52) <~RCBOT> Binary Calculation: 36
(19:37:57) <~dronez4> !bin d000
(19:37:57) <~RCBOT> Sorry Invalid calculation
Meh have fun.
on *:text:*:#:{
if ($1 == !bin) {
set %channel1 $chan
if ($2 isnum) {
set %binnum $2
getbin
}
else {
msg $chan Sorry Invalid calculation
}
}
}
;http://www.calculator.net/binary-calculator.html?b2dnumber1=1010101010&calctype=b2d&x=77&y=19
alias getbin {
sockclose getbin
sockopen getbin www.calculator.net 80
}
alias NoHTML {
if (alt=": isin $1) {
return $regsubex($1,/<[^>]+(?:>|$)|^[^<>]+>/g,) :emoticon:
}
else {
if (' isin $1) {
set %removed1 l $remove(%read,')
return $regsubex($1,/<[^>]+(?:>|$)|^[^<>]+>/g,)
}
else {
return $regsubex($1,/<[^>]+(?:>|$)|^[^<>]+>/g,)
}
}
}
alias striphtml {
return $regsubex($1,/=[^"]+(?:>|$)|^[^<>]+</g,)
}
on *:sockread:getbin:{
if ($sockerr > 0) { return }
else {
var %read
sockread %read
if (*Decimal value: <font* iswm %read) {
msg %channel1 Binary Calculation: $remove($nohtml(%read),result:,Decimal value:)
}
}
}
On *:sockopen:getbin: {
if (!$sockerr) {
sockwrite -nt getbin GET /binary-calculator.html?b2dnumber1= $+ %binnum $+ &calctype=b2d&x=77&y=19 HTTP/1.0
sockwrite -n getbin Host: www.calculator.net
sockwrite -n getbin $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
Would be magnitudes more efficient if you took the time to calculate it locally instead of reaching out to a website to do it. Not to mention doing it locally would require about 50% less code. Doing it this way does not guarantee longevity. In a few months or whenever they decide to update the website, it'll have to be redone to function properly again.
Oh wow, As easy as that.. Didn't think that was as simple as that.. nicely done, Thanks..