From 02bebb663c959375daa9b9cac7b80c583450a71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Tue, 6 Nov 2012 04:14:55 +0100 Subject: [PATCH] Fix various error on DCC connection and post treated messages --- bot.py | 3 ++- modules/alias/__init__.py | 5 ++++- response.py | 12 ++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 2f61b6b..7ed043c 100644 --- a/bot.py +++ b/bot.py @@ -28,6 +28,7 @@ import event import hooks from networkbot import NetworkBot from IRCServer import IRCServer +from DCC import DCC import response ID_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -94,7 +95,7 @@ class Bot: def _ctcp_dcc(self, srv, msg): """Response to DCC CTCP message""" - ip = self.srv.toIP(int(msg.cmds[3])) + ip = srv.toIP(int(msg.cmds[3])) conn = DCC(srv, msg.sender) if conn.accept_user(ip, int(msg.cmds[4])): srv.dcc_clients[conn.sender] = conn diff --git a/modules/alias/__init__.py b/modules/alias/__init__.py index 307a1c5..3621f44 100644 --- a/modules/alias/__init__.py +++ b/modules/alias/__init__.py @@ -109,7 +109,10 @@ def replace_variables(cnt, msg=None): def treat_variables(res): for i in range(0, len(res.messages)): - res.messages[i] = replace_variables(res.messages[i], res) + if isinstance(res.messages[i], list): + res.messages[i] = replace_variables(", ".join(res.messages[i]), res) + else: + res.messages[i] = replace_variables(res.messages[i], res) return True def treat_alias(msg, hooks_cache): diff --git a/response.py b/response.py index a4489c6..98bb30c 100644 --- a/response.py +++ b/response.py @@ -41,10 +41,14 @@ class Response: @property def content(self): - if self.title is not None: - return self.title + ", ".join(self.messages) - else: - return ", ".join(self.messages) + #FIXME: error when messages in self.messages are list! + try: + if self.title is not None: + return self.title + ", ".join(self.messages) + else: + return ", ".join(self.messages) + except: + return "" def set_sender(self, sender): if sender is None or sender.find("!") < 0: