Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F623694
leavefed.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
leavefed.lua
View Options
--[[
mattata v2.0 - Federation: leavefed
Removes the current chat from its federation. Requires group admin.
]]
local
tools
=
require
(
'telegram-bot-lua.tools'
)
local
plugin
=
{}
plugin
.
name
=
'leavefed'
plugin
.
category
=
'admin'
plugin
.
description
=
'Remove this chat from its federation.'
plugin
.
commands
=
{
'leavefed'
}
plugin
.
help
=
'/leavefed - Remove this chat from its current federation.'
plugin
.
group_only
=
true
plugin
.
admin_only
=
true
function
plugin
.
on_message
(
api
,
message
,
ctx
)
local
chat_id
=
message
.
chat
.
id
-- Check if the chat is in a federation
local
existing
=
ctx
.
db
.
execute
(
'SELECT f.id, f.name FROM federations f JOIN federation_chats fc ON f.id = fc.federation_id WHERE fc.chat_id = $1'
,
{
chat_id
}
)
if
not
existing
or
#
existing
==
0
then
return
api
.
send_message
(
chat_id
,
'This chat is not part of any federation.'
,
'html'
)
end
local
fed
=
existing
[
1
]
ctx
.
db
.
execute
(
'DELETE FROM federation_chats WHERE federation_id = $1 AND chat_id = $2'
,
{
fed
.
id
,
chat_id
}
)
return
api
.
send_message
(
chat_id
,
string.format
(
'This chat has left the federation <b>%s</b>.'
,
tools
.
escape_html
(
fed
.
name
)
),
'html'
)
end
return
plugin
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 14, 9:31 PM (18 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
132087
Default Alt Text
leavefed.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline