def command_server_cycle(self, args): """ Do a /cycle on each room of the given server. If none, do it on the current tab """ tab = self.current_tab() message = "" if args: domain = args[0] if len(args) == 2: message = args[1] else: if isinstance(tab, tabs.MucTab): domain = safeJID(tab.name).domain else: return self.information(_("No server specified"), "Error") for tab in self.get_tabs(tabs.MucTab): if tab.name.endswith(domain): if tab.joined: muc.leave_groupchat(tab.core.xmpp, tab.name, tab.own_nick, message) tab.joined = False if tab.name == domain: self.command_join('"@%s/%s"' %(tab.name, tab.own_nick)) else: self.command_join('"%s/%s"' %(tab.name, tab.own_nick))
def command_server_cycle(self, args): """ Do a /cycle on each room of the given server. If none, do it on the current tab """ tab = self.current_tab() message = "" if args: domain = args[0] if len(args) == 2: message = args[1] else: if isinstance(tab, tabs.MucTab): domain = safeJID(tab.name).domain else: return self.information("No server specified", "Error") for tab in self.get_tabs(tabs.MucTab): if tab.name.endswith(domain): if tab.joined: muc.leave_groupchat(tab.core.xmpp, tab.name, tab.own_nick, message) tab.joined = False if tab.name == domain: self.command_join('"@%s/%s"' % (tab.name, tab.own_nick)) else: self.command_join('"%s/%s"' % (tab.name, tab.own_nick))
def on_groupchat_message(self, message): """ Triggered whenever a message is received from a multi-user chat room. """ if message['subject']: return room_from = message['from'].bare if message['type'] == 'error': # Check if it's an error return self.room_error(message, room_from) tab = self.get_tab_by_name(room_from, tabs.MucTab) if not tab: self.information(_("message received for a non-existing room: %s") % (room_from)) muc.leave_groupchat(self.xmpp, room_from, self.own_nick, msg='') return nick_from = message['mucnick'] user = tab.get_user_by_name(nick_from) if user and user in tab.ignores: return self.events.trigger('muc_msg', message, tab) use_xhtml = config.get('enable_xhtml_im') tmp_dir = config.get('tmp_image_dir') or path.join(CACHE_DIR, 'images') extract_images = config.get('extract_inline_images') body = xhtml.get_body_from_message_stanza(message, use_xhtml=use_xhtml, tmp_dir=tmp_dir, extract_images=extract_images) if not body: return old_state = tab.state delayed, date = common.find_delayed_tag(message) replaced_id = message['replace']['id'] replaced = False if replaced_id is not '' and config.get_by_tabname('group_corrections', message['from'].bare): try: if tab.modify_message(body, replaced_id, message['id'], time=date, nickname=nick_from, user=user): self.events.trigger('highlight', message, tab) replaced = True except CorrectionError: log.debug('Unable to correct a message', exc_info=True) if not replaced and tab.add_message(body, date, nick_from, history=delayed, identifier=message['id'], jid=message['from'], typ=1): self.events.trigger('highlight', message, tab) if message['from'].resource == tab.own_nick: tab.last_sent_message = message if tab is self.current_tab(): tab.text_win.refresh() tab.info_header.refresh(tab, tab.text_win) tab.input.refresh() self.doupdate() elif tab.state != old_state: self.refresh_tab_win() current = self.current_tab() if hasattr(current, 'input') and current.input: current.input.refresh() self.doupdate() if 'message' in config.get('beep_on').split(): if (not config.get_by_tabname('disable_beep', room_from) and self.own_nick != message['from'].resource): curses.beep()