Force checking mate when done via command

master
q3k 2015-09-27 18:38:21 +02:00
parent d4ac18254e
commit 134e892077
1 changed files with 4 additions and 3 deletions

View File

@ -33,7 +33,8 @@ local function GetPackStatus(ID)
return ParsePackXML(Body)
end
local function CheckMate(IRC)
local function CheckMate(IRC, Force)
Force = Force or false
local Now = os.time()
local Redis = GetRedisClient()
if Redis == nil then
@ -43,7 +44,7 @@ local function CheckMate(IRC)
for _, ID in pairs(Redis:smembers("paczkomate:ids")) do
local LastChecked = tonumber(Redis:hget("paczkomate:objects:" .. ID, "lastchecked"))
local LastStatus = Redis:hget("paczkomate:objects:" .. ID, "status")
if Now > LastChecked + 600 then
if Now > LastChecked + 600 or Force then
Redis:hset("paczkomate:objects:" .. ID, "lastchecked", Now)
local NewStatus = GetPackStatus(ID)
if NewStatus ~= LastStatus then
@ -92,6 +93,6 @@ plugin.AddCommand('check-paczkomate', 0, function(Username, Channel)
Channel:Say("#hackerspace-pl-members only, dear.")
return
end
CheckMate(Channel._irc)
CheckMate(Channel._irc, true)
Channel:Say("Done.")
end)