Download the PHP package viktorprogger/telegram-bot without Composer
On this page you can find all versions of the php package viktorprogger/telegram-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download viktorprogger/telegram-bot
More information about viktorprogger/telegram-bot
Files in viktorprogger/telegram-bot
Package telegram-bot
Short Description Bot runtime library to handle received updates
License BSD-3-Clause
Informations about the package telegram-bot
Botasis Runtime
Botasis Runtime is a powerful and versatile PHP library designed to streamline the development of Telegram bot applications. It serves as a foundational framework for building Telegram bots by providing essential abstractions and features, making it easier than ever to create interactive and intelligent chatbots.
Key Features
-
Middleware Stack: Botasis Runtime offers a robust middleware system, allowing you to easily define and organize the processing of incoming Telegram updates. With middleware, you can implement various behaviors and logic for your bot, such as authentication, message pre- and post-processing, and more.
-
Routing and Dispatching: The library includes a flexible and efficient routing system, enabling you to define routes for specific Telegram commands or interactions. Route groups, inner middlewares, and route parameter capturing provide fine-grained control over how updates are handled.
-
Update Handling: Botasis Runtime simplifies the management and manipulation of Telegram updates. It offers an intuitive API for accessing and modifying update data, making it effortless to interact with users and respond to their messages.
-
Framework Agnostic: Botasis Runtime is designed to be framework-agnostic, which means it can be seamlessly integrated into various PHP applications and frameworks. Whether you're using a specific PHP framework or developing a standalone bot application, Botasis Runtime adapts to your project's needs.
-
Extensibility: Extend and customize the behavior of your Telegram bot by adding your own middleware, handlers, and custom logic. It has all extension points you may ever need.
-
Configuration: Fine-tune bot settings, routing rules, and middleware stacks to create a bot that behaves exactly as you envision. No hard code, everything is configurable.
- Scalability: As your bot grows and evolves, Botasis Runtime enables you to make changes and enhancements easily, ensuring your bot remains adaptable to new features and user interactions.
Quick Start
The quickest way to start your app with Botasis is to use the Botasis Application Template.
If you don't want to use it, or you want to embed Botasis into your existing app, follow these steps:
-
Install Botasis Runtime and all requirements using Composer:
Packages details
- `botasis/runtime` - this package, required - `httpsoft/http-message` - An implementation of PSR-7 (HTTP Message) and PSR-17 (HTTP Factories). You can use any implementations you want, but personally I prefer this one. - `php-http/socket-client` - An implementation of PSR-18 (HTTP Client). You can use any implementation you want. - `yiisoft/event-dispatcher` - An implementation of PSR-14 (Event Dispatcher). You can use any implementation you want, but personally I prefer this one since it's a good and framework-agnostic implementation. - `yiisoft/di` - An implementation of PSR-11 (DI Container). You can use any implementation you want, but personally I prefer this one since it's a very efficient, convenient and framework-agnostic implementation. -
Create a new PHP script to initialize your bot. Normally a DI container will handle the most of this stuff.
PHP script listing
- Customize your bot by registering middleware, handlers, and routes based on your bot's behavior and requirements.
- Start receiving updates. You can use the GetUpdatesCommand to pull updates from Telegram API while working locally or SetTelegramWebhookCommand to set your bot's webhook address, so Telegram will send you updates itself.
That's it! You've now set up the foundation for your bot using Botasis Runtime. You can continue to enhance your bot's functionality by customizing its handlers, middleware, and routes to create engaging and interactive experiences for your users.
Features
1. State management
When your application requires handling chat or user state, this feature is essential. Follow these four steps to use it:
- Implement StateRepositoryInterface.
You may use any existing implementation (they will be implemented later). -
Save user/chat state using the repository:
-
Add StateMiddleware before the router middleware.
This allows you to access the current state within your update handlers.Caution! This middleware searches for both user and chat ids. In case you need only user or only chat id, you have implement this logic on your own.
- Use state in routing:
If you prefer to create a strictly typed State object, you need to implement the StateInterface along with the StateRepositoryInterface.
All versions of telegram-bot with dependencies
botasis/telegram-client Version ^1.0
psr/container Version ^2.0
psr/event-dispatcher Version ^1.0
psr/log Version ^1.0.0||^2.0.0||^3.0.0
symfony/deprecation-contracts Version ^3.5
yiisoft/friendly-exception Version ^1.1
yiisoft/injector Version ^1.0