bitbot-3.11-fork/modules/admin.py
jesopo 8c6ab17e57 give an Exports object (actually, ExportsContex object) to each module, to
facilitate things like !set and !channelset without using the events system
2018-09-02 19:54:45 +01:00

26 lines
967 B
Python

class Module(object):
def __init__(self, bot, events, exports):
self.bot = bot
events.on("received").on("command").on("changenickname"
).hook(self.change_nickname, permission="changenickname",
min_args=1, help="Change my nickname", usage="<nickname>")
events.on("received").on("command").on("raw"
).hook(self.raw, permission="raw", min_args=1,
help="Send a raw IRC line through the bot",
usage="<raw line>")
events.on("received").on("command").on("part"
).hook(self.part, permission="part", min_args=1,
help="Part from a channel",
usage="<#channel>")
def change_nickname(self, event):
nickname = event["args_split"][0]
event["server"].send_nick(nickname)
def raw(self, event):
event["server"].send(event["args"])
def part(self, event):
event["server"].send_part(event["args_split"][0])