Bot kann jetzt mit File-IDs umgehen (https://core.telegram.org/bots/api#resending-files-without-reuploading)
This commit is contained in:
parent
52cbd768f0
commit
2053f0b3a5
@ -28,6 +28,7 @@ function bindings:request(method, parameters, file)
|
|||||||
end
|
end
|
||||||
if file and next(file) ~= nil then
|
if file and next(file) ~= nil then
|
||||||
local file_type, file_name = next(file)
|
local file_type, file_name = next(file)
|
||||||
|
if string.match(file_name, '/tmp/') then
|
||||||
local file_file = io.open(file_name, 'r')
|
local file_file = io.open(file_name, 'r')
|
||||||
local file_data = {
|
local file_data = {
|
||||||
filename = file_name,
|
filename = file_name,
|
||||||
@ -35,6 +36,10 @@ function bindings:request(method, parameters, file)
|
|||||||
}
|
}
|
||||||
file_file:close()
|
file_file:close()
|
||||||
parameters[file_type] = file_data
|
parameters[file_type] = file_data
|
||||||
|
else
|
||||||
|
local file_type, file_name = next(file)
|
||||||
|
parameters[file_type] = file_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if next(parameters) == nil then
|
if next(parameters) == nil then
|
||||||
parameters = {''}
|
parameters = {''}
|
||||||
|
@ -59,8 +59,10 @@ function utilities:send_photo(chat_id, file, text, reply_to_message_id, reply_ma
|
|||||||
reply_to_message_id = reply_to_message_id,
|
reply_to_message_id = reply_to_message_id,
|
||||||
reply_markup = reply_markup
|
reply_markup = reply_markup
|
||||||
}, {photo = file} )
|
}, {photo = file} )
|
||||||
|
if string.match(file, '/tmp/') then
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
print("Deleted: "..file)
|
print("Deleted: "..file)
|
||||||
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -73,8 +75,10 @@ function utilities:send_audio(chat_id, file, reply_to_message_id, duration, perf
|
|||||||
title = title or nil,
|
title = title or nil,
|
||||||
reply_to_message_id = reply_to_message_id
|
reply_to_message_id = reply_to_message_id
|
||||||
}, {audio = file} )
|
}, {audio = file} )
|
||||||
|
if string.match(file, '/tmp/') then
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
print("Deleted: "..file)
|
print("Deleted: "..file)
|
||||||
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,8 +90,10 @@ function utilities:send_document(chat_id, file, text, reply_to_message_id, reply
|
|||||||
reply_to_message_id = reply_to_message_id,
|
reply_to_message_id = reply_to_message_id,
|
||||||
reply_markup = reply_markup
|
reply_markup = reply_markup
|
||||||
}, {document = file} )
|
}, {document = file} )
|
||||||
|
if string.match(file, '/tmp/') then
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
print("Deleted: "..file)
|
print("Deleted: "..file)
|
||||||
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -101,8 +107,10 @@ function utilities:send_video(chat_id, file, text, reply_to_message_id, duration
|
|||||||
height = height or nil,
|
height = height or nil,
|
||||||
reply_to_message_id = reply_to_message_id
|
reply_to_message_id = reply_to_message_id
|
||||||
}, {video = file} )
|
}, {video = file} )
|
||||||
|
if string.match(file, '/tmp/') then
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
print("Deleted: "..file)
|
print("Deleted: "..file)
|
||||||
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -114,8 +122,10 @@ function utilities:send_voice(chat_id, file, text, reply_to_message_id, duration
|
|||||||
duration = duration or nil,
|
duration = duration or nil,
|
||||||
reply_to_message_id = reply_to_message_id
|
reply_to_message_id = reply_to_message_id
|
||||||
}, {voice = file} )
|
}, {voice = file} )
|
||||||
|
if string.match(file, '/tmp/') then
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
print("Deleted: "..file)
|
print("Deleted: "..file)
|
||||||
|
end
|
||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user