Merge pull request #1866 from CiBeRHeMuL/andrew-gos/telegram-bot-bundle

Add recipe for andrew-gos/telegram-bot-bundle
This commit is contained in:
Fabien Potencier
2025-10-04 16:19:50 +02:00
committed by GitHub
2 changed files with 80 additions and 0 deletions
@@ -0,0 +1,72 @@
# -----------------------------------------------------------------------------
# AndrewGos Telegram Bot Bundle - Default Configuration
# -----------------------------------------------------------------------------
# This file was generated by the AndrewGos Telegram Bot Bundle recipe.
# It provides a solid foundation for your first Telegram bot.
#
# ❗️ YOUR NEXT STEPS:
# 1. Set your bot's token in the .env file:
# TELEGRAM_BOT_TOKEN="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
#
# 2. Create the handler and checker classes referenced below, for example:
# src/Telegram/Handler/StartHandler.php
# src/Telegram/Checker/CommandChecker.php
# src/Telegram/Handler/DefaultMessageHandler.php
# -----------------------------------------------------------------------------
andrew_gos_telegram_bot:
bots:
# 🤖 This is the unique name for your bot.
# You'll use this name in console commands, e.g., `php bin/console andrew-gos:telegram-bot:listen default_bot`
# default_bot:
# 🏭 The factory defines how the Telegram API client is created.
# factory:
# 'getUpdates' is a shortcut for the long-polling factory. It's perfect for
# getting started quickly with the `listen` command.
# For production, you will likely switch to webhooks using the 'default' factory.
# method: 'getUpdates'
# arguments:
# ✅ Best Practice: Never hardcode secrets!
# This reads the token from your .env file.
# $token: '%env(string:TELEGRAM_BOT_TOKEN)%'
# 🔌 Plugins are services that run on EVERY update before handlers.
# They are great for logging, analytics, or session management.
# Uncomment this section to enable a request logger.
# plugins:
# - class: App\Telegram\Plugin\RequestLoggerPlugin
# arguments:
# # This injects the default Symfony logger for the 'telegram' channel.
# $logger: '@monolog.logger.telegram'
# 🔄 Handlers contain the core logic of your bot.
# They are checked in order of priority (higher numbers first).
# The first handler whose 'checker' passes will be executed.
# handlers:
# Handler for the '/start' command. It has a high priority.
# -
# The checker decides if the handler should run for the current update.
# checker:
# class: App\Telegram\Checker\CommandChecker
# arguments:
# $command: '/start'
# The handler contains the actual logic to execute.
# handler: App.Telegram.Handler.StartHandler
# Middlewares run after the checker but before the handler.
# Useful for authentication, rate limiting, etc.
# middlewares:
# - App\Telegram\Middleware\UserRateLimiterMiddleware
# Higher priority means this handler is checked before others.
# priority: 10
# A fallback handler for any message not caught by the handlers above.
# When a 'checker' is not specified, it defaults to `AnyChecker`,
# -
# which always passes. This makes it a perfect "catch-all".
# handler: App\Telegram\Handler\DefaultMessageHandler
# A negative priority ensures this runs last.
# priority: -10
@@ -0,0 +1,8 @@
{
"bundles": {
"AndrewGos\\TelegramBotBundle\\AndrewGosTelegramBotBundle": ["all"]
},
"copy-from-recipe": {
"config/": "%CONFIG_DIR%/"
}
}