diff --git a/plugins/admin.lua b/plugins/admin.lua deleted file mode 100755 index c9d3259..0000000 --- a/plugins/admin.lua +++ /dev/null @@ -1,75 +0,0 @@ -local triggers = { - '^/admin[@'..bot.username..']*' -} - -local commands = { - - ['run'] = function(cmd) - local cmd = cmd:input() - if not cmd then - return 'Please enter a command to run.' - end - return io.popen(cmd):read('*all') - end, - - ['lua'] = function(cmd) - local cmd = cmd:input() - if not cmd then - return 'Please enter a command to run.' - end - local a = loadstring(cmd)() - if a then - return a - else - return 'Done!' - end - end, - - ['reload'] = function(cmd) - bot_init() - return 'Bot reloaded!' - end, - - ['halt'] = function(cmd) - is_started = false - return 'Stopping bot!' - end, - - ['error'] = function(cmd) - error('Intentional test error.') - end - -} - -local action = function(msg) - - if msg.from.id ~= config.admin then - return - end - - local input = msg.text:input() - if not input then - local list = 'Specify a command: ' - for k,v in pairs(commands) do - list = list .. k .. ', ' - end - list = list:gsub(', $', '.') - sendReply(msg, list) - return - end - - for k,v in pairs(commands) do - if string.match(get_word(input, 1), k) then - sendReply(msg, v(input)) - return - end - end - - sendReply(msg, 'Specify a command: run, reload, halt.') - -end - -return { - action = action, - triggers = triggers -} diff --git a/plugins/antisquig.lua b/plugins/antisquig.lua index 9f64705..9e0e180 100755 --- a/plugins/antisquig.lua +++ b/plugins/antisquig.lua @@ -1,3 +1,4 @@ + -- An extension to moderation.lua. This plugin is useless without it. -- Put this at the very top of your plugin list, even before blacklist.lua. -- Developed by the incredible JuanPotato, creator of the Python CLI bot Botato. diff --git a/plugins/control.lua b/plugins/control.lua new file mode 100644 index 0000000..c59c59b --- /dev/null +++ b/plugins/control.lua @@ -0,0 +1,26 @@ +local triggers = { + '^/reload[@'..bot.username..']*', + '^/halt[@'..bot.username..']*' +} + +local action = function(msg) + + if msg.from.id ~= config.admin then + return + end + + if msg.text:match('^/reload') then + bot_init() + sendReply(msg, 'Bot reloaded!') + elseif msg.text:match('^/halt') then + is_started = false + sendReply(msg, 'Stopping bot!') + end + +end + +return { + action = action, + triggers = triggers +} + diff --git a/plugins/hearthstone.lua b/plugins/hearthstone.lua old mode 100644 new mode 100755 diff --git a/plugins/luarun.lua b/plugins/luarun.lua new file mode 100644 index 0000000..0c71ee0 --- /dev/null +++ b/plugins/luarun.lua @@ -0,0 +1,27 @@ +local triggers = { + '^/lua[@'..bot.username..']*' +} + +local action = function(msg) + + if msg.from.id ~= config.admin then + return + end + + local input = msg.text:input() + if not input then + sendReply(msg, 'Please enter a string to load.') + return + end + + local output = loadstring(input)() + if not output then output = 'Done!' end + sendReply(msg, output) + +end + +return { + action = action, + triggers = triggers +} + diff --git a/plugins/ping.lua b/plugins/ping.lua old mode 100644 new mode 100755 diff --git a/plugins/shell.lua b/plugins/shell.lua new file mode 100644 index 0000000..38fc392 --- /dev/null +++ b/plugins/shell.lua @@ -0,0 +1,26 @@ +local triggers = { + '^/run[@'..bot.username..']*' +} + +local action = function(msg) + + if msg.from.id ~= config.admin then + return + end + + local input = msg.text:input() + if not input then + sendReply(msg, 'Please specify a command to run.') + return + end + + local output = io.popen(input):read('*all') + if output:len() == 0 then output = 'Done!' end + sendReply(msg, output) + +end + +return { + action = action, + triggers = triggers +} diff --git a/plugins/shout.lua b/plugins/shout.lua new file mode 100644 index 0000000..8967de5 --- /dev/null +++ b/plugins/shout.lua @@ -0,0 +1,43 @@ +local doc = [[ + /shout + Shout something! +]] + +local triggers = { + '^/shout[@'..bot.username..']*' +} + +local action = function(msg) + + local input = msg.text:input() + + if not input then + sendReply(msg, doc) + return + end + + input = input:upper() + local output = '' + local inc = 0 + for match in input:gmatch('.') do + output = output .. match .. ' ' + end + output = output .. '\n' + for match in input:sub(2):gmatch('.') do + local spacing = '' + for i = 1, inc do + spacing = spacing .. ' ' + end + inc = inc + 1 + output = output .. match .. ' ' .. spacing .. match .. '\n' + end + output = '```\n' .. output:trim() .. '\n```' + sendMessage(msg.chat.id, output, true, false, true) + +end + +return { + action = action, + triggers = triggers, + doc = doc +}