Fix various error on DCC connection and post treated messages

This commit is contained in:
Némunaire 2012-11-06 04:14:55 +01:00
parent aa697a36d0
commit 02bebb663c
3 changed files with 14 additions and 6 deletions

3
bot.py
View File

@ -28,6 +28,7 @@ import event
import hooks import hooks
from networkbot import NetworkBot from networkbot import NetworkBot
from IRCServer import IRCServer from IRCServer import IRCServer
from DCC import DCC
import response import response
ID_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ID_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -94,7 +95,7 @@ class Bot:
def _ctcp_dcc(self, srv, msg): def _ctcp_dcc(self, srv, msg):
"""Response to DCC CTCP message""" """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) conn = DCC(srv, msg.sender)
if conn.accept_user(ip, int(msg.cmds[4])): if conn.accept_user(ip, int(msg.cmds[4])):
srv.dcc_clients[conn.sender] = conn srv.dcc_clients[conn.sender] = conn

View File

@ -109,6 +109,9 @@ def replace_variables(cnt, msg=None):
def treat_variables(res): def treat_variables(res):
for i in range(0, len(res.messages)): for i in range(0, len(res.messages)):
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) res.messages[i] = replace_variables(res.messages[i], res)
return True return True

View File

@ -41,10 +41,14 @@ class Response:
@property @property
def content(self): def content(self):
#FIXME: error when messages in self.messages are list!
try:
if self.title is not None: if self.title is not None:
return self.title + ", ".join(self.messages) return self.title + ", ".join(self.messages)
else: else:
return ", ".join(self.messages) return ", ".join(self.messages)
except:
return ""
def set_sender(self, sender): def set_sender(self, sender):
if sender is None or sender.find("!") < 0: if sender is None or sender.find("!") < 0: