{"id":16511163,"url":"https://github.com/danog/tg-dialog-id","last_synced_at":"2025-07-03T23:33:00.582Z","repository":{"id":239166786,"uuid":"798757779","full_name":"danog/tg-dialog-id","owner":"danog","description":"A library to work with Telegram bot API dialog IDs.","archived":false,"fork":false,"pushed_at":"2025-06-28T15:40:43.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T16:16:10.382Z","etag":null,"topics":["bot-api","telegram","telegram-bot","telegram-bot-api","telegram-id"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"danog"}},"created_at":"2024-05-10T12:08:08.000Z","updated_at":"2025-06-28T15:36:29.000Z","dependencies_parsed_at":"2025-06-04T22:09:32.550Z","dependency_job_id":"c23644bc-c54b-4cb6-8212-83c1e97bb678","html_url":"https://github.com/danog/tg-dialog-id","commit_stats":null,"previous_names":["danog/tg-dialog-id"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/danog/tg-dialog-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Ftg-dialog-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Ftg-dialog-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Ftg-dialog-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Ftg-dialog-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danog","download_url":"https://codeload.github.com/danog/tg-dialog-id/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Ftg-dialog-id/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421454,"owners_count":23464012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot-api","telegram","telegram-bot","telegram-bot-api","telegram-id"],"created_at":"2024-10-11T15:59:12.373Z","updated_at":"2025-07-03T23:33:00.499Z","avatar_url":"https://github.com/danog.png","language":"PHP","funding_links":["https://github.com/sponsors/danog"],"categories":[],"sub_categories":[],"readme":"# tg-dialog-id\n\n[![codecov](https://codecov.io/gh/danog/tg-dialog-id/branch/master/graph/badge.svg)](https://codecov.io/gh/danog/tg-dialog-id)\n[![Psalm coverage](https://shepherd.dev/github/danog/tg-dialog-id/coverage.svg)](https://shepherd.dev/github/danog/tg-dialog-id)\n[![Psalm level 1](https://shepherd.dev/github/danog/tg-dialog-id/level.svg)](https://shepherd.dev/github/danog/tg-dialog-id)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fdanog%2Ftg-dialog-id%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/danog/tg-dialog-id/master)\n![License](https://img.shields.io/github/license/danog/tg-dialog-id)\n\nA library to work with Telegram bot API dialog IDs.  \n\nCreated by Daniil Gentili (https://daniil.it).  \n\nThis library was initially created for [MadelineProto](https://docs.madelineproto.xyz), an async PHP client API for the telegram MTProto protocol.  \n\n## Installation\n\n```bash\ncomposer require danog/tg-dialog-id\n```\n\n## Usage\n\n```php\n\u003c?php declare(strict_types=1);\n\nuse danog\\DialogId\\DialogId;\n\nrequire 'vendor/autoload.php';\n\nfunction expect(bool $expect): void\n{\n    if (!$expect) {\n        throw new AssertionError(\"Not verified!\");\n    }\n}\n\n$link = \"https://t.me/c/1234567890/8892\";\nif (preg_match(\"|t.me/c/(\\d+)/(\\d+)|\", $link, $matches)) {\n    // Returns -1001234567890\n    echo DialogId::fromSupergroupOrChannelId((int) $matches[1]).PHP_EOL;\n}\n\n// Converts an MTProto supergroup/channel ID =\u003e bot API dialog ID\nexpect(DialogId::fromSupergroupOrChannelId(1234567890) === -1001234567890);\n\n// Converts an MTProto chat ID =\u003e bot API dialog ID\nexpect(DialogId::fromChatId(123456789) === -123456789);\n\n// Converts an MTProto user ID =\u003e bot API dialog ID\nexpect(DialogId::fromUserId(123456789) === 123456789);\n\n// Converts an MTProto secret chat ID =\u003e bot API dialog ID\nexpect(DialogId::fromSecretChatId(123456789) === -1999876543211);\n\n// Converts a bot API dialog ID =\u003e MTProto supergroup/channel ID\nexpect(DialogId::toSupergroupOrChannelId(-1001234567890) === 1234567890);\n\n// Converts a bot API dialog ID =\u003e MTProto chat ID\nexpect(DialogId::toChatId(-123456789) === 123456789);\n\n// Converts a bot API dialog ID =\u003e MTProto user ID\nexpect(DialogId::toUserId(123456789) === 123456789);\n\n// Converts a bot API dialog ID =\u003e MTProto secret chat ID\nexpect(DialogId::toSecretChatId(-1999876543211) === 123456789);\n\nexpect(DialogId::getType(101374607) === DialogId::USER);\nexpect(DialogId::getType(-123456789) === DialogId::CHAT);\nexpect(DialogId::getType(-1001234567890) === DialogId::CHANNEL_OR_SUPERGROUP);\nexpect(DialogId::getType(-1999898625393) === DialogId::SECRET_CHAT);\n\nexpect(DialogId::isUser(1099511627775) === true);\nexpect(DialogId::isChat(-999_999_999_999) === true);\nexpect(DialogId::isSupergroupOrChannel(-1997852516352) === true);\nexpect(DialogId::isSecretChat(-2002147483648) === true);\n\nexpect(DialogId::isUser(101374607) === true);\nexpect(DialogId::isChat(-101374607) === true);\nexpect(DialogId::isSupergroupOrChannel(-1001234567890) === true);\nexpect(DialogId::isSecretChat(-1999898625393) === true);\n\n// Converts a bot API dialog ID =\u003e MTProto ID automatically depending on type\nexpect(DialogId::toMTProtoId(-1001234567890) === 1234567890);\nexpect(DialogId::toMTProtoId(-123456789) === 123456789);\nexpect(DialogId::toMTProtoId(123456789) === 123456789);\nexpect(DialogId::toMTProtoId(-1999876543211) === 123456789);\n\necho \"OK!\".PHP_EOL;\n```\n\n## API Documentation\n\nClick [here \u0026raquo;](https://github.com/danog/tg-dialog-id/blob/master/docs/index.md) to view the API documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Ftg-dialog-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanog%2Ftg-dialog-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Ftg-dialog-id/lists"}