administration.lua 1.13.2 - /desc can now be used with a query.
remind.lua - Now accepts repled-to message text as reminder.
This commit is contained in:
parent
384e4c62a3
commit
caff204c71
@ -108,14 +108,14 @@ function drua.message(target, text, s)
|
|||||||
text = escape(text)
|
text = escape(text)
|
||||||
local command = 'msg %s "%s"'
|
local command = 'msg %s "%s"'
|
||||||
command = command:format(target, text)
|
command = command:format(target, text)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.send_photo(target, photo, s)
|
function drua.send_photo(target, photo, s)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = 'send_photo %s %s'
|
local command = 'send_photo %s %s'
|
||||||
command = command:format(target, photo)
|
command = command:format(target, photo)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.add_user(chat, target, s)
|
function drua.add_user(chat, target, s)
|
||||||
@ -123,24 +123,24 @@ function drua.add_user(chat, target, s)
|
|||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = comtab.add[a]:format(chat, target)
|
local command = comtab.add[a]:format(chat, target)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.kick_user(chat, target, s)
|
function drua.kick_user(chat, target, s)
|
||||||
-- Get the group info so tg will recognize the target.
|
-- Get the group info so tg will recognize the target.
|
||||||
drua.get_info(chat, _, s)
|
drua.get_info(chat, nil, s)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
target = format_target(target)
|
target = format_target(target)
|
||||||
local command = comtab.kick[a]:format(chat, target)
|
local command = comtab.kick[a]:format(chat, target)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.rename_chat(chat, name, s)
|
function drua.rename_chat(chat, name, s)
|
||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.rename[a]:format(chat, name)
|
local command = comtab.rename[a]:format(chat, name)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.export_link(chat, s)
|
function drua.export_link(chat, s)
|
||||||
@ -166,7 +166,7 @@ function drua.set_photo(chat, photo, s)
|
|||||||
local a
|
local a
|
||||||
chat, a = format_target(chat)
|
chat, a = format_target(chat)
|
||||||
local command = comtab.photo_set[a]:format(chat, photo)
|
local command = comtab.photo_set[a]:format(chat, photo)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.get_info(target, s)
|
function drua.get_info(target, s)
|
||||||
@ -181,7 +181,7 @@ function drua.channel_set_admin(chat, user, rank, s)
|
|||||||
user = format_target(user)
|
user = format_target(user)
|
||||||
local command = 'channel_set_admin %s %s %s'
|
local command = 'channel_set_admin %s %s %s'
|
||||||
command = command:format(chat, user, rank)
|
command = command:format(chat, user, rank)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.channel_set_about(chat, text, s)
|
function drua.channel_set_about(chat, text, s)
|
||||||
@ -189,15 +189,15 @@ function drua.channel_set_about(chat, text, s)
|
|||||||
text = escape(text)
|
text = escape(text)
|
||||||
local command = 'channel_set_about %s "%s"'
|
local command = 'channel_set_about %s "%s"'
|
||||||
command = command:format(chat, text)
|
command = command:format(chat, text)
|
||||||
return drua.send(command, _, s)
|
return drua.send(command, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.block(user, s)
|
function drua.block(user, s)
|
||||||
return drua.send('block_user user#' .. user, _, s)
|
return drua.send('block_user user#' .. user, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
function drua.unblock(user, s)
|
function drua.unblock(user, s)
|
||||||
return drua.send('unblock_user user#' .. user, _, s)
|
return drua.send('unblock_user user#' .. user, nil, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
return drua
|
return drua
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--[[
|
--[[
|
||||||
administration.lua, version 1.13.1
|
administration.lua, version 1.13.2
|
||||||
This plugin provides self-hosted, single-realm group administration.
|
This plugin provides self-hosted, single-realm group administration.
|
||||||
It requires tg (http://github.com/vysheng/tg) with supergroup support.
|
It requires tg (http://github.com/vysheng/tg) with supergroup support.
|
||||||
For more documentation, read the the manual (otou.to/rtfm).
|
For more documentation, read the the manual (otou.to/rtfm).
|
||||||
@ -34,6 +34,8 @@
|
|||||||
modrights, to give moderators access to changing the group photo, title,
|
modrights, to give moderators access to changing the group photo, title,
|
||||||
link, and motd (config option is deprecated. RIP). /unban will reset the
|
link, and motd (config option is deprecated. RIP). /unban will reset the
|
||||||
target's autokick counter. Added configuration for default flag settings.
|
target's autokick counter. Added configuration for default flag settings.
|
||||||
|
|
||||||
|
1.13.2 - /desc can now be used with a query.
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
local drua = require('otouto.drua-tg')
|
local drua = require('otouto.drua-tg')
|
||||||
@ -715,19 +717,34 @@ function administration.init_command(self_, config_)
|
|||||||
end
|
end
|
||||||
utilities.send_message(msg.chat.id, output, true, nil, true)
|
utilities.send_message(msg.chat.id, output, true, nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- /desc
|
{ -- /desc
|
||||||
triggers = utilities.triggers(self_.info.username, config_.cmd_pat):t('desc'):t('description').table,
|
triggers = utilities.triggers(self_.info.username, config_.cmd_pat):t('desc', true):t('description', true).table,
|
||||||
|
|
||||||
command = 'description',
|
command = 'description',
|
||||||
privilege = 1,
|
privilege = 1,
|
||||||
interior = true,
|
interior = false,
|
||||||
doc = 'Returns a description of the group (in a private message), including its motd, rules, flags, governor, and moderators.',
|
doc = 'Returns a description of the group (in a private message), including its motd, rules, flags, governor, and moderators.',
|
||||||
|
|
||||||
action = function(self, msg, group, config)
|
action = function(self, msg, group, config)
|
||||||
local output = administration.get_desc(self, msg.chat.id, config)
|
local chat = group and tostring(msg.chat.id) or nil
|
||||||
|
local input = utilities.input(msg.text)
|
||||||
|
if input then
|
||||||
|
for chat_id_str, group_ in pairs(self.database.administration.groups) do
|
||||||
|
if (not group_.flags[1]) and group_.link then -- no unlisted or unlinked groups
|
||||||
|
if input == chat_id_str or string.match(group_.name:lower(), input:lower()) then
|
||||||
|
chat = chat_id_str
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not chat then
|
||||||
|
utilities.send_reply(msg, 'Group not found. Specify a group by name or ID, or use this command without arguments inside an administrated group.')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local output = administration.get_desc(self, chat, config)
|
||||||
if utilities.send_message(msg.from.id, output, true, nil, true) then
|
if utilities.send_message(msg.from.id, output, true, nil, true) then
|
||||||
if msg.from.id ~= msg.chat.id then
|
if msg.from.id ~= msg.chat.id then
|
||||||
utilities.send_reply(msg, 'I have sent you the requested information in a private message.')
|
utilities.send_reply(msg, 'I have sent you the requested information in a private message.')
|
||||||
|
@ -33,8 +33,13 @@ function remind:action(msg, config)
|
|||||||
elseif duration > config.remind.max_duration then
|
elseif duration > config.remind.max_duration then
|
||||||
duration = config.remind.max_duration
|
duration = config.remind.max_duration
|
||||||
end
|
end
|
||||||
local message = utilities.input(input)
|
|
||||||
if not message then
|
local message
|
||||||
|
if msg.reply_to_message and #msg.reply_to_message.text > 0 then
|
||||||
|
message = msg.reply_to_message.text
|
||||||
|
elseif utilities.input(input) then
|
||||||
|
message = utilities.input(input)
|
||||||
|
else
|
||||||
utilities.send_reply(msg, remind.doc, true)
|
utilities.send_reply(msg, remind.doc, true)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user