27 lines
667 B
Lua
27 lines
667 B
Lua
|
local get_img = {}
|
||
|
|
||
|
function get_img:init(config)
|
||
|
get_img.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('getimg', true).table
|
||
|
get_img.doc = '\n*/getimg* _<URL>_'
|
||
|
end
|
||
|
|
||
|
get_img.command = 'getimg <URL>'
|
||
|
|
||
|
function get_img:action(msg, config)
|
||
|
local input = utilities.input_from_msg(msg)
|
||
|
if not input then
|
||
|
utilities.send_reply(msg, get_img.doc, true)
|
||
|
return
|
||
|
end
|
||
|
|
||
|
utilities.send_typing(msg.chat.id, 'upload_photo')
|
||
|
local img_url = download_to_file(input)
|
||
|
if not img_url then
|
||
|
utilities.send_reply(msg, config.errors.connection)
|
||
|
return
|
||
|
end
|
||
|
utilities.send_photo(msg.chat.id, input, nil, msg.message_id)
|
||
|
end
|
||
|
|
||
|
return get_img
|