viktorprorgger / bot-template
Telegram bot template
dev-main
2024-09-30 08:51 UTC
Requires
- php: ^8.2
- ext-apcu: *
- ext-pdo: *
- botasis/runtime: ~0.2
- botasis/telegram-client: ~0.2
- httpsoft/http-message: ^1.0
- monolog/monolog: ^3.2
- php-http/socket-client: ^2.1
- psr/container: ^2.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0||^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- ramsey/uuid: ^4.2
- sentry/sdk: ^3.3
- vishnubob/wait-for-it: dev-master
- yiisoft/aliases: ^3.0
- yiisoft/arrays: ^3.0
- yiisoft/cache: ^3.0
- yiisoft/cache-apcu: dev-master
- yiisoft/config: ^1.1
- yiisoft/data: ^1.0
- yiisoft/data-response: ^2.0
- yiisoft/di: ^1.2
- yiisoft/error-handler: ^3.0
- yiisoft/http: ^1.2
- yiisoft/request-body-parser: ^1.1
- yiisoft/request-model: ^1.0@dev
- yiisoft/router: ^3.0
- yiisoft/router-fastroute: ^3.0
- yiisoft/yii-console: ^2.0
- yiisoft/yii-cycle: 2.0.x-dev
- yiisoft/yii-event: ^2.0
- yiisoft/yii-http: ^1.0
- yiisoft/yii-queue: 3.0.x-dev
- yiisoft/yii-queue-amqp: 3.0.x-dev
- yiisoft/yii-runner-console: ^2.0
- yiisoft/yii-runner-roadrunner: ^2.0
- yiisoft/yii-sentry: ^2.0
Requires (Dev)
- infection/infection: ^0.26
- maglnet/composer-require-checker: ^4.5
- phpunit/phpunit: ^10.0
- psalm/attributes: ^0.1.0
- roave/infection-static-analysis-plugin: ^1.28
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.7
- symfony/var-dumper: ^v6.2
- v.chetkov/php-clean-architecture: ^0.1.0
- vimeo/psalm: ^5.4
This package is auto-updated.
Last update: 2024-10-30 09:13:06 UTC
README
I will update it to a cutting edge after the runtime package 1.0 release.
Telegram bot template
It's a ready-to-use application template meant to boost creation of a new Telegram bot for you. All you need to start is to write your app logic, everything other is in the template.
Quick Start
Prerequisites
- Your Telegram bot is created via @BotFather, and you know its token
- The latest version of
docker
is installed and running - Port 3306 for MySQL on your computer is opened (you can configure any other port of your choice in the
.env
file, it's just the default value)
Installing
git clone git@github.com:viktorprogger/bot-template.git
- Create
.env
file in the project root and set there your bot token to the keyBOT_TOKEN
like this:BOT_TOKEN=12345:abcdef
. See.env.example
to get list of all available environment variables - Run
docker compose build php
- Run
docker compose --profile console-tools run --rm --no-deps php composer i
- Run
docker compose --profile console-tools run --rm --no-deps php vendor/bin/rr get
- Run
docker compose --profile main up -d
- Type
/start
to your bot in Telegram, and you'll get an answer in half a minute (app asks for the getUpdates every 30 seconds)
Available docker-compose profiles
This repo uses docker-compose profiles mechanism to get only needed services working
console-tools
- starts php service only, without DB, AMQP and other services. Useful to runcomposer
,psalm
and other console tools.main
- get your application up and running. It startsphp
,db
andamqp
services.full
- get working Loki, Grafana and Promtail for convenient logs reading. This app produces tons of logs, so these services will be useful to get in what's happening inside your app.
To get everything down regardless of a set of running services, run docker compose down --remove-orphans
Components
DBAL
This app uses yiisoft/yii-cycle as DBAL.
In dev mode it automatically syncs your DB schema with your code, see \Cycle\Schema\Generator\SyncTables
class.