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,7 +109,10 @@ 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)):
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 return True
def treat_alias(msg, hooks_cache): def treat_alias(msg, hooks_cache):

View File

@ -41,10 +41,14 @@ class Response:
@property @property
def content(self): def content(self):
if self.title is not None: #FIXME: error when messages in self.messages are list!
return self.title + ", ".join(self.messages) try:
else: if self.title is not None:
return ", ".join(self.messages) return self.title + ", ".join(self.messages)
else:
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: