Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
28 KB
Referenced Files
None
Subscribers
None
diff --git a/libs/utils.lua b/libs/utils.lua
index 061f8d7..f6f9c0e 100644
--- a/libs/utils.lua
+++ b/libs/utils.lua
@@ -1,531 +1,524 @@
local utils = {}
local redis = dofile('libs/redis.lua')
local configuration = require('configuration')
local mattata = {}
local api = {}
local tools = {}
function utils:init()
mattata = self
api = self.api
tools = self.tools
return utils
end
function utils.is_trusted_user(chat_id, user_id)
if redis:sismember('administration:' .. chat_id .. ':trusted', user_id) then
return true
end
return false
end
function utils.get_user_count()
return #redis:keys('user:*:info')
end
function utils.get_group_count()
return #redis:keys('chat:*:info')
end
function utils.get_user_language(user_id)
return redis:hget('chat:' .. user_id .. ':settings', 'language') or 'en_gb'
end
function utils.get_log_chat(chat_id)
local chat = redis:hget('chat:' .. chat_id .. ':settings', 'log chat')
if chat ~= false and chat ~= nil then
return chat
end
return configuration.log_channel or false
end
-function utils.set_captcha(chat_id, user_id, id, text, original_message, is_inline)
+function utils.set_captcha(chat_id, user_id, id, text, original_message)
local hash = string.format('chat:%s:captcha:%s', chat_id, user_id)
redis:hset(hash, 'id', id)
redis:hset(hash, 'text', text)
redis:hset(hash, 'original message', original_message)
redis:hset(hash, 'time', os.time())
- return redis:hset(hash, 'is inline', is_inline)
-end
-
-function utils.is_inline_captcha(chat_id, user_id)
- return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'is inline')
+ return true
end
function utils.get_captcha_id(chat_id, user_id)
- return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'id')
+ return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'id') or false
end
function utils.get_captcha_text(chat_id, user_id)
- return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'text')
+ return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'text') or false
end
function utils.get_captcha_original_message(chat_id, user_id)
- return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'original message')
+ return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'original message') or false
end
function utils.get_captcha_time(chat_id, user_id)
- return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'time')
+ return redis:hget('chat:' .. chat_id .. ':captcha:' .. user_id, 'time') or false
end
function utils.delete_redis_hash(hash, field)
return redis:hdel(hash, field)
end
-function utils.wipe_redis_captcha(chat_id, user_id, not_completed)
+function utils.wipe_redis_captcha(chat_id, user_id)
redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'original message')
redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'id')
- if not not_completed then
- redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'text')
- end
- redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'is inline')
+ redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'text')
redis:hdel('chat:' .. chat_id .. ':captcha:' .. user_id, 'time')
end
function utils.get_missing_languages(delimiter)
local missing_languages = redis:smembers('mattata:missing_languages')
if not missing_languages then
return false
end
local output = {}
for _, v in pairs(missing_languages) do
table.insert(output, v)
end
delimiter = delimiter or ', '
return table.concat(output, delimiter)
end
function utils.purge_user(user)
if type(user) ~= 'table' then
return false
end
user = user.from or user
redis:hdel('user:' .. user.id .. ':info', 'id')
if user.username or redis:hget('user:' .. user.id .. ':info', 'username') then
redis:hdel('user:' .. user.id .. ':info', 'username')
local all = redis:smembers('user:' .. user.id .. ':usernames')
for _, v in pairs(all) do
redis:srem('user:' .. user.id .. ':usernames', v)
end
redis:del('username:' .. user.id)
end
redis:hdel('user:' .. user.id .. ':info', 'first_name')
if user.name or redis:hget('user:' .. user.id .. ':info', 'name') then
redis:hdel('user:' .. user.id .. ':info', 'name')
end
if user.last_name or redis:hget('user:' .. user.id .. ':info', 'last_name') then
redis:hdel('user:' .. user.id .. ':info', 'last_name')
end
if user.language_code or redis:hget('user:' .. user.id .. ':info', 'language_code') then
redis:hdel('user:' .. user.id .. ':info', 'language_code')
end
return true
end
function utils.get_list(name)
name = tostring(name)
local length = redis:llen(name)
return redis:lrange(name, 0, tonumber(length) - 1)
end
function utils.get_inline_help(input, offset)
offset = offset and tonumber(offset) or 0
local inline_help = {}
local count = offset + 1
local plugin_list = mattata.plugin_list
for _, plugin in pairs(mattata.administrative_plugin_list) do
if not tools.table_contains(plugin_list, plugin) then
table.insert(plugin_list, plugin)
end
end
table.sort(plugin_list)
for k, v in pairs(plugin_list) do
-- The bot API only accepts a maximum of 50 results, hence we need the offset.
if k > offset and k < offset + 50 then
v = v:gsub('\n', ' ')
if v:match('^/.- %- .-$') and v:lower():match(input) then
table.insert(inline_help,
{
['type'] = 'article',
['id'] = tostring(count),
['title'] = v:match('^(/.-) %- .-$'),
['description'] = v:match('^/.- %- (.-)$'),
['input_message_content'] = {
['message_text'] = utf8.char(8226) .. ' ' .. v:match('^(/.-) %- .-$') .. ' - ' .. v:match('^/.- %- (.-)$')
}
})
count = count + 1
end
end
end
return inline_help
end
function utils.string_to_time(str, is_temp_ban)
if not str then
return false
end
str = tostring(str):gsub('%s', '')
local base_date = {
['year'] = 1970,
['month'] = 1,
['day'] = 1,
['hour'] = 0,
['min'] = 0,
['sec'] = 0
}
local units = {
['y'] = 'year',
['year'] = 'year',
['years'] = 'year',
['mo'] = 'month',
['month'] = 'month',
['months'] = 'month',
['w'] = '7day',
['week'] = '7day',
['weeks'] = '7day',
['d'] = 'day',
['day'] = 'day',
['days'] = 'day',
['h'] = 'hour',
['hour'] = 'hour',
['hours'] = 'hour',
['m'] = 'min',
['min'] = 'min',
['mins'] = 'min',
['minute'] = 'min',
['minutes'] = 'min',
['s'] = 'sec',
['sec'] = 'sec',
['secs'] = 'sec',
['second'] = 'sec',
['seconds'] = 'sec'
}
for number, unit in str:gmatch('(%d+)(%a+)') do
local amount, field = units[unit]:match('^(%d*)(%a+)$')
base_date[field] = base_date[field] + tonumber(number) * (tonumber(amount) or 1)
end
local final_length = os.time(base_date)
if is_temp_ban and final_length <= 59 then
return false
end
return final_length
end
function utils.get_user_setting(chat_id, user_id, setting)
if not chat_id or not user_id or not setting then
return false
elseif not redis:hexists('user:' .. user_id .. ':' .. chat_id .. ':settings', tostring(setting)) then
return false
end
return true
end
function utils.is_group(message)
if not message or not message.chat or not message.chat.type or message.chat.type == 'private' then
return false
end
return true
end
function utils.get_user_message_statistics(user_id, chat_id)
return {
['messages'] = tonumber(redis:get('messages:' .. user_id .. ':' .. chat_id)) or 0,
['name'] = redis:hget('user:' .. user_id .. ':info', 'first_name'),
['id'] = user_id
}
end
function utils.reset_message_statistics(chat_id)
if not chat_id or tonumber(chat_id) == nil then
return false
end
local messages = redis:keys('messages:*:' .. chat_id)
if not next(messages) then
return false
end
for _, v in pairs(messages) do
redis:del(v)
end
return true
end
function utils.input(s)
local mentioned_user = false
if not s then
return false
elseif type(s) == 'table' then
if s.entities and #s.entities >= 2 and s.entities[2].type == 'text_mention' then
mentioned_user = tostring(s.entities[2].user.id)
end
s = s.text
end
if s:lower():match('^mattata search %a+ for .-$') then
return s:lower():match('^mattata search %a+ for (.-)$')
elseif not s:lower():match('^[%%/%%!%%$%%^%%?%%&%%%%]') then
return s
end
local input = s:find(' ')
if not input then
return false
end
s = s:sub(input + 1)
input = s:find(' ')
if mentioned_user then
s = input and mentioned_user .. ' ' .. s:sub(input + 1) or mentioned_user
end
return s
end
function utils.get_input(message, has_reason)
local input = utils.input(message)
if message.reply then
if not message.reply.from or message.reply.forward_from then
return false
elseif has_reason and input then
return message.reply.from.id, input
end
return message.reply.from.id
elseif not input then
return false
elseif has_reason and input:find(' ') then
return input:match('^(.-) '), input:match(' (.-)$')
end
return input
end
function utils.get_chat_id(chat)
if not chat then
return false
end
local success = api.get_chat(chat)
if not success or not success.result then
return false
end
return success.result.id
end
function utils.get_setting(chat_id, setting)
if not chat_id or not setting then
return false
end
return redis:hget('chat:' .. chat_id .. ':settings', tostring(setting))
end
function utils.get_value(chat_id, value)
if not chat_id or not value then
return false
end
return redis:hget('chat:' .. chat_id .. ':info', tostring(value))
end
function utils.set_value(chat_id, key, value)
if not chat_id or not key or not value then
return false
end
return redis:hset('chat:' .. chat_id .. ':info', tostring(key), tostring(value))
end
function utils.log_error(error_message)
error_message = tostring(error_message):gsub('%%', '%%%%')
local output = string.format('%s[31m[Error] %s%s[0m', string.char(27), error_message, string.char(27))
print(output)
end
function utils.set_command_action(chat_id, message_id, command)
local hash = string.format('action:%s:%s', chat_id, message_id)
return redis:set(hash, command)
end
function utils.increase_administrative_action(chat_id, user_id, action, increase_by)
if not increase_by or tonumber(increase_by) == nil then
increase_by = 1
end
local hash = string.format('chat:%s:%s', chat_id, user_id)
return redis:hincrby(hash, action, increase_by)
end
function utils.is_whitelisted_link(link)
if link == 'username' or link == 'isiswatch' or link == 'mattata' or link == 'telegram' then
return true
end
return false
end
function utils.is_valid(message) -- Performs basic checks on the message object to see if it's fit
-- for its purpose. If it's valid, this function will return `true` - otherwise it will return `false`.
if not message then -- If the `message` object is nil, then we'll ignore it.
return false, 'No `message` object exists!'
elseif message.date < os.time() - 7 then -- We don't want to process old messages, so anything
-- older than the current system time (giving it a leeway of 7 seconds).
return false, 'This `message` object is too old!'
elseif not message.from then -- If the `message.from` object doesn't exist, this will likely
-- break some more code further down the line!
return false, 'No `message.from` object exists!'
end
return true
end
function utils.get_chat_members(chat_id)
return redis:smembers('chat:' .. chat_id .. ':users')
end
function utils.is_privacy_enabled(user_id)
return redis:exists('user:' .. user_id .. ':opt_out')
end
function utils.uses_administration(chat_id)
return utils.get_setting(chat_id, 'use administration')
end
function utils.is_plugin_allowed(plugin, is_blacklisted)
if not is_blacklisted then
return true
end
for _, p in pairs(configuration.blacklist_plugin_exceptions) do
if p == plugin then
return true
end
end
return false
end
function utils.command_action(chat_id, message_id)
if not chat_id or not message_id then
return false
end
return string.format('action:%s:%s', chat_id, message_id)
end
function utils.is_fed_admin(fed_id, user_id)
if not fed_id or not user_id then
return false
end
return redis:sismember('fedadmins:' .. fed_id, user_id)
end
function utils.is_fed_creator(fed_id, user_id)
if not fed_id or not user_id then
return false
end
local creator = redis:hget('fed:' .. fed_id, 'creator')
return tonumber(user_id) == tonumber(creator) and true or false
end
function utils.is_user_fedbanned(chat_id, user_id)
if not chat_id or not user_id then
return false
end
local feds = redis:smembers('chat:' .. chat_id .. ':feds')
if #feds == 0 then
return false
end
for _, fed in pairs(feds) do
if redis:sismember('fedbans:' .. fed, user_id) then
return true
end
end
return false
end
function utils.has_fed(user_id, fed_id)
if not user_id then
return false
end
local feds = redis:smembers('feds:' .. user_id)
if #feds > 0 then
if fed_id then
for _, fed in pairs(feds) do
if fed_id == fed then
return true, fed
end
end
return false
end
return true, feds[1], true
end
return false
end
function utils.fed_ban_chat_member(chat_id, user_id, fed_list)
if not chat_id or not user_id then
return false
end
fed_list = type(fed_list) == 'table' and fed_list or { fed_list }
api.ban_chat_member(chat_id, user_id)
local success
for _, fed in pairs(fed_list) do
success = redis:sadd('fedbans:' .. fed, user_id)
end
return success
end
function utils.fed_unban_chat_member(chat_id, user_id, fed_list)
if not chat_id or not user_id then
return false
end
fed_list = type(fed_list) == 'table' and fed_list or { fed_list }
local success
api.unban_chat_member(chat_id, user_id)
for _, fed in pairs(fed_list) do
success = redis:srem('fedbans:' .. fed, user_id)
end
return success
end
function utils.is_fed_banned(fed_id, user_id)
if not fed_id or not user_id then
return false
end
return redis:sismember('fedbans:' .. fed_id, user_id) and true or false
end
function utils.get_feds(chat_id)
if not chat_id then
return false
end
return redis:smembers('chat:' .. chat_id .. ':feds')
end
function utils.get_fed_bans(fed_id)
if not fed_id then
return false
end
return #redis:smembers('fedbans:' .. fed_id)
end
function utils.fed_whitelist(chat_id, user_id)
if not chat_id or not user_id then
return false
end
return redis:sadd('fedwhitelist:' .. chat_id, user_id)
end
function utils.is_user_fed_whitelisted(chat_id, user_id)
if not chat_id or not user_id then
return false
end
return redis:sismember('fedwhitelist:' .. chat_id, user_id) and true or false
end
function utils.is_duplicate(tab, val)
local seen = {}
local duplicated = {}
for i = 1, #tab do
local element = tab[i]
if seen[element] then
duplicated[element] = true
else
seen[element] = true
end
end
if val and duplicated[val] then
return true
elseif val then
return false
end
return duplicated
end
return utils
\ No newline at end of file
diff --git a/plugins/administration/join_captcha.mattata b/plugins/administration/join_captcha.mattata
index 0b939ad..c2f4e36 100644
--- a/plugins/administration/join_captcha.mattata
+++ b/plugins/administration/join_captcha.mattata
@@ -1,137 +1,143 @@
--[[
Copyright 2020 Matthew Hesketh <matthew@matthewhesketh.com>
This code is licensed under the MIT. See LICENSE for details.
]]
local join_captcha = {}
local mattata = require('mattata')
local redis = dofile('libs/redis.lua')
local captcha_lib = require('captcha')
function join_captcha.cron()
local keys = redis:keys('chat:*:captcha:*')
- for _, key in pairs(keys) do
- local captcha_time = redis:hget(key, 'time') or 0
- local chat_id, user_id = key:match('^chat:(%-?%d+):captcha:(%d+)$')
- local original_message = redis:hget(key, 'original message')
- local photo_id = redis:hget(key, 'id')
- if tonumber(captcha_time) <= (os.time() - 300) then
- mattata.delete_message(chat_id, tonumber(original_message))
- mattata.delete_message(chat_id, tonumber(photo_id))
- local user = mattata.get_user(user_id, nil, nil, true)
- local kicked_user = mattata.get_formatted_user(user_id, user.result.first_name, 'html')
- local action = mattata.get_setting(chat_id, 'ban not kick') and mattata.ban_chat_member or mattata.kick_chat_member
- local action_str = mattata.get_setting(chat_id, 'ban not kick') and 'Banned' or 'Kicked'
- local output = action_str .. ' ' .. kicked_user .. ' <code>[' .. user_id .. ']</code> %sbecause they didn\'t complete the CAPTCHA within 5 minutes!'
- if mattata.get_setting(chat_id, 'log administrative actions') then
- local chat = mattata.get_chat(chat_id)
- local log_output = output
- if chat then
- local title = mattata.escape_html(chat.result.title)
- title = 'from ' .. title .. ' <code>[' .. chat.result.id .. ']</code> '
- log_output = string.format(log_output, title)
- log_output = log_output .. '\n#chat' .. tostring(chat.result.id):gsub('^%-100', '') .. ' #user' .. user_id
+ for _, key in ipairs(keys) do
+ local captcha_time = redis:hget(key, 'time')
+ if captcha_time and tonumber(captcha_time) ~= nil then
+ captcha_time = tonumber(captcha_time)
+ local chat_id, user_id = key:match('^chat:(%-?%d+):captcha:(%d+)$')
+ local original_message = redis:hget(key, 'original message')
+ local photo_id = redis:hget(key, 'id')
+ if captcha_time <= (os.time() - 300) then
+ mattata.delete_message(chat_id, tonumber(original_message))
+ mattata.delete_message(chat_id, tonumber(photo_id))
+ local user = mattata.get_user(user_id, nil, nil, true)
+ local kicked_user = mattata.get_formatted_user(user_id, user.result.first_name, 'html')
+ local action = mattata.get_setting(chat_id, 'ban not kick') and mattata.ban_chat_member or mattata.kick_chat_member
+ local action_str = mattata.get_setting(chat_id, 'ban not kick') and 'Banned' or 'Kicked'
+ local output = action_str .. ' ' .. kicked_user .. ' <code>[' .. user_id .. ']</code> %sbecause they didn\'t complete the CAPTCHA within 5 minutes!'
+ if mattata.get_setting(chat_id, 'log administrative actions') then
+ local chat = mattata.get_chat(chat_id)
+ local log_output = output
+ if chat then
+ local title = mattata.escape_html(chat.result.title)
+ title = 'from ' .. title .. ' <code>[' .. chat.result.id .. ']</code> '
+ log_output = string.format(log_output, title)
+ log_output = log_output .. '\n#chat' .. tostring(chat.result.id):gsub('^%-100', '') .. ' #user' .. user_id
+ else
+ log_output = string.format(log_output, '')
+ end
+ mattata.send_message(mattata.get_log_chat(chat_id), log_output, 'html')
else
- log_output = string.format(log_output, '')
+ output = string.format(output, '')
+ mattata.send_message(chat_id, output, 'html')
end
-
- mattata.send_message(mattata.get_log_chat(chat_id), log_output, 'html')
- else
- output = string.format(output, '')
- mattata.send_message(chat_id, output, 'html')
+ mattata.wipe_redis_captcha(chat_id, user_id)
+ action(chat_id, user_id)
end
- mattata.wipe_redis_captcha(chat_id, user_id)
- action(chat_id, user_id)
end
end
end
function join_captcha.on_callback_query(_, callback_query, message)
if not callback_query.data:match('^.-:.-:.-$') then
return false
end
local chat_id, user_id, guess = callback_query.data:match('^(.-):(.-):(.-)$')
if callback_query.from.id ~= tonumber(user_id) then
return mattata.answer_callback_query(callback_query.id, 'This isn\'t your CAPTCHA!')
end
local correct = mattata.get_captcha_text(chat_id, callback_query.from.id)
local id = mattata.get_captcha_original_message(chat_id, callback_query.from.id)
local photo_id = mattata.get_captcha_id(chat_id, callback_query.from.id)
- mattata.wipe_redis_captcha(chat_id, callback_query.from.id, true) -- we're done with this now
+ local default_permissions = mattata.get_chat(message.chat.id)
+ mattata.wipe_redis_captcha(chat_id, callback_query.from.id)
if guess:lower() == correct:lower() then
- local default_permissions = mattata.get_chat(message.chat.id)
local success
if not default_permissions then
success = mattata.restrict_chat_member(chat_id, callback_query.from.id, 'forever', true, true, true, true, true, false, false, false)
else
success = mattata.restrict_chat_member(chat_id, callback_query.from.id, 'forever', default_permissions.result.permissions)
end
if not success then
mattata.delete_message(chat_id, tonumber(photo_id))
return mattata.edit_message_text(message.chat.id, tonumber(id), 'I could not give that user their permissions. You may have to do this manually!')
end
mattata.delete_message(chat_id, tonumber(photo_id))
mattata.delete_message(chat_id, tonumber(id))
- redis:hdel('chat:' .. chat_id .. ':captcha:' .. callback_query.from.id, 'text')
return mattata.answer_callback_query(callback_query.id, 'Success! You may now speak!')
else
mattata.delete_message(chat_id, tonumber(photo_id))
mattata.delete_message(chat_id, tonumber(id))
- redis:hdel('chat:' .. chat_id .. ':captcha:' .. callback_query.from.id, 'text')
- return mattata.answer_callback_query(callback_query.id, 'You got it wrong! Consult an admin if you wish to be unmuted!')
+ if mattata.get_setting(chat_id, 'log administrative actions') then
+ local failed_username = mattata.get_formatted_user(callback_query.from.id, callback_query.from.first_name, 'html')
+ local chat_title = mattata.escape_html(message.chat.title)
+ local output = '%s <code>[%s]</code> failed the CAPTCHA in %s <code>[%s]</code>. They guessed <code>%s</code> but the correct answer was <code>%s</code>.\n#chat%s #user%s'
+ output = string.format(output, failed_username, user_id, chat_title, chat_id, guess, correct, tostring(chat_id):gsub('^%-100', ''), user_id)
+ local log_chat = mattata.get_log_chat(chat_id)
+ mattata.send_message(log_chat, output, 'html')
+ end
+ return mattata.answer_callback_query(callback_query.id, 'You got it wrong! Re-join the group and try again, or consult an admin if you wish to be unmuted!')
end
end
function join_captcha.on_member_join(_, message, configuration)
- if mattata.get_setting(message.chat.id, 'require captcha') and not message.new_chat_participant.is_bot and not mattata.get_captcha_id(message.chat.id, message.new_chat_participant.id) then
+ if mattata.get_setting(message.chat.id, 'require captcha') and tostring(message.new_chat_participant.is_bot) ~= 'true' and not mattata.get_captcha_id(message.chat.id, message.new_chat_participant.id) then
local chat_member = mattata.get_chat_member(message.chat.id, message.new_chat_participant.id)
if not chat_member then -- we can't even get info about the user? abort! abort!
return false
- elseif chat_member.result.can_send_messages == false then -- if it's false it means he's already muted!
- return false
end
local download_location = configuration.download_location
if download_location:match('/$') then
download_location = download_location:match('^(.-)/$')
end
local new_captcha = captcha_lib.new()
new_captcha:setlength(6)
new_captcha:setfontsize(40)
new_captcha:setpath(download_location)
new_captcha:setformat('jpg')
new_captcha:setfontsfolder(configuration.fonts_directory)
local generated_captcha = new_captcha:generate()
local username = message.new_chat_participant.username and '@' .. message.new_chat_participant.username or false
local msg = string.format('Hey, [%s](tg://user?id=%s)! Please enter the CAPTCHA below before you can speak! You will be removed in 5 minutes if you don\'t do this.', username or mattata.escape_markdown(message.new_chat_participant.first_name), message.new_chat_participant.id)
local correct = generated_captcha:match('^' .. download_location .. '/(.-)%.jpg$')
local captchas = mattata.random_string(6, 5)
table.insert(captchas, correct)
table.sort(captchas)
local callback_data = string.format('join_captcha:%s:%s', message.chat.id, message.new_chat_participant.id)
local keyboard = mattata.inline_keyboard():row(
mattata.row()
:callback_data_button(captchas[1], callback_data .. ':' .. captchas[1])
:callback_data_button(captchas[2], callback_data .. ':' .. captchas[2])
:callback_data_button(captchas[3], callback_data .. ':' .. captchas[3])
):row(
mattata.row()
:callback_data_button(captchas[4], callback_data .. ':' .. captchas[4])
:callback_data_button(captchas[5], callback_data .. ':' .. captchas[5])
:callback_data_button(captchas[6], callback_data .. ':' .. captchas[6])
)
local photo_success = mattata.send_photo(message.chat.id, generated_captcha)
local success = mattata.send_message(message.chat.id, msg, 'markdown', true, false, nil, keyboard)
if not photo_success or not success then
return false
end
os.execute('rm ' .. generated_captcha)
local mute = mattata.restrict_chat_member(message.chat.id, message.new_chat_participant.id, 'forever', false, false, false, false, false, false, false, false)
if not mute then
return false
end
- mattata.set_captcha(message.chat.id, message.new_chat_participant.id, photo_success.result.message_id, correct, success.result.message_id, true)
+ mattata.set_captcha(message.chat.id, message.new_chat_participant.id, photo_success.result.message_id, correct, success.result.message_id)
return mattata.delete_message(message.chat.id, message.message_id)
end
end
return join_captcha
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Sat, May 16, 7:06 AM (16 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64038
Default Alt Text
(28 KB)

Event Timeline