on peut choisir son nick lors d'un /join machin@truc/NICK

parent 33cf82e0
......@@ -25,9 +25,9 @@ from handler import Handler
from gui import Gui
from curses import wrapper, initscr
sys.stderr = open('logs', 'a')
if len(sys.argv) == 1: # not debug, so hide any error message and disable C-c
import signal
sys.stderr = open('logs', 'a')
signal.signal(signal.SIGINT, signal.SIG_IGN)
class Client(object):
......
......@@ -98,7 +98,6 @@ class Connection(Thread):
def handler_error(self, connection, error):
print "fion"
sys.exit()
# self.handler.emit('room-iq', stanza=iq)
def process(self, timeout=10):
if self.online:
......
......@@ -28,6 +28,8 @@ from logging import logger
from random import randrange
from config import config
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()
......@@ -292,6 +294,7 @@ class Gui(object):
def execute(self):
line = self.window.input.get_text()
self.window.input.clear_text()
curses.doupdate()
if line == "":
return
if line.startswith('/'):
......@@ -306,13 +309,19 @@ class Gui(object):
self.window.input.refresh()
def command_join(self, args):
room = args[0]
info = args[0].split('/')
if len(info) == 1:
nick = config.get('default_nick', 'Poezio')
else:
nick = info[1]
room = info[0]
r = self.get_room_by_name(room)
if r: # if we are already in the room
if r and r.joined: # if we are already in the room
self.information("already in room [%s]" % room)
return
self.muc.join_room(room, "poezio")
self.join_room(room, 'poezio')
self.muc.join_room(room, nick)
if not r: # if the room window exist, we don't recreate it.
self.join_room(room, nick)
def information(self, msg):
room = self.get_room_by_name("Info")
......
......@@ -64,15 +64,17 @@ class MultiUserChat(object):
mes.setType('groupchat')
self.connection.send(mes)
def join_room(self, room, nick):
def join_room(self, room, nick, password=None):
"""Join a new room"""
self.rooms.append(room)
self.rn[room] = nick
# self.rooms.append(room)
# self.rn[room] = nick
pres = Presence(to='%s/%s' % (room, nick))
pres.setFrom('%s'%self.own_jid)
pres.addChild(name='x', namespace=NS_MUC)
open('fion', 'w').write(str(pres))
if password:
pres.addChild(name='x', namespace=NS_MUC)
else:
pres.addChild(name='x', namespace=NS_MUC)
self.connection.send(pres)
def quit_room(self, room, nick):
......
......@@ -3,7 +3,5 @@ logfile = logs
resource = poezio
server = louiz.org
port = 5222
rooms = discussion@kikoo.louiz.org/poezio:test@chat.jabberfr.org/poefion
rooms = test@chat.jabberfr.org/poefion:discussion@kikoo.louiz.org/poezio
default_nick = poezio
......@@ -185,6 +185,8 @@ class Input(Win):
self.refresh()
def key_up(self):
if not len(self.history):
return
self.win.clear()
if self.histo_pos >= 0:
self.histo_pos -= 1
......@@ -194,6 +196,8 @@ class Input(Win):
self.refresh()
def key_down(self):
if not len(self.history):
return
self.win.clear()
if self.histo_pos < len(self.history)-1:
self.histo_pos += 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment