From f5b36601817ca47b9087f167bbc24128c6ba3fae Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 23 Aug 2018 12:47:10 +0200 Subject: [PATCH] ircbot: check always topic --- sopel-bot/default.cfg | 8 ++++---- sopel-bot/modules/spaceapi.py | 25 ++++++++++++------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sopel-bot/default.cfg b/sopel-bot/default.cfg index f8e2f3f..82d3cee 100644 --- a/sopel-bot/default.cfg +++ b/sopel-bot/default.cfg @@ -5,7 +5,7 @@ use_ssl = true verify_ssl = false port = 6697 owner = ccchb-schalter -channels = #ccchb -extra = /home/pi/Eingangsschalter/ircbot/ -enable = spaceapi - +channels = #ccchb,#ccchb-dev +enable = spaceapi,admin +admins = genofire,paradx,pyropeter +auth_method = server diff --git a/sopel-bot/modules/spaceapi.py b/sopel-bot/modules/spaceapi.py index 1b6fb18..ed361f2 100644 --- a/sopel-bot/modules/spaceapi.py +++ b/sopel-bot/modules/spaceapi.py @@ -27,18 +27,6 @@ def change_status(bot, status): for ch in bot.channels: bot.notice('{} changed to {}'.format(PLACE, status_text), ch) - topic = status_msg(status) - - for ch in bot.channels: - channel = bot.channels[ch] - topic_new = topic - topic_cur = status_msg(not status) - if channel.topic != None: - topic_new = channel.topic.replace(topic_cur, topic_new) - topic_cur = channel.topic - if topic_new != topic_cur: - bot.write(('TOPIC', ch), topic_new) - def check_status(bot, human=False): data = get_spaceapi() status = data["state"]["open"] @@ -47,8 +35,19 @@ def check_status(bot, human=False): cache["open"] = status change_status(bot, status) + status_text = status_msg(status) + for ch in bot.channels: + channel = bot.channels[ch] + topic_new = status_text + topic_cur = status_msg(not status) + if channel.topic != None: + topic_new = channel.topic.replace(topic_cur, topic_new) + topic_cur = channel.topic + if topic_new != topic_cur: + bot.write(('TOPIC', ch), topic_new) + if human: - bot.reply(status_msg(status)) + bot.reply(status_text) @sopel.module.interval(5) def interval_check_status(bot):