diff --git a/bot.py b/bot.py index 1bcbcb0..a8bdbc5 100644 --- a/bot.py +++ b/bot.py @@ -1,4 +1,4 @@ -import teambot, sys, traceback, requests, random, words, markovuniverse, imp, plugin, os +import teambot, sys, traceback, requests, random, words, imp, plugin, os from titlecase import titlecase BOTOP = "~minerobber@127.0.0.1" @@ -75,17 +75,6 @@ class MinerbotPhoenix(teambot.Handler): self.say(channel,nick+": "+titlecase(" ".join(result))) def on_kwam(self,channel,nick,*a): self.on_backronym(channel,nick,"kwam") - def on_stevenuniverse(self,channel,nick,subcmd,*args): -# print(channel,nick,subcmd,args) - if not subcmd: subcmd="help" - if subcmd=="help": - self.say(channel,nick+": Current subcommands: !{cmd} fake-leak".format(cmd=self.cmd)) - elif subcmd=="fake-leak": - self.say(channel,nick+": {} - {}".format(*markovuniverse.new_episode())) - def on_su(self,channel,nick,*args): - self.on_stevenuniverse(channel,nick,*args) - def on_minerbot2src(self,channel,nick,*a): - self.say(channel,nick+": https://tildegit.org/khuxkm/minerbot2") if __name__=="__main__": words.loadDict("words") diff --git a/plugins/stevenuniverse.py b/plugins/stevenuniverse.py new file mode 100644 index 0000000..92485ca --- /dev/null +++ b/plugins/stevenuniverse.py @@ -0,0 +1,32 @@ +import markovuniverse,plugin,sys + +SUBCMDS = dict() +USAGE = dict() + +def reg_subcmd(name,format=""): + def _register(func): + SUBCMDS[name]=func + USAGE[name]=" ".join(filter(None,[name,format])) + return _register + +@plugin.command("stevenuniverse"," [args]") +def stevenuniverse(bot,channel,nick,subcmd=None,*args): + if not subcmd: subcmd = "help" + if subcmd not in SUBCMDS: subcmd = "help" + try: + SUBCMDS[subcmd](bot,channel,nick,*args) + except ValueError: + bot.say("Usage: !{} {}".format(bot.cmd,USAGE[subcmd])) + except: + print("!{} {} {}".format(bot.cmd,subcmd," ".join(args))) + raise + +plugin.alias("su","stevenuniverse") + +@reg_subcmd("help") +def help(bot,channel,nick,*a): + bot.say(channel,"{}: Current !{} subcommands are {}".format(nick,bot.cmd,", ".join(SUBCMDS.keys()))) + +@reg_subcmd("fake-leak") +def fakeleak(bot,channel,nick,*a): + bot.say(channel,nick+": {} - {}".format(*markovuniverse.new_episode()))