Local functions on help
This commit is contained in:
parent
2cb99efc17
commit
8b38b3a0dc
@ -1,5 +1,7 @@
|
|||||||
|
do
|
||||||
|
|
||||||
-- Generate an HTML table for GitHub
|
-- Generate an HTML table for GitHub
|
||||||
function html_help()
|
local function html_help()
|
||||||
local text = [[<table>
|
local text = [[<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -30,14 +32,16 @@ function html_help()
|
|||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
function has_usage_data(dict)
|
-- Returns true if is not empty
|
||||||
|
local function has_usage_data(dict)
|
||||||
if (dict.usage == nil or dict.usage == '') then
|
if (dict.usage == nil or dict.usage == '') then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin_help(name)
|
-- Get commands for that plugin
|
||||||
|
local function plugin_help(name)
|
||||||
local plugin = plugins[name]
|
local plugin = plugins[name]
|
||||||
if not plugin then return nil end
|
if not plugin then return nil end
|
||||||
|
|
||||||
@ -54,7 +58,7 @@ function plugin_help(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- !help command
|
-- !help command
|
||||||
function telegram_help()
|
local function telegram_help()
|
||||||
local text = "Plugin list: \n\n"
|
local text = "Plugin list: \n\n"
|
||||||
-- Plugins names
|
-- Plugins names
|
||||||
for name in pairs(plugins) do
|
for name in pairs(plugins) do
|
||||||
@ -66,7 +70,7 @@ function telegram_help()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- !help all command
|
-- !help all command
|
||||||
function help_all()
|
local function help_all()
|
||||||
local ret = ""
|
local ret = ""
|
||||||
for name in pairs(plugins) do
|
for name in pairs(plugins) do
|
||||||
ret = ret .. plugin_help(name)
|
ret = ret .. plugin_help(name)
|
||||||
@ -74,7 +78,7 @@ function help_all()
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function run(msg, matches)
|
local function run(msg, matches)
|
||||||
if matches[1] == "!help" then
|
if matches[1] == "!help" then
|
||||||
return telegram_help()
|
return telegram_help()
|
||||||
elseif matches[1] == "!help all" then
|
elseif matches[1] == "!help all" then
|
||||||
@ -102,3 +106,5 @@ return {
|
|||||||
},
|
},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end
|
Reference in New Issue
Block a user