87 lines
1.9 KiB
Python
87 lines
1.9 KiB
Python
import sieve,plugin
|
|
class Solver(plugin.Plugin):
|
|
def __init__(self,bot):
|
|
plugin.Plugin.__init__(self,bot,"!mbtilde ([a-z]+) ([A-Za-z0-9]+)(?: (.+))?")
|
|
|
|
def answer(self,c,n,m):
|
|
if not self.cmd.search(m):
|
|
return
|
|
if n!=self.bot.owner:
|
|
self.bot.say(c,"Don't tell me what to do!")
|
|
return
|
|
if c!="#bots":
|
|
self.bot.say(c,"Remember: tildebot only awards tildes in \#bots.")
|
|
plugin.Plugin.answer(self,c,n,m) # call super method
|
|
|
|
def run(self,cmd):
|
|
if not cmd.startswith("!mbtilde"):
|
|
return False
|
|
else:
|
|
parts = cmd.split()
|
|
parts.pop(0)
|
|
parts = [part.strip() for part in parts]
|
|
try:
|
|
return getattr(self,parts[0])(*parts[1:])
|
|
except:
|
|
return False
|
|
|
|
def request(self,c,n,m):
|
|
self.bot.say(c,self._request())
|
|
|
|
def _request(self):
|
|
return "!tilde"
|
|
|
|
def add(self,c,n,m):
|
|
self.bot.say(c,self._add(m.group(2),m.group(3)))
|
|
|
|
def _add(self,num1,num2):
|
|
return int(num1)+int(num2)
|
|
|
|
def sub(self,c,n,m):
|
|
self.bot.say(c,self._sub(m.group(2),m.group(3)))
|
|
|
|
def _sub(self,num1,num2):
|
|
return int(num1)-int(num2)
|
|
|
|
def mult(self,c,n,m):
|
|
self.bot.say(c,self._mult(m.group(2),m.group(3)))
|
|
|
|
def _mult(self,num1,num2):
|
|
return int(num1)*int(num2)
|
|
|
|
def div(self,c,n,m):
|
|
self.bot.say(c,self._div(m.group(2),m.group(3)))
|
|
|
|
def _div(self,num1,num2):
|
|
return int(num1)/int(num2)
|
|
|
|
def pow(self,c,n,m):
|
|
self.bot.say(c,self._pow(m.group(2),m.group(3)))
|
|
|
|
def _pow(self,num1,num2):
|
|
return int(num1)**int(num2)
|
|
|
|
def mod(self,c,n,m):
|
|
self.bot.say(c,self._mod(m.group(2),m.group(3)))
|
|
|
|
def _mod(self,num1,num2):
|
|
return int(num1)%int(num2)
|
|
|
|
def primefac(self,c,n,m):
|
|
self.bot.say(c,self._primefac(m.group(2)))
|
|
|
|
def _primefac(self,num):
|
|
return sieve.primefactors(int(num))
|
|
|
|
def score(self,c,n,m):
|
|
self.bot.say(c,self._score())
|
|
|
|
def _score(self,d):
|
|
return "!tildescore"
|
|
|
|
def say(self,c,n,m):
|
|
self.bot.say(c,self._say(m.group(2)))
|
|
|
|
def _say(self,msg):
|
|
return msg
|