wizardloop/telegramurlparser
Composer 安装命令:
composer require wizardloop/telegramurlparser
包简介
Powerful and simple Telegram URL parser
README 文档
README
A lightweight and powerful PHP library for parsing Telegram message
URLs.
Created by @WizardLoop.
TelegramUrlParser extracts chat type, IDs, usernames, and message
identifiers from any Telegram URL.
Supports public, private, bot, user, and topic-based chats.
✨ Features
-
Validates Telegram URLs
-
Parses any
t.meand Telegram link -
Extracts:
- Username
- Chat ID
- Message ID
- User/Bot identifier
-
Supports:
✔ Public chats
✔ Private groups/channels
✔ Bots
✔ Users
✔ Topic chats -
Zero dependencies
-
Clean static API
🛠 Installation
Composer
composer require wizardloop/telegramurlparser
Or manually in composer.json:
{
"require": {
"wizardloop/telegramurlparser": "^1.0"
}
}
🚀 Usage Example
<?php use Wizardloop\TelegramUrlParser\FilterURL; $check = FilterURL::checkUrl("https://t.me/username/123"); if (isset($check['error'])) { die("Error: " . $check['error']); } print_r($check);
📦 Returned Structure
FilterURL::checkUrl() returns:
[
'out1' => string|null,
'out2' => string|null,
'out3' => string|null,
'out4' => string|null,
'out5' => string|null
]
Meaning: - out1 --- Username / c / u / b\
- out2 --- Chat ID / Username / Message ID\
- out3 --- Message ID\
- out4 --- Extra (private groups)\
- out5 --- Extra (invalid if exists)
If invalid:
['error' => 'invalid url!']
🔗 Supported URL Formats
Type Example
Public channel post https://t.me/username/123
Private channel https://t.me/c/123456/78
Public group https://t.me/groupname/55
Private group https://t.me/c/777/99
Bot message https://t.me/b/botname/44
User (username) https://t.me/u/wizardloop/12
User (ID) https://t.me/u/123456789/34
Topic chats https://t.me/groupname/22222
🧠 Logic Helper
if (!preg_match('/^\+/', $out1)) { if ($out1 === 'c') { // Private channel/group $chatId = $out2; $msgId = $out3; } elseif ($out1 === 'b') { // Bot $botUsername = $out2; $msgId = $out3; } elseif ($out1 === 'u') { // User $userIdOrUsername = $out2; $msgId = $out3; } else { // Public channel/group $username = $out1; $msgId = $out2; } }
📁 Project Structure
src/
└── FilterURL.php
composer.json
README.md
👤 Author
WizardLoop (@wizardloop)
📄 License
MIT License
wizardloop/telegramurlparser 适用场景与选型建议
wizardloop/telegramurlparser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wizardloop/telegramurlparser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wizardloop/telegramurlparser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-16