- Entferne Blacklist (da in Banhammer integriert)

- Übersetze Channel-Plugin
This commit is contained in:
Andreas Bielawski 2016-07-08 19:37:30 +02:00
parent 730e0dbf75
commit 47f6777cdc
2 changed files with 18 additions and 71 deletions

View File

@ -1,51 +0,0 @@
-- This plugin will allow the admin to blacklist users who will be unable to
-- use the bot. This plugin should be at the top of your plugin list in config.
local blacklist = {}
local utilities = require('otouto.utilities')
function blacklist:init()
if not self.database.blacklist then
self.database.blacklist = {}
end
end
blacklist.triggers = {
''
}
function blacklist:action(msg, config)
if self.database.blacklist[tostring(msg.from.id)] then return end
if self.database.blacklist[tostring(msg.chat.id)] then return end
if not msg.text:match('^'..config.cmd_pat..'blacklist') then return true end
if msg.from.id ~= config.admin then return end
local target = utilities.user_from_message(self, msg)
if target.err then
utilities.send_reply(self, msg, target.err)
return
end
if tonumber(target.id) < 0 then
target.name = 'Group'
end
if self.database.blacklist[tostring(target.id)] then
self.database.blacklist[tostring(target.id)] = nil
utilities.send_reply(self, msg, target.name .. ' has been removed from the blacklist.')
if config.drua_block_on_blacklist then
require('drua-tg').unblock(target.id)
end
else
self.database.blacklist[tostring(target.id)] = true
utilities.send_reply(self, msg, target.name .. ' has been added to the blacklist.')
if config.drua_block_on_blacklist then
require('drua-tg').block(target.id)
end
end
end
return blacklist

View File

@ -3,29 +3,27 @@ local channel = {}
local bindings = require('otouto.bindings') local bindings = require('otouto.bindings')
local utilities = require('otouto.utilities') local utilities = require('otouto.utilities')
--channel.command = 'ch <channel> \\n <message>' channel.command = 'ch <Kanal> \\n <Nachricht>'
channel.doc = [[``` channel.doc = [[*
/ch <channel> /ch*_ <Kanal>_
<message> _<Nachricht>_
Sends a message to a channel. Channel may be specified via ID or username. Messages are markdown-enabled. Users may only send messages to channels for which they are the owner or an administrator. Sendet eine Nachricht in den Kanal. Der Kanal kann per Username oder ID bestimmt werden, Markdown wird unterstützt. Du musst Administrator oder Besitzer des Kanals sein.
The following markdown syntax is supported: Markdown-Syntax:
*bold text* *Fetter Text*
_italic text_ _Kursiver Text_
[text](URL) [Text](URL)
`inline fixed-width code` `Inline-Codeblock`
```pre-formatted fixed-width code block``` ```Größere Code-Block über mehrere Zeilen```
Due to the frequent dysfunction and incompletion of the API method used to determine the administrators of a channel, this command may not work for the owners of some channels. *Der Kanalname muss mit einem @ beginnen!*]]
```]]
function channel:init(config) function channel:init(config)
channel.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('ch', true).table channel.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('ch', true).table
end end
function channel:action(msg, config) function channel:action(msg, config)
-- An exercise in using zero early returns. :)
local input = utilities.input(msg.text) local input = utilities.input(msg.text)
local output local output
if input then if input then
@ -43,18 +41,18 @@ function channel:action(msg, config)
if text then if text then
local success, result = utilities.send_message(self, chat_id, text, true, nil, true) local success, result = utilities.send_message(self, chat_id, text, true, nil, true)
if success then if success then
output = 'Your message has been sent!' output = 'Deine Nachricht wurde versendet!'
else else
output = 'Sorry, I was unable to send your message.\n`' .. result.description .. '`' output = 'Sorry, ich konnte deine Nachricht nicht senden.\n`' .. result.description .. '`'
end end
else else
output = 'Please enter a message to be sent. Markdown is supported.' output = 'Bitte gebe deine Nachricht ein. Markdown wird unterstützt.'
end end
else else
output = 'Sorry, you do not appear to be an administrator for that channel.\nThere is currently a known bug in the getChatAdministrators method, where administrator lists will often not show a channel\'s owner.' output = 'Es sieht nicht so aus, als wärst du der Administrator dieses Kanals.'
end end
else else
output = 'Sorry, I was unable to retrieve a list of administrators for that channel.\n`' .. t.description .. '`' output = 'Sorry, ich konnte die Administratorenliste nicht abrufen. Falls du den Kanalnamen benutzt: Beginnt er mit einem @?\n`' .. t.description .. '`'
end end
else else
output = channel.doc output = channel.doc