From 9fc9383ab711bf6ea8a289de6804f0ffd0eafad3 Mon Sep 17 00:00:00 2001 From: yago Date: Wed, 4 Feb 2015 23:03:42 +0100 Subject: [PATCH] Help well formatted --- plugins/echo.lua | 4 ++-- plugins/get.lua | 6 +++--- plugins/google.lua | 2 +- plugins/gps.lua | 2 +- plugins/help.lua | 28 ++++++++++++++++++---------- plugins/img_google.lua | 4 ++-- plugins/location.lua | 2 +- plugins/plugins.lua | 8 ++++---- plugins/rae.lua | 2 +- plugins/set.lua | 4 ++-- plugins/stats.lua | 4 ++-- plugins/time.lua | 4 ++-- plugins/twitter_send.lua | 2 +- plugins/version.lua | 6 ++++-- 14 files changed, 44 insertions(+), 34 deletions(-) diff --git a/plugins/echo.lua b/plugins/echo.lua index 1e758f9..58f77b3 100644 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -4,8 +4,8 @@ function run(msg, matches) end return { - description = "echoes the msg", - usage = "!echo [whatever]", + description = "Simplest plugin ever!", + usage = "!echo [whatever]: echoes the msg", patterns = {"^!echo (.*)$"}, run = run } diff --git a/plugins/get.lua b/plugins/get.lua index c254dc5..4dc953b 100644 --- a/plugins/get.lua +++ b/plugins/get.lua @@ -72,11 +72,11 @@ function lex(msg, text) end return { - description = "retrieves variables saved with !set", - usage = "!get (value_name)", + description = "Retrieves variables saved with !set", + usage = "!get (value_name): Returns the value_name value.", patterns = { "^!get (%a+)$", - "^!get$"}, + "^!get$"}, run = run, lex = lex } diff --git a/plugins/google.lua b/plugins/google.lua index 0481962..61f6b2e 100644 --- a/plugins/google.lua +++ b/plugins/google.lua @@ -29,7 +29,7 @@ end return { description = "Searches Google and send results", - usage = "!google [terms]", + usage = "!google [terms]: Searches Google and send results", patterns = { "^!google (.*)$", "^%.[g|G]oogle (.*)$" diff --git a/plugins/gps.lua b/plugins/gps.lua index f26a211..7393e86 100644 --- a/plugins/gps.lua +++ b/plugins/gps.lua @@ -25,7 +25,7 @@ end return { description = "generates a map showing the given GPS coordinates", - usage = "!gps latitude,longitude", + usage = "!gps latitude,longitude: generates a map showing the given GPS coordinates", patterns = {"^!gps ([^,]*)[,%s]([^,]*)$"}, run = run } diff --git a/plugins/help.lua b/plugins/help.lua index 31b29e8..c671ff1 100644 --- a/plugins/help.lua +++ b/plugins/help.lua @@ -30,18 +30,23 @@ function html_help() return text end +function has_usage_data(dict) + if (dict.usage == nil or dict.usage == '') then + return false + end + return true +end + function telegram_help( ) local ret = "" for k, dict in pairs(plugins) do - if dict.usage ~= "" then - if (type(dict.usage) == "table") then - for ku,vu in pairs(dict.usage) do - ret = ret..vu.." " - end - else - ret = ret..dict.usage + if (type(dict.usage) == "table") then + for ku,usage in pairs(dict.usage) do + ret = ret..usage..'\n' end - ret = ret .. " -> " .. dict.description .. "\n" + ret = ret..'\n' + elseif has_usage_data(dict) then -- Is not empty + ret = ret..dict.usage..'\n\n' end end return ret @@ -56,8 +61,11 @@ function run(msg, matches) end return { - description = "Lists all available commands", - usage = {"!help", "!help md"}, + description = "Help plugin. Get info from other plugins. ", + usage = { + "!help: Show all the help", + "!help md: Generate a GitHub Markdown table" + }, patterns = { "^!help$", "^!help md$" diff --git a/plugins/img_google.lua b/plugins/img_google.lua index 5624edf..456a247 100644 --- a/plugins/img_google.lua +++ b/plugins/img_google.lua @@ -25,8 +25,8 @@ function run(msg, matches) end return { - description = "search image with Google API and sends it", - usage = "!img [topic]", + description = "Search image with Google API and sends it.", + usage = "!img [term]: Random search an image with Google API.", patterns = {"^!img (.*)$"}, run = run } diff --git a/plugins/location.lua b/plugins/location.lua index f6d876b..3d06d92 100644 --- a/plugins/location.lua +++ b/plugins/location.lua @@ -64,7 +64,7 @@ end return { description = "Gets information about a location, maplink and overview", - usage = "!loc (location)", + usage = "!loc (location): Gets information about a location, maplink and overview", patterns = {"^!loc (.*)$"}, run = run } diff --git a/plugins/plugins.lua b/plugins/plugins.lua index 323b6c6..021c41b 100644 --- a/plugins/plugins.lua +++ b/plugins/plugins.lua @@ -100,12 +100,12 @@ function run(msg, matches) end return { - description = "Enables, disables and reloads plugins. Privileged users only.", + description = "Plugin to manage other plugins. Enable, disable or reload.", usage = { "!plugins: list all plugins", - "!plugins enable [plugin]", - "!plugins disable [plugin]", - "!plugins reload" }, + "!plugins enable [plugin]: enable plugin", + "!plugins disable [plugin]: disable plugin", + "!plugins reload: reloads all plugins" }, patterns = { "^!plugins$", "^!plugins? (enable) (.*)$", diff --git a/plugins/rae.lua b/plugins/rae.lua index 787fc18..3c8c538 100644 --- a/plugins/rae.lua +++ b/plugins/rae.lua @@ -41,7 +41,7 @@ end return { description = "Spanish dictionary", - usage = "!rae [word]", + usage = "!rae [word]: Search that word in Spanish dictionary. Powered by https://github.com/javierhonduco/dulcinea", patterns = {"^!rae (.*)$"}, run = run } diff --git a/plugins/set.lua b/plugins/set.lua index d971b9c..8f0b1a6 100644 --- a/plugins/set.lua +++ b/plugins/set.lua @@ -23,8 +23,8 @@ function run(msg, matches) end return { - description = "Set value", - usage = "!set [value_name] [data]", + description = "Plugin for saving values. get.lua plugin is necesary to retrieve them.", + usage = "!set [value_name] [data]: Saves the data with the value_name name.", patterns = {"^!set (%a+) (.+)$"}, run = run } diff --git a/plugins/stats.lua b/plugins/stats.lua index 7ddf803..0b9e340 100644 --- a/plugins/stats.lua +++ b/plugins/stats.lua @@ -102,8 +102,8 @@ end _stats = read_file_stats() return { - description = "Number of messages by user", - usage = "!stats", + description = "Plugin to update user stats.", + usage = "!stats: Returns a list of Username [telegram_id]: msg_num", patterns = { ".*", "^!(stats)" diff --git a/plugins/time.lua b/plugins/time.lua index 0bf0ed9..289691e 100644 --- a/plugins/time.lua +++ b/plugins/time.lua @@ -94,7 +94,7 @@ end return { description = "Displays the local time in an area", - usage = "!time [area]", + usage = "!time [area]: Displays the local time in that area", patterns = {"^!time (.*)$"}, - run = run + run = run } diff --git a/plugins/twitter_send.lua b/plugins/twitter_send.lua index 28ea04e..ba9ae84 100644 --- a/plugins/twitter_send.lua +++ b/plugins/twitter_send.lua @@ -44,7 +44,7 @@ end return { description = "Sends a tweet", - usage = "!tw [text]", + usage = "!tw [text]: Sends the Tweet with the configured accout.", patterns = {"^!tw (.+)"}, run = run } diff --git a/plugins/version.lua b/plugins/version.lua index ec0bc02..9e42111 100644 --- a/plugins/version.lua +++ b/plugins/version.lua @@ -7,8 +7,10 @@ end return { description = "Shows bot version", - usage = "!version", - patterns = {"^!version$"}, + usage = "!version: Shows bot version", + patterns = { + "^!version$" + }, run = run }