local question, answer = rest:match('^(.-)%s*|%s*(.+)$')
if not question or question == '' or not answer or answer == '' then
- return api.send_message(chat_id, 'Please separate the question and answer with a pipe character (|).\nExample: <code>/customcaptcha set What colour is the sky? | blue</code>', { parse_mode = 'html' })
+ local err_text = 'Please separate the question and answer with a pipe character (|).\n'
+ .. 'Example: <code>/customcaptcha set What colour is the sky? | blue</code>'
'Welcome, <a href="tg://user?id=%d">%s</a>! To verify you\'re human, please answer the following question:\n\n<b>%s</b>\n\nType your answer in the chat. You have %d seconds.',
new_member.id,
tools.escape_html(new_member.first_name),
tools.escape_html(question),
timeout
)
local sent = api.send_message(chat_id, text, { parse_mode = 'html' })
plugin.help = '/reactions <on|off> - Toggle reaction karma tracking for this group.'
plugin.group_only = true
plugin.admin_only = true
local THUMBS_UP = '\xF0\x9F\x91\x8D'
local THUMBS_DOWN = '\xF0\x9F\x91\x8E'
function plugin.on_message(api, message, ctx)
if not message.args or message.args == '' then
-- Show current status
local enabled = session.get_cached_setting(message.chat.id, 'reactions_enabled', function()
local result = ctx.db.call('sp_get_chat_setting', { message.chat.id, 'reactions_enabled' })
if result and #result > 0 then
return result[1].value
end
return nil
end)
local status = (enabled == 'true') and 'enabled' or 'disabled'
return api.send_message(message.chat.id,
string.format('Reaction karma is currently <b>%s</b> for this group.\nUse <code>/reactions on</code> or <code>/reactions off</code> to toggle.', status),
Searches for GIFs using the Tenor API and sends them as animations.
]]
local plugin = {}
plugin.name = 'gif'
plugin.category = 'media'
plugin.description = 'Search for GIFs using Tenor'
plugin.commands = { 'gif', 'tenor' }
plugin.help = '/gif <query> - Search for a GIF and send it.'
function plugin.on_message(api, message, ctx)
local http = require('src.core.http')
local url = require('socket.url')
local tenor_key = ctx.config.get('TENOR_API_KEY')
if not tenor_key or tenor_key == '' then
return api.send_message(message.chat.id, 'The Tenor API key is not configured. Please set <code>TENOR_API_KEY</code> in the bot configuration.', 'html')
end
if not message.args or message.args == '' then
return api.send_message(message.chat.id, 'Please specify a search query, e.g. <code>/gif funny cats</code>.', { parse_mode = 'html' })
plugin.description = 'View your Last.fm now playing and recent tracks'
plugin.commands = { 'lastfm', 'np', 'fmset' }
plugin.help = '/np - Show your currently playing or most recent track.\n/fmset <username> - Link your Last.fm account.\n/lastfm [username] - View recent tracks for a Last.fm user.'
function plugin.on_message(api, message, ctx)
local http = require('src.core.http')
local url = require('socket.url')
local tools = require('telegram-bot-lua.tools')
local config = require('src.core.config')
local api_key = config.get('LASTFM_API_KEY')
if not api_key or api_key == '' then
return api.send_message(message.chat.id, 'Last.fm is not configured. The bot admin needs to set LASTFM_API_KEY.')
end
-- /fmset: link Last.fm username
if message.command == 'fmset' then
local username = message.args
if not username or username == '' then
return api.send_message(message.chat.id, 'Please provide your Last.fm username. Usage: /fmset <username>')