Skip to content

Commit 25c9164

Browse files
authored
Rename project to TelegramUrlParser and enhance README
Updated README to reflect new project name and features.
1 parent 4b5b8d7 commit 25c9164

File tree

1 file changed

+174
-26
lines changed

1 file changed

+174
-26
lines changed

README.md

Lines changed: 174 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,185 @@
1-
# filterURL-GetAnyMessage
1+
# TelegramUrlParser
22

3-
## Description
4-
filter the chat type by telegram url with custom filters!
3+
A lightweight and powerful PHP library for parsing Telegram message
4+
URLs.\
5+
Created by **@WizardLoop**.
56

6-
Function to filter the chat type by telegram url with custom filters: (b/u)
7-
_For all supported formats, go to the examples folder._
7+
[![Packagist
8+
Version](https://img.shields.io/packagist/v/wizardloop/telegram-url-parser)](https://packagist.org/packages/wizardloop/telegram-url-parser)
9+
![PHP Version](https://img.shields.io/badge/PHP-7.4%2B-blue)
10+
![License](https://img.shields.io/badge/license-MIT-green)
11+
![Status](https://img.shields.io/badge/status-stable-success)
812

9-
all type of chats: ```channel/group/user/bot || public/private || channel comment & topics groups```
13+
TelegramUrlParser extracts chat type, IDs, usernames, and message
14+
identifiers from any Telegram URL.\
15+
Supports public, private, bot, user, and topic-based chats.
1016

11-
( From my project: @GetAnyMessageRobot )
17+
------------------------------------------------------------------------
1218

13-
_[You can check our bot here](https://t.me/GetAnyMessageRobot)._
19+
## 📚 Table of Contents
1420

15-
[*Written by PHPwiz ( php-wiz )](https://github.com/php-wiz)
21+
- [Features](#features)
22+
- [Installation](#installation)
23+
- [Usage](#usage)
24+
- [Returned Structure](#returned-structure)
25+
- [Supported URL Formats](#supported-url-formats)
26+
- [Logic Helper](#logic-helper)
27+
- [Project Structure](#project-structure)
28+
- [Author](#author)
29+
- [License](#license)
1630

17-
## explanation
18-
**url paths:**
19-
```php
20-
$out1 = $result1['out1'] ?? null; // PATH URL 1
21-
$out2 = $result1['out2'] ?? null; // PATH URL 2
22-
$out3 = $result1['out3'] ?? null; // PATH URL 3
23-
$out4 = $result1['out4'] ?? null; // PATH URL 4
24-
$out5 = $result1['out5'] ?? null; // PATH URL 5
31+
------------------------------------------------------------------------
32+
33+
## ✨ Features
34+
35+
- Validates Telegram URLs
36+
37+
- Parses any `t.me` and Telegram link
38+
39+
- Extracts:
40+
41+
- Username
42+
- Chat ID
43+
- Message ID
44+
- User/Bot identifier
45+
46+
- Supports:\
47+
✔ Public chats\
48+
✔ Private groups/channels\
49+
✔ Bots\
50+
✔ Users\
51+
✔ Topic chats
52+
53+
- Zero dependencies\
54+
55+
- Clean static API
56+
57+
------------------------------------------------------------------------
58+
59+
## 🛠 Installation
60+
61+
### Composer
62+
63+
composer require wizardloop/telegram-url-parser
64+
65+
Or manually in `composer.json`:
66+
67+
``` json
68+
{
69+
"require": {
70+
"wizardloop/telegram-url-parser": "^1.0"
71+
}
72+
}
2573
```
2674

27-
**info:**
28-
```php
29-
PATH URL 1 ($out1):
30-
if path is c/C = private chat(group/channel).
31-
if path is u/U = user chat.
32-
if path is b/B = chat bot.
33-
else = (username) so its public channel/group.
75+
------------------------------------------------------------------------
76+
77+
## 🚀 Usage Example
78+
79+
``` php
80+
<?php
81+
82+
use Wizardloop\TelegramUrlParser\FilterURL;
83+
84+
$check = FilterURL::checkUrl("https://t.me/username/123");
3485

35-
*checks if path does not start with + to filter out invitation links.
36-
*Check only on Telegram links.
86+
if (isset($check['error'])) {
87+
die("Error: " . $check['error']);
88+
}
89+
90+
print_r($check);
3791
```
92+
93+
------------------------------------------------------------------------
94+
95+
## 📦 Returned Structure
96+
97+
`FilterURL::checkUrl()` returns:
98+
99+
``` php
100+
[
101+
'out1' => string|null,
102+
'out2' => string|null,
103+
'out3' => string|null,
104+
'out4' => string|null,
105+
'out5' => string|null
106+
]
107+
```
108+
109+
Meaning: - **out1** --- Username / c / u / b\
110+
- **out2** --- Chat ID / Username / Message ID\
111+
- **out3** --- Message ID\
112+
- **out4** --- Extra (private groups)\
113+
- **out5** --- Extra (invalid if exists)
114+
115+
If invalid:
116+
117+
``` php
118+
['error' => 'invalid url!']
119+
```
120+
121+
------------------------------------------------------------------------
122+
123+
## 🔗 Supported URL Formats
124+
125+
Type Example
126+
--------------------- --------------------------------
127+
Public channel post `https://t.me/username/123`
128+
Private channel `https://t.me/c/123456/78`
129+
Public group `https://t.me/groupname/55`
130+
Private group `https://t.me/c/777/99`
131+
Bot message `https://t.me/b/botname/44`
132+
User (username) `https://t.me/u/wizardloop/12`
133+
User (ID) `https://t.me/u/123456789/34`
134+
Topic chats `https://t.me/groupname/22222`
135+
136+
------------------------------------------------------------------------
137+
138+
## 🧠 Logic Helper
139+
140+
``` php
141+
if (!preg_match('/^\+/', $out1)) {
142+
143+
if ($out1 === 'c') {
144+
// Private channel/group
145+
$chatId = $out2;
146+
$msgId = $out3;
147+
}
148+
elseif ($out1 === 'b') {
149+
// Bot
150+
$botUsername = $out2;
151+
$msgId = $out3;
152+
}
153+
elseif ($out1 === 'u') {
154+
// User
155+
$userIdOrUsername = $out2;
156+
$msgId = $out3;
157+
}
158+
else {
159+
// Public channel/group
160+
$username = $out1;
161+
$msgId = $out2;
162+
}
163+
}
164+
```
165+
166+
------------------------------------------------------------------------
167+
168+
## 📁 Project Structure
169+
170+
src/
171+
└── FilterURL.php
172+
composer.json
173+
README.md
174+
175+
------------------------------------------------------------------------
176+
177+
## 👤 Author
178+
179+
**WizardLoop (@wizardloop)**
180+
181+
------------------------------------------------------------------------
182+
183+
## 📄 License
184+
185+
MIT License

0 commit comments

Comments
 (0)