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

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