def update_title(self): """Update title.""" try: self.widget.set_title( color.remove(self.data['title'].decode('utf-8'))) except: self.widget.set_title(None)
def update_title(self): """Update title.""" try: self.widget.set_title( color.remove(self.data['title'].decode('utf-8'))) except: # noqa: E722 self.widget.set_title(None)
def parse_buffer(self, buf, lines=None): """Check the buffer object and send any needed notifications.""" if ("local_variables" not in buf.data or 'notify' not in buf.data): return local_var = buf.data["local_variables"] if ((buf.data['notify'] == 0 and not buf.flag()) or not lines or 'type' not in local_var or 'nick' not in local_var): return line = lines[-1][1] prefix = color.remove(line[1]).strip(" ") text = color.remove(line[2]) if prefix == local_var["nick"] or (prefix == "*" and text.split(" ", 1)[0] == prefix): return d = datetime.datetime.fromtimestamp(float(line[0])) date_str = d.strftime(self._time_format) title = buf.data["full_name"] + " " + date_str cmd_str = title + " " + prefix + " " + text # Play a sound. Highlight has priority, then type, then buffer flag. if buf.highlight and self._config_get("highlight.sound"): self.play_sound(self._config_get("highlight.sound")) elif self._config_get(local_var["type"] + ".sound"): self.play_sound(self._config_get(local_var["type"] + ".sound")) elif buf.flag("beep"): self.play_sound(self.config.get("notifications", "beep_sound")) # Run a custom command. if buf.highlight and self._config_get("highlight.command"): call([self._config_get("highlight.command"), cmd_str]) elif self._config_get(local_var["type"] + ".command"): call([self._config_get(local_var["type"] + ".command"), cmd_str]) # Output to a file. if buf.highlight and self._config_get("highlight.file"): self._log(cmd_str, self._config_get("highlight.file")) elif self._config_get(local_var["type"] + ".file"): self._log(cmd_str, (self._config_get(local_var["type"] + ".file"))) # Display tray activity. if (buf.highlight and self._config_get("highlight.tray") == "on" or self._config_get(local_var["type"] + ".tray") == "on" or buf.flag("tray")): if self.config.get("notifications", "tray_icon") == "unread": self.tray_icon.show() self.add_record(buf.data["full_name"], buf.data["short_name"], date_str, prefix, text) self.set_icon("hot") # Display a notification message. if (buf.highlight and self._config_get("highlight.message") == "on" or self._config_get(local_var["type"] + ".message") == "on" or buf.flag("beep")): self.show_message(title, prefix + " " + text) # Flags the taskbar as highlighted. if (buf.highlight and self._config_get("highlight.taskbar") == "on" or self._config_get(local_var["type"] + ".taskbar") == "on" or buf.flag("taskbar")): self.taskbar_activity.add(buf.data["full_name"]) self._update_taskbar_state()