Übernehme Änderungen von Brawl345/Brawlbot-v2

Verbesserungen für Media: Abhängig vom Dateityp wird jetzt die richtige
ChatAction gesendet (upload_video, upload_audio, etc.)
Dateien mit einer Größe von > 50 MB werden ignoriert
This commit is contained in:
2016-07-23 20:04:22 +02:00
parent cb2c056100
commit 8db9a30d13
2 changed files with 36 additions and 13 deletions

View File

@@ -30,10 +30,19 @@ media.triggers = {
function media:action(msg)
local url = matches[1]
local ext = matches[2]
local receiver = msg.chat.id
local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, 'upload_document', self)
local mime_type = mimetype.get_content_type_no_sub(ext)
local receiver = msg.chat.id
if mime_type == 'audio' then
chat_action = 'upload_audio'
elseif mime_type == 'video' then
chat_action = 'upload_video'
else
chat_action = 'upload_document'
end
local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, chat_action, self)
if not file then return end
if ext == 'gif' then
print('send gif')
@@ -56,4 +65,4 @@ function media:action(msg)
cache_file(result, url, last_modified)
end
return media
return media