save user last name
This commit is contained in:
parent
48b17bd5d0
commit
1c96903cc0
13
bot/bot.lua
13
bot/bot.lua
@ -228,14 +228,23 @@
|
||||
function update_user_stats(msg)
|
||||
-- Save user to _users table
|
||||
local from_id = tostring(msg.from.id)
|
||||
if (_users[from_id] == nil) then
|
||||
local user_name = get_name(msg)
|
||||
-- If last name is nil dont save last_name.
|
||||
local user_last_name = msg.from.last_name
|
||||
local user_print_name = msg.from.print_name
|
||||
print ("user_last_name", user_last_name)
|
||||
if _users[from_id] == nil then
|
||||
_users[from_id] = {
|
||||
name = get_name(msg),
|
||||
name = user_name,
|
||||
last_name = user_last_name,
|
||||
print_name = user_print_name,
|
||||
msg_num = 1
|
||||
}
|
||||
else
|
||||
local actual_num = _users[from_id].msg_num
|
||||
_users[from_id].msg_num = actual_num + 1
|
||||
-- And update last_name
|
||||
_users[from_id].last_name = user_last_name
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -9,7 +9,11 @@ function run(msg, matches)
|
||||
|
||||
local text = ""
|
||||
for id, user in pairs(_users) do
|
||||
text = text..user.name..": "..user.msg_num.."\n"
|
||||
if user.last_name == nil then
|
||||
text = text..user.name..": "..user.msg_num.."\n"
|
||||
else
|
||||
text = text..user.name.." "..user.last_name..": "..user.msg_num.."\n"
|
||||
end
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
Reference in New Issue
Block a user