1
0
forked from MTSR/telegram

Log non-text messages to the game chat, but without contents (like "sticker was sent")

This commit is contained in:
neko259 2019-02-03 22:47:15 +02:00
parent f67191ca37
commit bf832e684c

View File

@ -58,8 +58,9 @@ local function process_updates(response)
for key, update in pairs(updates.result) do
if update.message then
if update.message.text then
--print(update.message.text)
telegram.on_text_receive(update.message)
else
telegram.notify_non_text_receive(update.message)
end
end
-- TODO Other types of messages
@ -116,6 +117,20 @@ function telegram.on_text_receive(msg)
end
end
function telegram.notify_non_text_receive(message)
local payload = 'something'
if message.photo then
payload = 'photo'
elseif message.voice then
payload = 'voice message'
elseif message.sticker then
payload = 'sticker'
end
minetest.chat_send_all(message.from.first_name .. "@TG sent " .. payload)
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer + dtime