Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_chat.py @ 812:084b52afdceb
frontends: fixed /me usage + renamed a couple of "type" parameters to type_
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:51:16 +0100 |
parents | 1fe00f0c9a91 |
children | cd02f5ef30df |
comparison
equal
deleted
inserted
replaced
811:1fe00f0c9a91 | 812:084b52afdceb |
---|---|
24 from sat_frontends.quick_frontend.constants import Const | 24 from sat_frontends.quick_frontend.constants import Const |
25 | 25 |
26 | 26 |
27 class QuickChat(object): | 27 class QuickChat(object): |
28 | 28 |
29 def __init__(self, target, host, type='one2one'): | 29 def __init__(self, target, host, type_='one2one'): |
30 self.target = target | 30 self.target = target |
31 self.host = host | 31 self.host = host |
32 self.type = type | 32 self.type = type_ |
33 self.id = "" | 33 self.id = "" |
34 self.nick = None | 34 self.nick = None |
35 self.occupants = set() | 35 self.occupants = set() |
36 | 36 |
37 def setType(self, type): | 37 def setType(self, type_): |
38 """Set the type of the chat | 38 """Set the type of the chat |
39 @param type: can be 'one2one' for single conversation or 'group' for chat à la IRC | 39 @param type: can be 'one2one' for single conversation or 'group' for chat à la IRC |
40 """ | 40 """ |
41 self.type = type | 41 self.type = type_ |
42 | 42 |
43 def setPresents(self, nicks): | 43 def setPresents(self, nicks): |
44 """Set the users presents in the contact list for a group chat | 44 """Set the users presents in the contact list for a group chat |
45 @param nicks: list of nicknames | 45 @param nicks: list of nicknames |
46 """ | 46 """ |
128 """Print message in chat window. Must be implemented by child class""" | 128 """Print message in chat window. Must be implemented by child class""" |
129 jid=JID(from_jid) | 129 jid=JID(from_jid) |
130 nick = self._get_nick(jid) | 130 nick = self._get_nick(jid) |
131 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.bare == self.host.profiles[profile]['whoami'].bare) #mymess = True if message comes from local user | 131 mymess = (jid.resource == self.nick) if self.type == "group" else (jid.bare == self.host.profiles[profile]['whoami'].bare) #mymess = True if message comes from local user |
132 if msg.startswith('/me '): | 132 if msg.startswith('/me '): |
133 self.printInfo('* %s %s' % (nick, msg[4:]),type='me', timestamp=timestamp) | 133 self.printInfo('* %s %s' % (nick, msg[4:]), type_='me', timestamp=timestamp) |
134 return | 134 return |
135 return jid, nick, mymess | 135 return jid, nick, mymess |
136 | 136 |
137 def printInfo(self, msg, type='normal'): | 137 def printInfo(self, msg, type_='normal'): |
138 """Print general info | 138 """Print general info |
139 @param msg: message to print | 139 @param msg: message to print |
140 @type: one of: | 140 @type_: one of: |
141 normal: general info like "toto has joined the room" | 141 normal: general info like "toto has joined the room" |
142 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" | 142 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" |
143 """ | 143 """ |
144 raise NotImplementedError | 144 raise NotImplementedError |
145 | 145 |