From 4ad27bc405188708f38c6100723a03f47994da94 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Fri, 26 Aug 2016 00:28:09 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Zitate=20l=C3=B6schen=20per=20Reply?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/plugins/quotes.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/otouto/plugins/quotes.lua b/otouto/plugins/quotes.lua index 29a634b..35e8c31 100644 --- a/otouto/plugins/quotes.lua +++ b/otouto/plugins/quotes.lua @@ -7,7 +7,8 @@ function quotes:init(config) "^/(delquote) (.+)$", "^/(addquote) (.+)$", "^/(quote)$", - "^/(listquotes)$" + "^/(listquotes)$", + "^/(delquote)$" } quotes.doc = [[* ]]..config.cmd_pat..[[addquote* __: Fügt Zitat hinzu. @@ -87,12 +88,22 @@ function quotes:action(msg, config, matches) utilities.send_reply(msg, quotes:save_quote(msg), true) return elseif matches[1] == "delquote" and matches[2] then - if msg.from.id ~= config.admin then + if not is_sudo(msg, config) then utilities.send_reply(msg, config.errors.sudo) return end + utilities.send_reply(msg, quotes:delete_quote(msg), true) + return + elseif matches[1] == "delquote" and not matches[2] then + if not is_sudo(msg, config) then + utilities.send_reply(msg, config.errors.sudo) + return + end + if msg.reply_to_message then + local msg = msg.reply_to_message utilities.send_reply(msg, quotes:delete_quote(msg), true) return + end elseif matches[1] == "listquotes" then local link, iserror = quotes:list_quotes(msg) if iserror then From 335994f0d74d0a647c40e27d0995519122739dc3 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Fri, 26 Aug 2016 00:44:01 +0200 Subject: [PATCH 2/3] Fixe Luarun --- otouto/plugins/luarun.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/otouto/plugins/luarun.lua b/otouto/plugins/luarun.lua index bcc8a05..eb8f206 100644 --- a/otouto/plugins/luarun.lua +++ b/otouto/plugins/luarun.lua @@ -23,7 +23,7 @@ function luarun:action(msg, config) local input = utilities.input(msg.text) if not input then - utilities.send_reply(msg, 'Please enter a string to load.') + utilities.send_reply(self, msg, 'Bitte gebe einen Befehl ein.') return end @@ -35,15 +35,14 @@ function luarun:action(msg, config) local bot = require('otouto.bot') local bindings = require('otouto.bindings') local utilities = require('otouto.utilities') - local drua = require('otouto.drua-tg') - local JSON = require('dkjson') + local json = require('dkjson') local URL = require('socket.url') - local HTTP = require('socket.http') - local HTTPS = require('ssl.https') - return function (msg, config) ]] .. input .. [[ end - ]] )()(msg, config) + local http = require('socket.http') + local https = require('ssl.https') + return function (self, msg, config) ]] .. input .. [[ end + ]] )()(self, msg, config) if output == nil then - output = 'Done!' + output = 'Ausgeführt!' else if type(output) == 'table' then local s = luarun.serialize(output) @@ -53,9 +52,8 @@ function luarun:action(msg, config) end output = '```\n' .. tostring(output) .. '\n```' end - utilities.send_message(msg.chat.id, output, true, msg.message_id, true) + utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true) end -return luarun - +return luarun \ No newline at end of file From 4d3a67fe5f181ad04bd7b04106a91792c009871d Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Fri, 26 Aug 2016 17:42:40 +0200 Subject: [PATCH 3/3] Luarun-Fix 2 --- otouto/plugins/luarun.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/otouto/plugins/luarun.lua b/otouto/plugins/luarun.lua index eb8f206..e6c40ca 100644 --- a/otouto/plugins/luarun.lua +++ b/otouto/plugins/luarun.lua @@ -23,7 +23,7 @@ function luarun:action(msg, config) local input = utilities.input(msg.text) if not input then - utilities.send_reply(self, msg, 'Bitte gebe einen Befehl ein.') + utilities.send_reply(msg, 'Bitte gebe einen Befehl ein.') return end @@ -39,8 +39,8 @@ function luarun:action(msg, config) local URL = require('socket.url') local http = require('socket.http') local https = require('ssl.https') - return function (self, msg, config) ]] .. input .. [[ end - ]] )()(self, msg, config) + return function (msg, config) ]] .. input .. [[ end + ]] )()(msg, config) if output == nil then output = 'Ausgeführt!' else @@ -52,7 +52,7 @@ function luarun:action(msg, config) end output = '```\n' .. tostring(output) .. '\n```' end - utilities.send_message(self, msg.chat.id, output, true, msg.message_id, true) + utilities.send_message(msg.chat.id, output, true, msg.message_id, true) end