2020-05-11 20:00:46 +00:00
|
|
|
from bot import IRCLine
|
|
|
|
from events import Event
|
|
|
|
BOT = None
|
|
|
|
|
|
|
|
def on_botlist(event):
|
|
|
|
if not BOT: return None
|
|
|
|
commands = []
|
|
|
|
for handler in BOT.event_manager.handlers.keys():
|
|
|
|
if handler.startswith("command_"):
|
|
|
|
command = handler[len("command_"):]
|
|
|
|
if command not in "admin botlist".split(): commands.append(command)
|
2021-05-13 18:32:14 +00:00
|
|
|
print(commands)
|
2020-05-11 20:00:46 +00:00
|
|
|
BOT.socket.send(IRCLine("PRIVMSG",event.target,":{}: I'm minerbot2, rewritten again! Commands include {}".format(event.hostmask.nick,", ".join(["!"+x for x in commands]))))
|
|
|
|
|
|
|
|
def on_privmsg(event):
|
2021-05-13 18:32:14 +00:00
|
|
|
if BOT.in_batch: return
|
2020-05-11 20:00:46 +00:00
|
|
|
if BOT and BOT.prefix=="!": return
|
|
|
|
if event.message in ("!botlist", "!rollcall"):
|
|
|
|
ev = Event("command_botlist",parts=[])
|
|
|
|
ev.data.update(event.data)
|
|
|
|
on_botlist(ev)
|
|
|
|
|
|
|
|
def register(bot):
|
|
|
|
global BOT
|
|
|
|
BOT=bot
|
|
|
|
bot.event_manager.on("command_botlist",on_botlist)
|
|
|
|
bot.event_manager.on("privmsg",on_privmsg)
|