Lot of fixes

Use a partner to transform nick to login_x
Add questions support into qd.py
This commit is contained in:
Némunaire 2012-05-14 17:50:11 +02:00
parent 69c5d06ed7
commit 5004752660
10 changed files with 462 additions and 72 deletions

View file

@ -6,6 +6,11 @@ import time
import message
#class WaitedAnswer:
# def __init__(self, channel):
# self.channel = channel
# self.module
class Server:
def __init__(self, server, nick, owner, realname):
self.nick = nick
@ -25,18 +30,28 @@ class Server:
else:
self.password = None
self.waited_answer = list()
self.listen_nick = True
self.partner = "nbr23"
self.channels = list()
for channel in server.getElementsByTagName('channel'):
self.channels.append(channel.getAttribute("name"))
@property
def id(self):
return self.host + ":" + str(self.port)
def send_msg_final(self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
if msg is not None and channel is not None:
for line in msg.split("\n"):
if line != "":
self.s.send (("%s %s :%s%s" % (cmd, channel, line, endl)).encode ())
def send_msg_prtn (self, msg):
self.send_msg_final(self.partner, msg)
def send_msg_usr (self, user, msg):
if user is not None and user[0] != "#":
self.send_msg_final(user, msg)
@ -50,6 +65,9 @@ class Server:
self.send_msg (channel, msg, cmd, endl)
def register_answer(self, channel, ):
self.waited_answer.append(channel)
def launch(self, mods, datas_dir):
self.datas_dir = datas_dir
_thread.start_new_thread(self.connect, (mods,))