Transition to nick: command for admin
This commit is contained in:
parent
4ea83e892d
commit
89a52b1588
5
bot.py
5
bot.py
|
@ -7,6 +7,7 @@ PLUGIN_SPECS = dict()
|
|||
|
||||
class MinerbotPhoenix(teambot.Handler):
|
||||
prefix="!"
|
||||
nick="minerbot"
|
||||
def on_connection_established(self,*args):
|
||||
self.load_modules()
|
||||
def load_modules(self):
|
||||
|
@ -30,6 +31,7 @@ class MinerbotPhoenix(teambot.Handler):
|
|||
traceback.print_exc()
|
||||
pass
|
||||
def on_pubmsg(self,channel,nick,message):
|
||||
self.is_admin = self.event.source.userhost == BOTOP
|
||||
for listener in plugin.listeners:
|
||||
try:
|
||||
plugin.listeners[listener](self,channel,nick,message)
|
||||
|
@ -37,7 +39,6 @@ class MinerbotPhoenix(teambot.Handler):
|
|||
print("On listener `{}`:".format(listener))
|
||||
traceback.print_exc()
|
||||
if not message.startswith(self.prefix): return
|
||||
self.is_admin = self.event.source.userhost == BOTOP
|
||||
args = message[len(self.prefix):].split(" ")
|
||||
cmd = args.pop(0).lower()
|
||||
self.cmd = cmd
|
||||
|
@ -54,5 +55,5 @@ class MinerbotPhoenix(teambot.Handler):
|
|||
|
||||
if __name__=="__main__":
|
||||
channels = "#bots".split()
|
||||
bot = teambot.TeamBot(channels,"minerbot2","localhost",username="Minerbot",chandler=MinerbotPhoenix)
|
||||
bot = teambot.TeamBot(channels,"minerbot","localhost",username="Minerbot",chandler=MinerbotPhoenix)
|
||||
bot.start()
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
import plugin
|
||||
|
||||
@plugin.command("admin","GO AWAY YOU DINKLEBERG")
|
||||
def admin(bot,channel,nick,subcmd,*args):
|
||||
@plugin.listener("admin")
|
||||
def admin(bot,channel,nick,msg):
|
||||
if not bot.is_admin: return
|
||||
if not msg.startswith(bot.nick+": "): return
|
||||
args = msg[len(bot.nick)+2:].split()
|
||||
subcmd = args.pop(0)
|
||||
if subcmd=="down":
|
||||
bot._bot.die("Stopping...")
|
||||
elif subcmd=="reload":
|
||||
bot.load_modules()
|
||||
elif subcmd=="nick":
|
||||
bot._bot.conn.nick(args[0])
|
||||
bot.nick = args[0]
|
||||
elif subcmd=="prefix":
|
||||
bot.prefix = args[0]
|
||||
|
||||
|
|
Loading…
Reference in New Issue