Go to file
2024-05-09 23:51:45 +02:00
.github Test on all versions 2024-05-09 23:48:46 +02:00
docs First commit 2024-05-09 23:46:12 +02:00
examples First commit 2024-05-09 23:46:12 +02:00
src First commit 2024-05-09 23:46:12 +02:00
test First commit 2024-05-09 23:46:12 +02:00
.gitignore Add infection config 2024-05-09 23:48:46 +02:00
.php-cs-fixer.dist.php First commit 2024-05-09 23:46:12 +02:00
composer.json Relax versions 2024-05-09 23:49:40 +02:00
infection.json5 Add infection config 2024-05-09 23:48:46 +02:00
LICENSE First commit 2024-05-09 23:46:12 +02:00
NOTICE Bump notice 2024-05-09 23:51:45 +02:00
phpunit.xml Fix phpunit config 2024-05-09 23:50:42 +02:00
psalm.xml First commit 2024-05-09 23:46:12 +02:00
README.md First commit 2024-05-09 23:46:12 +02:00

tgbot-dialog-id

codecov Psalm coverage Psalm level 1 License

A library to work with Telegram bot API dialog IDs.

Created by Daniil Gentili (https://daniil.it).

This library was initially created for MadelineProto, an async PHP client API for the telegram MTProto protocol.

Installation

composer require danog/tgbot-dialog-id

Usage

<?php declare(strict_types=1);

use danog\DialogId\DialogType;

require 'vendor/autoload.php';

function expect(bool $expect): void
{
    if (!$expect) {
        throw new AssertionError("Not verified!");
    }
}

expect(DialogType::from(101374607) === DialogType::USER);
expect(DialogType::from(-123456789) === DialogType::CHAT);
expect(DialogType::from(-1001234567890) === DialogType::CHANNEL_OR_SUPERGROUP);
expect(DialogType::from(-1999898625393) === DialogType::SECRET_CHAT);

expect(DialogType::isUser(1099511627775) === true);
expect(DialogType::isChat(-999_999_999_999) === true);
expect(DialogType::isSupergroupOrChannel(-1997852516352) === true);
expect(DialogType::isSecretChat(-2002147483648) === true);

expect(DialogType::isUser(101374607) === true);
expect(DialogType::isChat(-101374607) === true);
expect(DialogType::isSupergroupOrChannel(-1001234567890) === true);
expect(DialogType::isSecretChat(-1999898625393) === true);

echo "OK!".PHP_EOL;

API Documentation

Click here » to view the API documentation.