def send_message(self, message, xhtml=None, process_commands=True, attention=False): """ Call this method to send the message """ message = helpers.remove_invalid_xml_chars(message) if not message: return # We need to make sure that we can still send through the room and that # the recipient did not go away if self.gc_contact.presence.is_unavailable: ErrorDialog( _('Sending private message failed'), #in second %s code replaces with nickname _('You are no longer in group chat "%(room)s" or ' '"%(nick)s" has left.') % { 'room': self.room_name, 'nick': self.gc_contact.name}, transient_for=self.parent_win.window) return ChatControl.send_message(self, message, xhtml=xhtml, process_commands=process_commands, attention=attention)
def _nec_message_outgoing(self, obj): # Send the given message to the active tab. # Doesn't return None if error if obj.control != self: return obj.message = helpers.remove_invalid_xml_chars(obj.message) conn = app.connections[self.account] if not self.session: if (not obj.resource and obj.jid != app.get_jid_from_account(self.account)): if self.resource: obj.resource = self.resource else: obj.resource = self.contact.resource sess = conn.find_controlless_session(obj.jid, resource=obj.resource) if self.resource: obj.jid += '/' + self.resource if not sess: if self.type_id == TYPE_PM: sess = conn.make_new_session(obj.jid, type_='pm') else: sess = conn.make_new_session(obj.jid) self.set_session(sess) obj.session = self.session
def on_dialog_response(self, dialog, response): if response == Gtk.ResponseType.OK: beg, end = self.message_buffer.get_bounds() message = self.message_buffer.get_text(beg, end, True).strip() message = helpers.remove_invalid_xml_chars(message) msg = helpers.to_one_line(message) if self.show: app.config.set_per('statusmsg', '_last_' + self.show, 'message', msg) if self.show_pep: app.config.set_per('statusmsg', '_last_' + self.show, 'activity', self.pep_dict['activity']) app.config.set_per('statusmsg', '_last_' + self.show, 'subactivity', self.pep_dict['subactivity']) app.config.set_per('statusmsg', '_last_' + self.show, 'activity_text', self.pep_dict['activity_text']) app.config.set_per('statusmsg', '_last_' + self.show, 'mood', self.pep_dict['mood']) app.config.set_per('statusmsg', '_last_' + self.show, 'mood_text', self.pep_dict['mood_text']) else: message = None # user pressed Cancel button or X wm button self.dialog.destroy() self.on_response(message, self.pep_dict)
def _change_status(self, *args): self.stop_timeout() beg, end = self._message_buffer.get_bounds() message = self._message_buffer.get_text(beg, end, True).strip() message = remove_invalid_xml_chars(message) if self._show_pep: self._send_user_activity() self._send_user_mood() if self._callback is not None: self._callback(message) else: self._send_status_and_message(message) self.destroy()