From b34817331e0dcdccb96614f2295722d6edaca17d Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 25 Oct 2015 12:21:47 +0100 Subject: [PATCH] [TASK] Implement rejoin on kick; improve Kick message implementation. --- bot.py | 5 +++++ irc.py | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index dbe04aa..beba888 100644 --- a/bot.py +++ b/bot.py @@ -77,6 +77,7 @@ class IrcProtocol(ManagedProtocol): super(IrcProtocol, self).connection_made(transport) self.send_msg(irc.User(self._config["ident"], self._config["realname"])) self.send_msg(irc.Nick(self._config["nick"])) + self.nick = self._config["nick"] def data_received(self, data): super(IrcProtocol, self).data_received(data) @@ -111,6 +112,10 @@ class IrcProtocol(ManagedProtocol): text = msg.message.strip("\x01") if text.upper() == "VERSION": self.send_msg(irc.Privmsg(msg.get("nick"), "\x01HalloWelt lustiger Client v0.0.1\x01")) + if isinstance(msg, irc.Kick): + if msg.target == self.nick: + self.send_msg(irc.Join(msg.channel)) + self.send_msg(irc.Privmsg(msg.channel, "Hey, das war nicht nett!")) def ready(self): for channel in self._config["channels"]: diff --git a/irc.py b/irc.py index ddcbd81..fee8e1c 100644 --- a/irc.py +++ b/irc.py @@ -177,7 +177,8 @@ class Kick(Message, metaclass=register_derivative): }) def parse(self): self.source = self.get("subject") - self.target = self.get("params")[0] + self.channel = self.get("params")[0] + self.target = self.get("params")[1] self.message = self.get("trailing") class Join(Message, metaclass=register_derivative): @@ -219,7 +220,6 @@ class Mode(Message, metaclass=register_derivative): self.usermode = False self.source = self.get("nick") self.subject = self.get("params")[0] - print(self.get("params")) if(self.source == self.subject): """Parsing user modes here.""" self.usermode = True @@ -276,7 +276,5 @@ if __name__ == "__main__": d = msg.__dict__ del d["data"] print(d) - print() - exit()