diff --git a/icingabot.py b/icingabot.py index 14f839a..e449797 100755 --- a/icingabot.py +++ b/icingabot.py @@ -20,7 +20,6 @@ from itertools import groupby import requests import irc.bot -import irc.strings """A simple IRC Bot statusing icinga2. @@ -192,19 +191,19 @@ class IcingaBot(Icinga2ServiceManager, irc.bot.SingleServerIRCBot): self.nick = nickname self.channel = channel self.connection.execute_every(30, self.refresh_ko_services) + self.connection.execute_every(300, self.refresh_nick) self.refresh_ko_services() - def suffix_nick(self, suffix): - self.nick_suffix = suffix + def refresh_nick(self): if self.connection.is_connected(): - self.connection.nick("{}{}".format(self.nick, suffix)) + self.connection.nick("{}{}".format(self.nick, self.nick_suffix)) def unmute(self): self.muted = False if self.ko_services: - self.suffix_nick("[{}]".format(len(self.ko_services))) + self.nick_suffix = "[{}]".format(len(self.ko_services)) else: - self.suffix_nick("") + self.nick_suffix = "" def send(self, msg): if not self.muted and self.connection.is_connected(): @@ -216,9 +215,9 @@ class IcingaBot(Icinga2ServiceManager, irc.bot.SingleServerIRCBot): if lost is False and news is False: return if self.ko_services: - self.suffix_nick("[{}]".format(len(self.ko_services))) + self.nick_suffix = "[{}]".format(len(self.ko_services)) else: - self.suffix_nick("") + self.nick_suffix = "" return def on_nicknameinuse(self, c, e): @@ -336,7 +335,7 @@ class IcingaBot(Icinga2ServiceManager, irc.bot.SingleServerIRCBot): def do_mute(self, c, e): self.muted = True - self.suffix_nick("[zZz]") + self.nick_suffix = "[zZz]" self.connection.execute_delayed(3600, self.refresh_ko_services) def do_command(self, e, cmd):