From 70b416b5ae277764424ddc1c320a27000fcd1ffc Mon Sep 17 00:00:00 2001 From: Mallory Hancock Date: Tue, 10 Oct 2017 08:55:47 -0700 Subject: [PATCH] create Message object to send to plugins --- pinhook/bot.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pinhook/bot.py b/pinhook/bot.py index 5627b02..0ad0438 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -5,6 +5,15 @@ import irc.bot irc.client.ServerConnection.buffer_class.errors = 'replace' +class Message: + def __init__(self, channel, nick, cmd, arg, botnick, ops): + self.channel = channel + self.nick = nick + self.cmd = cmd + self.arg = arg + self.botnick = botnick + self.ops = ops + class Bot(irc.bot.SingleServerIRCBot): def __init__(self, channels, nickname, server, port=6667, ops=[], plugin_dir='plugins'): @@ -60,7 +69,14 @@ class Bot(irc.bot.SingleServerIRCBot): msg = ', '.join(helplist) c.privmsg(chan, 'Available commands: {}'.format(msg)) elif cmd in self.cmds: - output = self.cmds[cmd](cmd=cmd, nick=nick, arg=arg) + output = self.cmds[cmd](Message( + channel=chan, + cmd=cmd, + nick=nick, + arg=arg, + botnick=self.bot_nick, + ops=self.ops + )) if output: if output.msg_type == 'message':