Download the PHP package gusaln/simple-tg-bot-api without Composer

On this page you can find all versions of the php package gusaln/simple-tg-bot-api. 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 simple-tg-bot-api

Simple Telegram Bot Api [WIP]

Telegram bot api Latest Version on Packagist

Minimalist strongly-typed Telegram Bot API.

This package is heavily inspired by tg-bot-api/bot-api-base.

BEWARE: This package is still in alpha.

Read the testing section before using this package.

What does this package provide?

What does this package NOT provide?

A framework for dealing with commands, inline queries or follow conversations. Those are for you to implement.

Supported Telegram Bot API

Supports Telegram Bot API 6.0 (April 16, 2022)

Installation

Via Composer

Usage

You need to instantiate the BotApi class which provides all the methods of the Telegram Bot API.

All the API methods have a corresponding method in the BotApi class, and that method takes in a MethodRequest object that takes all the arguments of said method.

This way you are prevented from mistyping any parameters or messing up their types.

WARNING: Methods like editMessageText can take a chat_id and a message_id for regular messages, or a inline_message_id for inline messages, but not the three at the same time. Currently, this package does not provide a safeguard against this invalid state, but it may in the future. For now, always read the constructor descriptions.

For more examples, check the examples folder.

Types

All the types from the Telegram Bot API, like Update, Message, and the like, are provided as clases in the GusALN\TelegramBotApi\Types\ namespace. They implement JsonSerializable and have a static fromPayload(array $payload): self that allows you to deserialize them.

The fromPayload method of abstract types, like MenuButton which has the child types MenuButtonCommands, MenuButtonWebApp, and MenuButtonDefault, return an instance of the specific child type where possible. Most abstract types have a property which's value specifies its subtype. Following with the MethodButton family of types, the property type can be either:

This values are provided as constants in all abstract types:

The first exception to this pattern is the InputMessageContent family of types which do not have a specific property-value pair that defines then, and other methods are used to identified them.

The other one is the type MessageEntity, that despite not being part of a family, has their type string specified in constants.

Enums

Enum classes are provided for certain magic string. There are two at the moment: GusALN\TelegramBotApi\Enums\ParseMode::* and GusALN\TelegramBotApi\Enums\ChatAction::*.

You can specify the parse_mode parameter for the messages using the ParseMode::* constants.

Fetching updates from a webhook

The WebhookUpdateFetcher can parse an update from either a Psr\Http\Message\RequestInterface or a string.

Polling updates

Check an example inside the examples/get_updates_polling.php.

What can I expect to change as the package matures?

A better API, which would include:

  1. Factory methods inside some requests. For example, the editMessageText could take a chat_id and a message_id for regular messages, or a inline_message_id for inline messages.

  2. General methods on the BotApi for common tasks. For example, having a send method that accepts all the requests that send something (sendMessage, sendPhoto, sendAudio, etc.).

Testing

I don’t always test my code, but when I do, I test in production.

In all seriousness, expect test to manifest after I play around with the API enough to have a clear idea of shape I want it to have. I have done some crude practical testing on a selection of all the methods to verify that they indeed work.

For the first beta release (0.1.0), there will be tests.

Change log

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


All versions of simple-tg-bot-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
guzzlehttp/guzzle Version ^6.0|^7.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 gusaln/simple-tg-bot-api contains the following files

Loading the files please wait ....