26 lines
580 B
Python
26 lines
580 B
Python
import re
|
|
|
|
class Plugin:
|
|
def __init__(self,bot,command_format):
|
|
self.bot = bot
|
|
self.cmd = re.compile(command_format)
|
|
|
|
def answer(self,channel,nick,message):
|
|
m = self.cmd.search(message)
|
|
if m and hasattr(self,m.group(1).replace(" ","_")):
|
|
getattr(self,m.group(1).replace(" ","_"))(channel,nick,message)
|
|
|
|
class TestPlugin(Plugin):
|
|
def __init__(self,bot):
|
|
Plugin.__init__(self,bot,"!test ([A-Za-z]+)(?: (.+))?")
|
|
self.is_bot=True
|
|
|
|
# def is_not_a_bot(self):
|
|
# self.is_bot=False
|
|
|
|
def say(self,c,n,m):
|
|
if self.is_bot:
|
|
self.bot.mention(c,n,m)
|
|
else:
|
|
print(m)
|