Terminal-Nachrichten zeigen nun Dateien etc. an

This commit is contained in:
Akamaru 2016-08-28 14:51:33 +02:00
parent caba3c835d
commit e341938b32

View File

@ -73,29 +73,47 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec
end end
if msg.from.first_name then if msg.from.first_name then
name1 = '\27[1m\27[31m'..msg.from.first_name..'\27[0m' name1 = msg.from.first_name
else else
name1 = '' name1 = ''
end end
if msg.from.last_name then if msg.from.last_name then
name2 = '\27[1m\27[31m'..msg.from.last_name..'\27[0m' name2 = msg.from.last_name
else else
name2 = '' name2 = ''
end end
if msg.from.username then if msg.from.username then
name3 = ' (@'..msg.from.username..'\27[0m)' name3 = ' (@'..msg.from.username..')'
else else
name3 = '' name3 = ''
end end
full_name = name1..' '..name2..name3 full_name = '\27[1m\27[31m'..name1..' '..name2..'\27[0m'..name3
if msg.text then if msg.text then
user_msg = msg.text..'\27[0m' user_msg = msg.text..'\27[0m'
elseif msg.caption then
user_msg = msg.caption..'\27[0m'
else else
user_msg = '' user_msg = ''
end end
full_message = msg_time..from_chat..full_name..' >>> '..user_msg if msg.photo then
filetext = '[Foto] '
elseif msg.video then
filetext = '[Video] '
elseif msg.sticker then
filetext = '[Sticker] '
elseif msg.voice then
filetext = '[Sprachnachricht] '
elseif msg.audio then
filetext = '[Audio] '
elseif msg.document then
filetext = '[Datei] '
else
filetext = ''
end
full_message = msg_time..from_chat..full_name..' >>> '..filetext..user_msg
print(full_message) print(full_message)
if msg.date < os.time() - 5 then return end -- Do not process old messages. if msg.date < os.time() - 5 then return end -- Do not process old messages.