diff --git a/README.md b/README.md index 9a17872..177dd19 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Multimedia Command list ------------ ``` -9gag -> send random image from 9gag +!9gag -> send random image from 9gag !echo [whatever] -> echoes the msg !eur [USD] -> EURUSD market value !uc3m -> Fortunes from Universidad Carlos III @@ -46,8 +46,9 @@ say hello to [name] -> Says hello to someone !ping -> bot sends pong !rae [word] -> Spanish dictionary !set [value_name] [data] -> Set value +!time [area] -> Displays the local time in an area !tw [text] -> Sends a tweet -!version -> Shows the bot version +!version -> Shows bot version !weather (city) -> weather in that city (Madrid is default) ``` diff --git a/bot/bot.lua b/bot/bot.lua index 1f92d77..5481cee 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -2,9 +2,8 @@ https = require("ssl.https") URL = require("socket.url") json = (loadfile "./bot/JSON.lua")() --- lrexlib = require("rex_pcre") - VERSION = 'v0.6' + VERSION = 'v0.7' -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) @@ -55,16 +54,16 @@ function do_action(msg) local receiver = get_receiver(msg) local text = msg.text - print("Received msg", text) + -- print("Received msg", text) for name, desc in pairs(plugins) do - print("Trying module", name) + -- print("Trying module", name) for k, pattern in pairs(desc.patterns) do - print("Trying", text, "against", pattern) + -- print("Trying", text, "against", pattern) matches = { string.match(text, pattern) } if matches[1] then - print(" matches!") + print(" matches!!!!!") result = desc.run(msg, matches) - print(" should return", result) + print(" sending", result) if (result) then send_msg(receiver, result, ok_cb, false) return @@ -74,25 +73,6 @@ end end - -- function do_action(msg) - -- local receiver = get_receiver(msg) - - -- if string.starts(msg.text, '!sh') then - -- text = run_sh(msg) - -- send_msg(receiver, text, ok_cb, false) - -- return - -- end - -- - - -- if string.starts(msg.text, '!cpu') then - -- text = run_bash('uname -snr') .. ' ' .. run_bash('whoami') - -- text = text .. '\n' .. run_bash('top -b |head -2') - -- send_msg(receiver, text, ok_cb, false) - -- return - -- end - - -- end - function load_config() local f = assert(io.open('./bot/config.json', "r")) local c = f:read "*a" @@ -166,7 +146,7 @@ end function download_to_file( url ) - print("url a descargar: "..url) + print("url to download: "..url) req, c, h = http.request(url) htype = h["content-type"] vardump(c) diff --git a/plugins/help.lua b/plugins/help.lua index 27865a2..d02e43a 100644 --- a/plugins/help.lua +++ b/plugins/help.lua @@ -2,7 +2,9 @@ function run(msg, matches) local ret = "" for k, dict in pairs(plugins) do - ret = ret .. dict.usage .. " -> " .. dict.description .. "\n" + if dict.usage ~= "" then + ret = ret .. dict.usage .. " -> " .. dict.description .. "\n" + end end return ret end @@ -12,5 +14,4 @@ return { usage = "!help", patterns = {"^!help$"}, run = run -} - +} \ No newline at end of file diff --git a/plugins/images.lua b/plugins/images.lua index 82f3b63..c39d725 100644 --- a/plugins/images.lua +++ b/plugins/images.lua @@ -6,7 +6,7 @@ function run(msg, matches) end return { - description = "from image URL downloads it and sends to origin", + description = "When user sends image URL (ends with png, jpg, jpeg) download and send it to origin.", usage = "", patterns = { "(https?://[%w-_%.%?%.:/%+=&]+.png)$", diff --git a/plugins/media.lua b/plugins/media.lua index 664f6a5..64c8175 100644 --- a/plugins/media.lua +++ b/plugins/media.lua @@ -5,7 +5,7 @@ function run(msg, matches) end return { - description = "from media URL downloads it and sends to origin", + description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.", usage = "", patterns = { "(https?://[%w-_%.%?%.:/%+=&]+.gif)$", diff --git a/plugins/twitter.lua b/plugins/twitter.lua index b40899c..e1cc3b0 100644 --- a/plugins/twitter.lua +++ b/plugins/twitter.lua @@ -61,7 +61,7 @@ function run(msg, matches) end return { - description = "Shows a tweet", + description = "When user sends twitter URL, send text and images to origin. Requieres OAuth Key.", usage = "", patterns = {"https://twitter.com/[^/]+/status/([0-9]+)"}, run = run diff --git a/plugins/version.lua b/plugins/version.lua index ec7fa24..21afc94 100644 --- a/plugins/version.lua +++ b/plugins/version.lua @@ -8,7 +8,7 @@ function run(msg, matches) end return { - description = "Shows the bot version", + description = "Shows bot version", usage = "!version", patterns = {"^!version$"}, run = run