should work idk

This commit is contained in:
lickthecheese 2020-01-31 18:00:47 -05:00
parent 85728a4311
commit 593158044f
1 changed files with 15 additions and 2 deletions

17
bot.py
View File

@ -3,8 +3,10 @@ import teambot, sys, os
class Circles(teambot.Handler):
def __init__(self, bot):
print('initilized')
self.modules = []
self.cmd = {}
self.raw = {}
self.help = {}
self.prefix = "."
def loadMods(self):
@ -17,10 +19,14 @@ class Circles(teambot.Handler):
self.modules.append(m)
def registerCommand(self, txt, func):
self.cmd[txt] = func
def regosterRaw(self, txt, func):
self.raw[txt] = func
def registerHelp(self, cmd, ht):
self.help[cmd] = ht
def on_connection_established(self):
print('Connected!')
self.loadMods()
print('Ready!')
def on_pubmessage(self,c,n,m):
if m.startswith(self.prefix):
args = m[len(self.prefix):].strip().split()
@ -30,7 +36,14 @@ class Circles(teambot.Handler):
self.cmd[cmd](self,c,n,m)
except TypeError:
self.say(c,n+": Usage: "+self.help[cmd])
if cmd in self.raw:
try:
self.raw[cmd](self,c,n,m)
except TypeError:
self.say(c,n+": Usage: "+self.help[cmd])
if __name__=="__main__":
chans = ['#chaos']
bot = teambot.TeamBot(chans, "circles", "localhost", chandler=Circles)
bot.start()