Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F626625
captcha.lua
No One
Temporary
Actions
Download 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
captcha.lua
View Options
--[[
mattata v2.0 - Captcha Middleware
Gates new members with captcha verification when enabled.
The actual captcha challenge is handled by the join_captcha plugin.
This middleware restricts unverified users from chatting.
]]
local
captcha
=
{}
captcha
.
name
=
'captcha'
local
session
=
require
(
'src.core.session'
)
function
captcha
.
run
(
ctx
,
message
)
if
not
ctx
.
is_group
or
not
message
.
from
then
return
ctx
,
true
end
-- Check if this user has a pending captcha
local
pending
=
session
.
get_captcha
(
message
.
chat
.
id
,
message
.
from
.
id
)
if
not
pending
then
return
ctx
,
true
end
-- If user has pending captcha, only allow callback query responses (handled elsewhere)
-- Block regular messages from unverified users
if
not
message
.
new_chat_members
then
-- Delete the message from the unverified user
pcall
(
function
()
ctx
.
api
.
delete_message
(
message
.
chat
.
id
,
message
.
message_id
)
end
)
return
ctx
,
false
end
return
ctx
,
true
end
return
captcha
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sun, Nov 15, 12:57 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
132832
Default Alt Text
captcha.lua (1 KB)
Attached To
Mode
R69 mattata
Attached
Detach File
Event Timeline