- 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'
+ 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
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)