its a simple calculator code for a bot and you can edit it to use ctcp and answer with echo for personal use
synax : !calc < * or + or - or / >
you can turn it on and off using [ !calc on - !calc off ]
and you can use it in a channel or in a private msg
------------------------
| Code By [ Alimak96 ] |
------------------------
on the channel :
#calc on
on *:TEXT:!cinfo:#: { notice $nick $nick , You Can Use !calc <number> < * or + or - or / > <number> }
on *:TEXT:!calc *:#: {
if ($2 isnum) && ($4 isnum) && ($3 == +) || ($3 == -) || ($3 == *) || ($3 == /) { msg $chan $2- = $calc($2-) }
elseif ($2 == on) { .enable #calc }
elseif ($2 == off) { .disable #calc }
else { notice $nick , You Can Only Use Numbers And ( +,-,*,/ ) }
}
on private msg :
on *:TEXT:!calc *:?: {
if ($2 isnum) && ($4 isnum) && ($3 == +) || ($3 == -) || ($3 == *) || ($3 == /) { msg $nick $2- = $calc($2-) }
else { msg $nick 4 You Can Only Use Numbers And ( +,-,*,/ ) }
}
#calc end
@Stewie1k94
@Jethro
while $calc($2 $3 $4)
works fine
idont have to change it :P
but if ppl want to use them they can simply change it
@Stewie1k94
becauz i think if i use $calc($2-)
this maybe not work :P
if ($2 isnum) && ($4 isnum) && ($3 == +) || ($3 == -) || ($3 == *) || ($3 == /)
(15:02:24) (@user) !calc 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000001
(15:02:25) (@Bot) 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000001 = 0
Perhaps you should check for this and the other post i made, should give an nan error or something?
updated :
you can use [ !calc on ] and [ !calc off ]
and you can use it on private msg to
@Sorasyn I wouldn't have bothered sharing 4 lines of code
its 16 line
@sunslayer There should be some sort of validation on $3 making sure its an operator
what do you mean ?!