def on_message(self, network, channel): log.debug('in on_message') if network.name in self.network_channels and channel.name in self.network_channels[network.name]: channel_window = self.network_channels[network.name][channel.name] channel_window.on_message(network, channel) else: log.warning('message for unknown channel {0}'.format(channel.name))
def process_commands(self): while self.running: try: command, network, params = self.next_command(block=True) log.info('processing command {0} from {1} with parameters {2}'.format(command, network, params)) method = 'command_' + command if hasattr(self, method): getattr(self, method)(network, params) else: log.warning('method {0} not found, command discarded'.format(method)) except Exception as e: log.exception('exception processing command: {0}'.format(e))
def command_connect(self, name, params, explicit=True): if name is None: for name in self.network_config: self.command_connect(name, params, explicit=False) elif name in self.network_config: if explicit or self.network_config[name]['connect']: network = Network(name, self.network_config[name], self.irc) connection = network.connect() self.networks[name] = network self.connections[connection] = network else: log.warning('network {0} not found in configuration, could not connect'.format(name))
def notify(self, *args, **params): try: event = args[0] t = type(event) if t == str: event_type = event args.pop(0) elif t == pyranha.irc.client.Event: event_type = event.eventtype() event_type = event_type.replace('-', '_') method = getattr(self, 'on_' + event_type) except AttributeError: log.warning('{0} does not support {1}'.format(self, event_type)) else: method(*args, **params)
def update_theme(self): load_themes() config = Dotfile('config') theme = config['theme'] if theme not in themes: log.warning('configured theme "{0}" not found; falling back to native'.format(theme)) theme = 'native' theme = themes[theme] css = theme.render() if self.css_provider is not None: Gtk.StyleContext.remove_provider_for_screen(Gdk.Screen.get_default(), self.css_provider) self.css_provider = Gtk.CssProvider() self.css_provider.load_from_data(css) Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), self.css_provider, 900)