From 6bfc5247bfbd92833edb3416112569bc66964e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mun=CC=83oz?= Date: Tue, 16 Dec 2014 15:05:42 +0100 Subject: [PATCH 1/2] Reload ALL the plugins! --- bot/bot.lua | 26 ++++++++++++++++---------- plugins/reload.lua | 13 +++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 plugins/reload.lua diff --git a/bot/bot.lua b/bot/bot.lua index 45c27c2..ea34bd7 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -28,9 +28,9 @@ function rmtmp_cb(file_path, success, result) end function msg_valid(msg) - --if msg.from.id == our_id then - -- return false - --end + if msg.from.id == our_id then + return true + end if msg.out then return false end @@ -194,10 +194,16 @@ now = os.time() plugins = {} -- load all plugins in the plugins/ directory -for k, v in pairs(scandir("plugins")) do - if not (v:sub(0, 1) == ".") then - print("Loading plugin", v) - t = loadfile("plugins/" .. v)() - table.insert(plugins, t) - end -end \ No newline at end of file +function load_plugins() + plugins = {} + for k, v in pairs(scandir("plugins")) do + if not (v:sub(0, 1) == ".") then + print("Loading plugin", v) + t = loadfile("plugins/" .. v)() + table.insert(plugins, t) + end + end +end + +load_plugins() + diff --git a/plugins/reload.lua b/plugins/reload.lua new file mode 100644 index 0000000..5dc4a35 --- /dev/null +++ b/plugins/reload.lua @@ -0,0 +1,13 @@ + +function run(msg, matches) + load_plugins() + return 'Plugins reloaded' +end + +return { + description = "Reloads bot plugins", + usage = "!reload", + patterns = {"^!reload$"}, + run = run +} + From acbb0ff03bfc97f01c25bbdf016090220af48151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mun=CC=83oz?= Date: Tue, 16 Dec 2014 15:06:49 +0100 Subject: [PATCH 2/2] small fix --- bot/bot.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/bot.lua b/bot/bot.lua index ea34bd7..366c4cb 100644 --- a/bot/bot.lua +++ b/bot/bot.lua @@ -28,9 +28,9 @@ function rmtmp_cb(file_path, success, result) end function msg_valid(msg) - if msg.from.id == our_id then - return true - end + -- if msg.from.id == our_id then + -- return true + -- end if msg.out then return false end