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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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.

Example

Here is an example of a simple Telegram bot that will send currency exchange rates by your request, but only if you already paid for this functionality.

  1. Create routes:

    Here we map three commands to their corresponding actions. /start and /pay commands are static routes. That means they will be mapped only if they match exactly to what did user send.
    On the other hand, /rates command is a dynamic one and should look like /rates USD GBP.

  2. Create command handlers.

    1. The most simple one is StartAction. It will only send a greeting message.

    2. Accepting payments is out of scope of this example. I will skip the PayAction handler, as there is nothing interesting in comparison to RatesAction.
    3. RatesAction handler:
  3. Create middlewares.

    1. UserRegisterMiddleware is assigned to the outer group. So it's always executed before each handler. It registers a user and adds it to an Update object as an attribute:

      Because of this middleware, request handlers may use #[UpdateAttribute('user')] attribute and get a typed User object (see RatesAction::handle()).

    2. PaidAccessMiddleware won't let to make a rates request if the user is not a premium user. It's also ready to be attached to any other paid endpoint.

With Botasis Runtime you shouldn't think about Telegram infrastructure. Just write your business logic as you already do for HTTP request handling!

Key Features

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:

  1. 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.
  2. Create a new PHP script to initialize your bot. Normally a DI container will handle the most of this stuff.

    PHP script listing
  3. Customize your bot by registering middleware, actions, and routes based on your bot's behavior and requirements.
  4. 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 actions, middleware, and routes to create engaging and interactive experiences for your users.

Features

1. Routing

You can create routes and sub-routes for your Telegram bot. Every route consists of two parts;

1. Attributes usage in routing

1. State management

When your application requires handling chat or user state, this feature is essential. Follow these four steps to use it:

  1. Implement StateRepositoryInterface.
    You may use any existing implementation (they will be implemented later).
  2. Save user/chat state using the repository:

  3. Add StateMiddleware before the router middleware.
    This allows you to access the current state within your router actions.

    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.

  4. 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

PHP Build Version
Package Version
Requires php Version ^8.2
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
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package viktorprogger/telegram-bot contains the following files

Loading the files please wait ....