few changes on bot.lua and utils.lua
TIMEOUT set to 10s Uglify on serialize_to_file Random name if previous patterns fails
This commit is contained in:
parent
5bf2b6bf17
commit
b2b41f2311
@ -74,7 +74,6 @@ local function is_plugin_disabled_on_chat(plugin_name, receiver)
|
|||||||
if disabled_chats and disabled_chats[receiver] then
|
if disabled_chats and disabled_chats[receiver] then
|
||||||
-- Checks if plugin is disabled on this chat
|
-- Checks if plugin is disabled on this chat
|
||||||
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
|
for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
|
||||||
print(disabled_plugin)
|
|
||||||
if disabled_plugin == plugin_name and disabled then
|
if disabled_plugin == plugin_name and disabled then
|
||||||
local warning = ''
|
local warning = ''
|
||||||
print(warning)
|
print(warning)
|
||||||
|
@ -6,6 +6,8 @@ json = (loadfile "./libs/JSON.lua")()
|
|||||||
serpent = (loadfile "./libs/serpent.lua")()
|
serpent = (loadfile "./libs/serpent.lua")()
|
||||||
mimetype = (loadfile "./libs/mimetype.lua")()
|
mimetype = (loadfile "./libs/mimetype.lua")()
|
||||||
|
|
||||||
|
http.TIMEOUT = 10
|
||||||
|
|
||||||
function get_receiver(msg)
|
function get_receiver(msg)
|
||||||
if msg.to.type == 'user' then
|
if msg.to.type == 'user' then
|
||||||
return 'user#id'..msg.from.id
|
return 'user#id'..msg.from.id
|
||||||
@ -53,8 +55,12 @@ function string:trim()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function get_http_file_name(url, headers)
|
function get_http_file_name(url, headers)
|
||||||
-- Everything after the last /
|
-- Eg: fooo.var
|
||||||
local file_name = url:match("([^/]+)$")
|
local file_name = url:match("[^%w]+([%.%w]+)$")
|
||||||
|
-- Any delimited aphanumeric on the url
|
||||||
|
file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$")
|
||||||
|
-- Random name, hope content-type works
|
||||||
|
file_name = file_name or str:random(5)
|
||||||
-- Possible headers names
|
-- Possible headers names
|
||||||
local content_type = headers["content-type"]
|
local content_type = headers["content-type"]
|
||||||
|
|
||||||
@ -210,12 +216,18 @@ function file_exists(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Save into file the data serialized for lua.
|
-- Save into file the data serialized for lua.
|
||||||
function serialize_to_file(data, file)
|
-- Set uglify true to minify the file.
|
||||||
|
function serialize_to_file(data, file, uglify)
|
||||||
file = io.open(file, 'w+')
|
file = io.open(file, 'w+')
|
||||||
local serialized = serpent.block(data, {
|
local serialized
|
||||||
comment = false,
|
if not uglify then
|
||||||
name = "_"
|
serialized = serpent.block(data, {
|
||||||
})
|
comment = false,
|
||||||
|
name = '_'
|
||||||
|
})
|
||||||
|
else
|
||||||
|
serialized = serpent.dump(data)
|
||||||
|
end
|
||||||
file:write(serialized)
|
file:write(serialized)
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user