Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F619525
fadmins.lua
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
fadmins.lua
View Options
--[[
mattata v2.0 - Federation: fadmins
Lists all admins of the federation the current chat belongs to.
Shows the owner separately from promoted admins.
]]
local
tools
=
require
(
'telegram-bot-lua.tools'
)
local
plugin
=
{}
plugin
.
name
=
'fadmins'
plugin
.
category
=
'admin'
plugin
.
description
=
'List federation admins.'
plugin
.
commands
=
{
'fadmins'
}
plugin
.
help
=
'/fadmins - List all admins of this federation.'
plugin
.
group_only
=
true
plugin
.
admin_only
=
false
local
function
get_chat_federation
(
db
,
chat_id
)
local
result
=
db
.
call
(
'sp_get_chat_federation'
,
{
chat_id
})
if
result
and
#
result
>
0
then
return
result
[
1
]
end
return
nil
end
function
plugin
.
on_message
(
api
,
message
,
ctx
)
local
fed
=
get_chat_federation
(
ctx
.
db
,
message
.
chat
.
id
)
if
not
fed
then
return
api
.
send_message
(
message
.
chat
.
id
,
'This chat is not part of any federation.'
,
{
parse_mode
=
'html'
}
)
end
local
output
=
string.format
(
'<b>Federation Admins</b>
\n
Federation: <b>%s</b>
\n\n
<b>Owner:</b>
\n
<code>%s</code>'
,
tools
.
escape_html
(
fed
.
name
),
fed
.
owner_id
)
local
admins
=
ctx
.
db
.
call
(
'sp_get_federation_admins'
,
{
fed
.
id
})
if
admins
and
#
admins
>
0
then
output
=
output
..
string.format
(
'
\n\n
<b>Admins (%d):</b>'
,
#
admins
)
for
i
,
admin
in
ipairs
(
admins
)
do
output
=
output
..
string.format
(
'
\n
%d. <code>%s</code>'
,
i
,
admin
.
user_id
)
end
else
output
=
output
..
'
\n\n
No promoted admins.'
end
return
api
.
send_message
(
message
.
chat
.
id
,
output
,
{
parse_mode
=
'html'
})
end
return
plugin
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 4:51 PM (10 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
126725
Default Alt Text
fadmins.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline