Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DeepLink Support Class #690

Merged
merged 2 commits into from
Apr 9, 2024
Merged

Add DeepLink Support Class #690

merged 2 commits into from
Apr 9, 2024

Conversation

Lukasss93
Copy link
Member

@Lukasss93 Lukasss93 commented Apr 9, 2024

This PR introduces the DeepLink class, a utility class designed to generate various types of Telegram deep links. The class supports a wide range of deep link types as defined in the Telegram API documentation.

$deepLink = new DeepLink();

// Create a deep link to a public username
$link = $deepLink->username('john_doe');
echo $link; // Outputs: https://t.me/john_doe

// Create a deep link to a temporary profile
$link = $deepLink->contact('temp_token');
echo $link; // Outputs: https://t.me/contact/temp_token

// Create a deep link to a phone number
$link = $deepLink->phone(1, 1234567890);
echo $link; // Outputs: https://t.me/+11234567890

// Create a deep link to a chat invite
$link = $deepLink->joinChat('invite_hash');
echo $link; // Outputs: https://t.me/+invite_hash

// Create a deep link to a bot start parameter
$link = $deepLink->start('my_bot', 'start_param');
echo $link; // Outputs: https://t.me/my_bot?start=start_param

// Create a deep link to add a bot to a group
$link = $deepLink->startGroup('my_bot', 'start_param', ['change_info', 'post_messages']);
echo $link; // Outputs: https://t.me/my_bot?startgroup=start_param&admin=change_info+post_messages

// Create a deep link to a game
$link = $deepLink->game('game_bot', 'game_short_name');
echo $link; // Outputs: https://t.me/game_bot?game=game_short_name

// Create a deep link to login
$link = $deepLink->login('login_code');
echo $link; // Outputs: https://t.me/login/login_code

// Create a deep link to an invoice
$link = $deepLink->invoice('invoice_slug');
echo $link; // Outputs: https://t.me/invoice/invoice_slug

// Create a deep link to set language
$link = $deepLink->setLanguage('en');
echo $link; // Outputs: https://t.me/setlanguage/en

// Create a deep link to confirm phone
$link = $deepLink->confirmPhone('1234567890', 'hash_value');
echo $link; // Outputs: https://t.me/confirmphone?phone=1234567890&hash=hash_value

// Create a deep link to a gift code
$link = $deepLink->giftCode('gift_code');
echo $link; // Outputs: https://t.me/giftcode/gift_code

// Create a deep link to start an app
$link = $deepLink->startApp('app_bot', 'start_param');
echo $link; // Outputs: https://t.me/app_bot?startapp=start_param

// Create a deep link to attach a bot to a specific chat
$link = $deepLink->attach('john_doe', 'bot_username', 'start_param');
echo $link; // Outputs: https://t.me/john_doe?attach=bot_username&startattach=start_param

@Lukasss93 Lukasss93 added the enhancement New feature or request label Apr 9, 2024
@Lukasss93 Lukasss93 self-assigned this Apr 9, 2024
@Lukasss93 Lukasss93 requested a review from sergix44 as a code owner April 9, 2024 21:32
src/Support/DeepLink.php Show resolved Hide resolved
src/Support/DeepLink.php Show resolved Hide resolved
src/Support/DeepLink.php Show resolved Hide resolved
src/Support/DeepLink.php Show resolved Hide resolved
src/Support/DeepLink.php Show resolved Hide resolved
Copy link

codeclimate bot commented Apr 9, 2024

Code Climate has analyzed commit e26f0aa and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 6

The test coverage on the diff in this pull request is 100.0% (60% is the threshold).

This pull request will bring the total coverage in the repository to 96.7% (0.2% change).

View more on Code Climate.

@Lukasss93 Lukasss93 merged commit d439d95 into master Apr 9, 2024
8 checks passed
@Lukasss93 Lukasss93 deleted the deep-linking branch April 9, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants