quick_frontend, wix, primitivus: informations in chat window
- user joined/left information - messages starting with /me are managed
This commit is contained in:
parent
03e9f23b01
commit
36d51e6acf
1 changed files with 72 additions and 17 deletions
|
|
@ -56,7 +56,10 @@ class QuickChat():
|
|||
if self.type != "group":
|
||||
error (_("[INTERNAL] trying to replace user for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
len_before = len(self.occupants)
|
||||
self.occupants.add(nick)
|
||||
if len_before != len(self.occupants):
|
||||
self.printInfo("=> %s has joined the room" % nick)
|
||||
|
||||
def setUserNick(self, nick):
|
||||
"""Set the nick of the user, usefull for e.g. change the color of the user"""
|
||||
|
|
@ -69,6 +72,7 @@ class QuickChat():
|
|||
error (_("[INTERNAL] trying to remove user for a non group chat window"))
|
||||
raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
|
||||
self.occupants.remove(nick)
|
||||
self.printInfo("=> %s has left the room" % nick)
|
||||
|
||||
def setSubject(self, subject):
|
||||
"""Set title for a group chat"""
|
||||
|
|
@ -88,9 +92,29 @@ class QuickChat():
|
|||
if keep_last: ##FIXME hack for sortilege
|
||||
self.last_history = stamps[-1] if stamps else None
|
||||
|
||||
def _get_nick(self, jid):
|
||||
"""Return nick of this jid when possible"""
|
||||
return jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid.node)
|
||||
|
||||
def printMessage(self, from_jid, msg, profile, timestamp):
|
||||
"""Print message in chat window. Must be implemented by child class"""
|
||||
jid=JID(from_jid)
|
||||
nick = self._get_nick(jid)
|
||||
mymess = (jid.resource == self.nick) if self.type == "group" else (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user
|
||||
if msg.startswith('/me '):
|
||||
self.printInfo('* %s %s' % (nick, msg[4:]),type='me')
|
||||
return
|
||||
return jid, nick, mymess
|
||||
|
||||
def printInfo(self, msg, type='normal'):
|
||||
"""Print general info
|
||||
@param msg: message to print
|
||||
@type: one of:
|
||||
normal: general info like "toto has joined the room"
|
||||
me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def startGame(self, game_type, referee, players):
|
||||
"""Configure the chat window to start a game"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue