def on_enter(self): txt = self.input.key_enter() if txt: if not self.execute_command(txt): if txt.startswith('//'): txt = txt[1:] self.command_say(xhtml.convert_simple_to_full_colors(txt)) self.cancel_paused_delay()
def command_marquee(self, args): tab = self.api.current_tab() args = xhtml.clean_text(xhtml.convert_simple_to_full_colors(args)) tab.command_say(args) is_muctab = isinstance(tab, tabs.MucTab) msg_id = tab.last_sent_message["id"] jid = tab.name event = self.api.create_delayed_event(self.config.get("refresh"), self.delayed_event, jid, args, msg_id, 1, 0, is_muctab) self.api.add_timed_event(event)
def execute_command(self, provided_text): """ Execute the command in the input and return False if the input didn't contain a command """ txt = provided_text or self.input.key_enter() if txt.startswith('/') and not txt.startswith('//') and\ not txt.startswith('/me '): command = txt.strip().split()[0][1:] arg = txt[2+len(command):] # jump the '/' and the ' ' func = None if command in self.commands: # check tab-specific commands func = self.commands[command][0] elif command in self.core.commands: # check global commands func = self.core.commands[command][0] else: low = command.lower() if low in self.commands: func = self.commands[low][0] elif low in self.core.commands: func = self.core.commands[low][0] else: if self.missing_command_callback is not None: error_handled = self.missing_command_callback(low) if not error_handled: self.core.information("Unknown command (%s)" % (command), 'Error') if command in ('correct', 'say'): # hack arg = xhtml.convert_simple_to_full_colors(arg) else: arg = xhtml.clean_text_simple(arg) if func: if hasattr(self.input, "reset_completion"): self.input.reset_completion() func(arg) return True else: return False
def execute_command(self, provided_text): """ Execute the command in the input and return False if the input didn't contain a command """ txt = provided_text or self.input.key_enter() if txt.startswith('/') and not txt.startswith('//') and\ not txt.startswith('/me '): command = txt.strip().split()[0][1:] arg = txt[2 + len(command):] # jump the '/' and the ' ' func = None if command in self.commands: # check tab-specific commands func = self.commands[command][0] elif command in self.core.commands: # check global commands func = self.core.commands[command][0] else: low = command.lower() if low in self.commands: func = self.commands[low][0] elif low in self.core.commands: func = self.core.commands[low][0] else: if self.missing_command_callback is not None: error_handled = self.missing_command_callback(low) if not error_handled: self.core.information( "Unknown command (%s)" % (command), 'Error') if command in ('correct', 'say'): # hack arg = xhtml.convert_simple_to_full_colors(arg) else: arg = xhtml.clean_text_simple(arg) if func: if hasattr(self.input, "reset_completion"): self.input.reset_completion() func(arg) return True else: return False