acc7046d64
Added optional target for kick/ban logs. Added flag 7 to use default log per group. This way, a realm can have a public kick/ban log but governors are able to opt out. Added flag 8, antilink. Kicks for Telegram join links which do not refer to groups within the realm. Added flag 9, modrights, to give moderators access to changing the group photo, title, link, and motd (config option is deprecated. RIP). /unban will reset the target's autokick counter. Added configuration for default flag settings. Revision to bindings.lua. BASE_URL has been moved to bindings. There is no real reason for it to remain in instance. Token is passed to bindings.init at load. All plugins have been updated accordingly.
69 lines
2.0 KiB
Lua
69 lines
2.0 KiB
Lua
local me = {}
|
|
|
|
local utilities = require('otouto.utilities')
|
|
|
|
function me:init(config)
|
|
me.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('me', true).table
|
|
me.command = 'me'
|
|
me.doc = 'Returns userdata stored by the bot.'
|
|
end
|
|
|
|
function me:action(msg, config)
|
|
local user
|
|
if msg.from.id == config.admin then
|
|
if msg.reply_to_message then
|
|
user = msg.reply_to_message.from
|
|
else
|
|
local input = utilities.input(msg.text)
|
|
if input then
|
|
if tonumber(input) then
|
|
user = self.database.users[input]
|
|
if not user then
|
|
utilities.send_reply(msg, 'Unrecognized ID.')
|
|
return
|
|
end
|
|
elseif input:match('^@') then
|
|
user = utilities.resolve_username(self, input)
|
|
if not user then
|
|
utilities.send_reply(msg, 'Unrecognized username.')
|
|
return
|
|
end
|
|
else
|
|
utilities.send_reply(msg, 'Invalid username or ID.')
|
|
return
|
|
end
|
|
end
|
|
end
|
|
end
|
|
user = user or msg.from
|
|
local userdata = self.database.userdata[tostring(user.id)] or {}
|
|
|
|
local data = {}
|
|
for k,v in pairs(userdata) do
|
|
table.insert(data, string.format(
|
|
'<b>%s:</b> <code>%s</code>\n',
|
|
utilities.html_escape(k),
|
|
utilities.html_escape(v)
|
|
))
|
|
end
|
|
|
|
local output
|
|
if #data == 0 then
|
|
output = 'There is no data stored for this user.'
|
|
else
|
|
output = string.format(
|
|
'<b>%s</b> <code>[%s]</code><b>:</b>\n',
|
|
utilities.html_escape(utilities.build_name(
|
|
user.first_name,
|
|
user.last_name
|
|
)),
|
|
user.id
|
|
) .. table.concat(data)
|
|
end
|
|
|
|
utilities.send_message(msg.chat.id, output, true, nil, 'html')
|
|
|
|
end
|
|
|
|
return me
|