From de2d6cb1972b9149fc52663f19620e64b73989dd Mon Sep 17 00:00:00 2001 From: chotee Date: Thu, 12 Jan 2017 12:30:49 +0100 Subject: [PATCH] Making checkin response more sensible when the space is closed. Informing that member list is emptied when closing the space. --- checkin.py | 7 ++++++- spacestatechange.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/checkin.py b/checkin.py index 0c808d2..721ac08 100644 --- a/checkin.py +++ b/checkin.py @@ -1,8 +1,10 @@ import urllib2 -import time + import willie from willie.module import commands, interval +from spacestatechange import SPACESTATE + INTERVAL = 5 SPACESTATE="unknown" CHANNEL = "#techinc" @@ -29,6 +31,9 @@ def trackstate(bot): def checkin(bot, trigger): """Adds you in to the list of people currently in the space""" global WHO + if SPACESTATE == "closed": + "Space is closed. %s cannot check-in. D'oh!" % trigger.nick + return if trigger.host == 'bugblue.sponsor.oftc.net': bot.say(trigger.nick + ' could not be checked in') return diff --git a/spacestatechange.py b/spacestatechange.py index 1fe3f8d..a4e2a7c 100644 --- a/spacestatechange.py +++ b/spacestatechange.py @@ -3,6 +3,8 @@ import willie from willie.module import commands, interval +from checkin import emptylist + INTERVAL = 5 SPACESTATE = "unknown" CHANNEL = "#techinc" @@ -40,12 +42,14 @@ def trackstate(bot): def togglestate(bot, trigger): """Toggles the state of the space (open/closed)""" currentstate = checkstate() - bot.say('Changing Spacestate') if currentstate == 'open': - state = 'closed' + newstate = 'closed' else: - state = 'open' - changestate(state) + newstate = 'open' + bot.say('Changing Spacestate from %s to %s' % (currentstate, newstate)) + changestate(newstate) + if newstate == 'closed': + emptylist(bot, trigger) @willie.module.commands('spacestate') @willie.module.example('.spacestate', 'spacestate')