From 4952036fc9cd47609fc35c22ecddeaa60fdf734e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Poulain?= Date: Sat, 16 Jan 2021 11:03:03 +0100 Subject: [PATCH] fix(nick): ne change de nom que toutes les 5 minutes --- icingabot.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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):