Actually code a decent amount of the bot
This commit is contained in:
parent
0289ac7a9d
commit
0366b24208
37
bot.py
37
bot.py
|
@ -1,8 +1,41 @@
|
|||
import teambot
|
||||
import teambot, sys
|
||||
|
||||
USAGE = dict(admin="Stop trying to use this command!")
|
||||
PUBLIC_COMMANDS = []
|
||||
|
||||
class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
||||
def __init__(self):
|
||||
self.prefix = "!"
|
||||
self.botop = "khuxkm"
|
||||
super(SOTDBot,self).__init__()
|
||||
def handle_command(self,target,nick,text):
|
||||
pass # change this
|
||||
if not text.startswith(self.prefix):
|
||||
return
|
||||
self.target = target if target!=self._bot.nick else nick
|
||||
self.sourcenick = nick
|
||||
args = text[len(self.prefix):].split()
|
||||
cmd = args.pop(0)
|
||||
if hasattr(self,"do_"+cmd.lower()):
|
||||
try:
|
||||
getattr(self,"do_"+cmd.lower())(*args)
|
||||
except TypeError as e:
|
||||
self.say(self.target,"{}: Usage: {}".format(nick,USAGE[command.lower()]))
|
||||
elif text in ("!botlist","!rollcall"):
|
||||
self.do_botlist()
|
||||
|
||||
def do_admin(self,*args):
|
||||
if nick!=self.botop:
|
||||
self.say(target,nick+": You can't tell me what to do!")
|
||||
return
|
||||
args = list(args)
|
||||
subcmd = args.pop(0)
|
||||
if subcmd=="down":
|
||||
self._bot.die("Bye bye!")
|
||||
elif subcmd=="prefix":
|
||||
self.prefix = args[0]
|
||||
|
||||
def do_botlist(self):
|
||||
self.say(self.target,"Maintainer: khuxkm | commands: {}".format(", ".join("{}{}".format(self.prefix,cmd) for cmd in PUBLIC_COMMANDS)))
|
||||
|
||||
if __name__=="__main__":
|
||||
channels = "#bots".split()
|
||||
|
|
Reference in New Issue