Stats: Prozentualer Anteil der Nachrichten eines Users am Totalwert (danke Malte!)

This commit is contained in:
Andreas Bielawski 2016-08-09 17:27:58 +02:00
parent fea1f79dcf
commit 55fca7a73d

View File

@ -70,11 +70,12 @@ function stats:chat_stats(chat_id)
local text = '' local text = ''
for k,user in pairs(users_info) do for k,user in pairs(users_info) do
text = text..user.name..': '..comma_value(user.msgs)..'\n' local msg_num = user.msgs
text = string.gsub(text, "%_", " ") -- Bot API doesn't use underscores anymore! Yippie! local percent = msg_num / all_msgs * 100
text = text..user.name..': '..comma_value(msg_num)..' <code>('..round(percent)..'%)</code>\n'
end end
if text:isempty() then return 'Keine Stats für diesen Chat verfügbar!'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) local text = text..'\n<b>TOTAL</b>: '..comma_value(all_msgs)
return text return text
end end
@ -129,7 +130,7 @@ function stats:action(msg, config, matches)
return return
else else
local chat_id = msg.chat.id local chat_id = msg.chat.id
utilities.send_reply(self, msg, stats:chat_stats(chat_id), true) utilities.send_reply(self, msg, stats:chat_stats(chat_id), 'HTML')
return return
end end
end end
@ -139,7 +140,7 @@ function stats:action(msg, config, matches)
utilities.send_reply(self, msg, config.errors.sudo) utilities.send_reply(self, msg, config.errors.sudo)
return return
else else
utilities.send_reply(self, msg, stats:chat_stats(matches[3]), true) utilities.send_reply(self, msg, stats:chat_stats(matches[3]), 'HTML')
return return
end end
end end