From 8bc1b541c4e7199f0db0763f4dd33758926b75e0 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Mon, 1 Aug 2016 02:02:13 +0200 Subject: [PATCH] =?UTF-8?q?-=20Hello:=20send=5Fmessage,=20statt=20send=5Fr?= =?UTF-8?q?eply=20-=20Stats:=20Z=C3=A4hle=20alle=20Nachrichten=20zusammen?= =?UTF-8?q?=20und=20verwnede=20comma=5Fvalue()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/plugins/hello.lua | 2 +- otouto/plugins/stats.lua | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/otouto/plugins/hello.lua b/otouto/plugins/hello.lua index 2d3483e..25a1101 100644 --- a/otouto/plugins/hello.lua +++ b/otouto/plugins/hello.lua @@ -5,7 +5,7 @@ hello.triggers = { } function hello:action(msg, config, matches) - utilities.send_reply(self, msg, 'Hallo, '..matches[1]..'!') + utilities.send_message(self, msg.chat.id, 'Hallo, '..matches[1]..'!') end return hello diff --git a/otouto/plugins/stats.lua b/otouto/plugins/stats.lua index 0e920be..3ba40bd 100644 --- a/otouto/plugins/stats.lua +++ b/otouto/plugins/stats.lua @@ -53,6 +53,13 @@ function stats:chat_stats(chat_id) local user_info = stats:get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end + + -- Get total message count + local all_msgs = 0 + for n, user in pairs(users_info) do + local msg_num = users_info[n].msgs + all_msgs = all_msgs + msg_num + end -- Sort users by msgs number table.sort(users_info, function(a, b) @@ -63,10 +70,11 @@ function stats:chat_stats(chat_id) local text = '' for k,user in pairs(users_info) do - text = text..user.name..': '..user.msgs..'\n' + text = text..user.name..': '..comma_value(user.msgs)..'\n' text = string.gsub(text, "%_", " ") -- Bot API doesn't use underscores anymore! Yippie! end if text:isempty() then return 'Keine Stats für diesen Chat verfügbar!'end + local text = utilities.md_escape(text)..'\n*TOTAL*: '..comma_value(all_msgs) return text end @@ -121,7 +129,7 @@ function stats:action(msg, config, matches) return else local chat_id = msg.chat.id - utilities.send_reply(self, msg, stats:chat_stats(chat_id)) + utilities.send_reply(self, msg, stats:chat_stats(chat_id), true) return end end @@ -131,7 +139,7 @@ function stats:action(msg, config, matches) utilities.send_reply(self, msg, config.errors.sudo) return else - utilities.send_reply(self, msg, stats:chat_stats(matches[3])) + utilities.send_reply(self, msg, stats:chat_stats(matches[3]), true) return end end