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
1 changed files with 23 additions and 5 deletions

View File

@ -73,29 +73,47 @@ function bot:on_msg_receive(msg, config) -- The fn run whenever a message is rec
end
if msg.from.first_name then
name1 = '\27[1m\27[31m'..msg.from.first_name..'\27[0m'
name1 = msg.from.first_name
else
name1 = ''
end
if msg.from.last_name then
name2 = '\27[1m\27[31m'..msg.from.last_name..'\27[0m'
name2 = msg.from.last_name
else
name2 = ''
end
if msg.from.username then
name3 = ' (@'..msg.from.username..'\27[0m)'
name3 = ' (@'..msg.from.username..')'
else
name3 = ''
end
full_name = name1..' '..name2..name3
full_name = '\27[1m\27[31m'..name1..' '..name2..'\27[0m'..name3
if msg.text then
user_msg = msg.text..'\27[0m'
elseif msg.caption then
user_msg = msg.caption..'\27[0m'
else
user_msg = ''
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)
if msg.date < os.time() - 5 then return end -- Do not process old messages.