From b11d86c4567ccac7f682b32269cf42f12b9d390a Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Tue, 16 Aug 2016 17:05:20 +0200 Subject: [PATCH] Fix: Entferne User von der Stats-Liste, wenn gekickt (falsche Reihenfolge) --- otouto/plugins/banhammer.lua | 3 +++ otouto/plugins/stats.lua | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/otouto/plugins/banhammer.lua b/otouto/plugins/banhammer.lua index d93abe6..be73241 100644 --- a/otouto/plugins/banhammer.lua +++ b/otouto/plugins/banhammer.lua @@ -48,6 +48,9 @@ function banhammer:kick_user(user_id, chat_id, self, onlykick) chat_id = chat_id, user_id = user_id } ) + local hash = 'chat:'..chat_id..':users' + print('User '..user_id..' was kicked/left the chat, deleting them from redis set '..hash) + redis:srem(hash, user_id) if onlykick then return end if not request then return 'User gebannt, aber kicken war nicht erfolgreich. Bin ich Administrator oder ist der User hier überhaupt?' end return 'User '..user_id..' gebannt!' diff --git a/otouto/plugins/stats.lua b/otouto/plugins/stats.lua index 7e4016c..7780c62 100644 --- a/otouto/plugins/stats.lua +++ b/otouto/plugins/stats.lua @@ -80,20 +80,20 @@ function stats:chat_stats(chat_id) end function stats:pre_process(msg, self) - -- Ignore service msg - if is_service_msg(msg) then - print('Service message') - return msg - end - if msg.left_chat_member then -- delete user from redis set, but keep message count local hash = 'chat:'..msg.chat.id..':users' local user_id_left = msg.left_chat_member.id - print('User '..user_id_left..' was kicked, deleting him/her from redis set '..hash) + print('User '..user_id_left..' was kicked/left the chat, deleting them from redis set '..hash) redis:srem(hash, user_id_left) return msg end + + -- Ignore service msg + if is_service_msg(msg) then + print('Service message') + return msg + end -- Save user on Redis local hash = 'user:'..msg.from.id