Add basic functionality
This commit is contained in:
parent
0366b24208
commit
21268a0e4d
23
bot.py
23
bot.py
|
@ -1,7 +1,12 @@
|
|||
import teambot, sys
|
||||
|
||||
USAGE = dict(admin="Stop trying to use this command!")
|
||||
PUBLIC_COMMANDS = []
|
||||
USAGE = dict(admin="Stop trying to use this command!",sotd="{}sotd <link> <name>")
|
||||
PUBLIC_COMMANDS = ["sotd"]
|
||||
|
||||
SOTDS = dict()
|
||||
|
||||
def get_title(link):
|
||||
return link # TODO: actually make this get the title of a link.
|
||||
|
||||
class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
||||
def __init__(self):
|
||||
|
@ -19,13 +24,13 @@ class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
|||
try:
|
||||
getattr(self,"do_"+cmd.lower())(*args)
|
||||
except TypeError as e:
|
||||
self.say(self.target,"{}: Usage: {}".format(nick,USAGE[command.lower()]))
|
||||
self.say(self.target,"{}: Usage: {}".format(nick,USAGE[command.lower()].format(self.prefix)))
|
||||
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!")
|
||||
if self.sourcenick!=self.botop:
|
||||
self.say(target,self.sourcenick+": You can't tell me what to do!")
|
||||
return
|
||||
args = list(args)
|
||||
subcmd = args.pop(0)
|
||||
|
@ -37,6 +42,14 @@ class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
|||
def do_botlist(self):
|
||||
self.say(self.target,"Maintainer: khuxkm | commands: {}".format(", ".join("{}{}".format(self.prefix,cmd) for cmd in PUBLIC_COMMANDS)))
|
||||
|
||||
def do_sotd(self,link,*name):
|
||||
if name:
|
||||
name = " ".join(name)
|
||||
else:
|
||||
name = get_title(link)
|
||||
SOTDS[self.sourcenick] = (name,link)
|
||||
self.say(self.target,self.sourcenick+": Your SOTD has been set to {}.".format(name))
|
||||
|
||||
if __name__=="__main__":
|
||||
channels = "#bots".split()
|
||||
bot = teambot.TeamBot(channels,"sotdbot","localhost",chandler=SOTDBot)
|
||||
|
|
Reference in New Issue