This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot-2/otouto/plugins/images.lua

23 lines
682 B
Lua
Raw Normal View History

2016-06-14 15:25:53 +02:00
local images = {}
local utilities = require('otouto.utilities')
images.triggers = {
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Pp][Nn][Gg])$",
"(https?://[%w-_%%%.%?%.:,/%+=~&%[%]]+%.[Jj][Pp][Ee]?[Gg])$"
}
function images:action(msg)
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local url = matches[1]
local file, last_modified, nocache = get_cached_file(url, nil, msg.chat.id, 'upload_photo', self)
local result = utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
if nocache then return end
if not result then return end
-- Cache File-ID und Last-Modified-Header in Redis
cache_file(result, url, last_modified)
2016-06-14 15:25:53 +02:00
end
return images