Mercurial > libervia-backend
comparison src/plugins/plugin_misc_text_commands.py @ 518:75216d94a89d
primitivus: fixed messages order in chat window
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Oct 2012 12:03:29 +0200 |
parents | 59b32c04e105 |
children | b7577230a7c8 |
comparison
equal
deleted
inserted
replaced
517:59b32c04e105 | 518:75216d94a89d |
---|---|
75 if arg[-1] !='@': | 75 if arg[-1] !='@': |
76 return jid.JID(arg) | 76 return jid.JID(arg) |
77 return jid.JID(arg+service_jid) | 77 return jid.JID(arg+service_jid) |
78 return jid.JID(u"%s@%s" % (arg, service_jid)) | 78 return jid.JID(u"%s@%s" % (arg, service_jid)) |
79 | 79 |
80 def _feedBack(self, message, mess_data, profile): | |
81 """Give a message back to the user""" | |
82 if mess_data["type"] == 'groupchat': | |
83 _from = mess_data["to"].userhostJID() | |
84 else: | |
85 _from = self.host.getJidNStream(profile)[0] | |
86 | |
87 self.host.bridge.newMessage(unicode(mess_data["to"]), message, mess_data['type'], unicode(_from), {}, profile=profile) | |
88 | |
80 def cmd_nick(self, mess_data, profile): | 89 def cmd_nick(self, mess_data, profile): |
81 """change nickname""" | 90 """change nickname""" |
82 debug("Catched nick command") | 91 debug("Catched nick command") |
83 | 92 |
84 if mess_data['type'] != "groupchat": | 93 if mess_data['type'] != "groupchat": |
146 | 155 |
147 if subject: | 156 if subject: |
148 room = mess_data["to"] | 157 room = mess_data["to"] |
149 self.host.plugins["XEP-0045"].subject(room, subject, profile) | 158 self.host.plugins["XEP-0045"].subject(room, subject, profile) |
150 | 159 |
160 return False | |
161 | |
162 def cmd_ignore(self, mess_data, profile): | |
163 """Add an entity to ignore list""" | |
164 nick = mess_data["unparsed"].strip() | |
165 | |
166 if mess_data['type'] == "groupchat": | |
167 #if we are in a group chat, a nick must be given as argument | |
168 if not nick: | |
169 return False | |
170 room = mess_data["to"] | |
171 if not self.host.plugins["XEP-0045"].isNickInRoom(room, nick): | |
172 self._feedBack(u"[%s] is not in this room, can't ignore it" % (nick,), mess_data, profile) | |
173 return False | |
174 full_jid = jid.JID(u"%s/%s" % (room.userhost(), nick)) | |
175 else: | |
176 if nick: | |
177 self._feedBack("/ignore doesn't support arguments if you are not in a room", mess_data, profile) | |
178 return False | |
179 full_jid = mess_data["to"] | |
180 | |
181 self.host.getClient(profile).ignore(full_jid) | |
182 self._feedBack(_(u"[%s] added to ignore list") % full_jid, mess_data, profile) | |
151 return False | 183 return False |
152 | 184 |
153 def cmd_help(self, mess_data, profile): | 185 def cmd_help(self, mess_data, profile): |
154 """show help on available commands""" | 186 """show help on available commands""" |
155 commands=filter(lambda method: method.startswith('cmd_'), dir(self)) | 187 commands=filter(lambda method: method.startswith('cmd_'), dir(self)) |
163 except AttributeError: | 195 except AttributeError: |
164 help_str = '' | 196 help_str = '' |
165 spaces = (longuest - len(command)) * ' ' | 197 spaces = (longuest - len(command)) * ' ' |
166 help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str)) | 198 help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str)) |
167 | 199 |
168 if mess_data["type"] == 'groupchat': | |
169 _from = mess_data["to"].userhostJID() | |
170 else: | |
171 _from = self.host.getJidNStream(profile)[0] | |
172 | |
173 help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),) | 200 help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),) |
174 | 201 self._feedBack(help_mess, mess_data, profile) |
175 self.host.bridge.newMessage(unicode(mess_data["to"]), help_mess, mess_data['type'], unicode(_from), {}, profile=profile) | 202 |
176 | 203 |
177 | |
178 |