[TASK] Implement rejoin on kick; improve Kick message implementation.

This commit is contained in:
Jan Philipp Timme 2015-10-25 12:21:47 +01:00
parent f5dba3f6ef
commit b34817331e
2 changed files with 7 additions and 4 deletions

5
bot.py
View File

@ -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"]:

6
irc.py
View File

@ -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()