1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-02 18:47:52 +01:00

Support username.t.me links
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
Daniil Gentili 2022-09-26 15:33:27 +02:00
parent 5572c2dbe1
commit 1f661441bf
2 changed files with 9 additions and 6 deletions

View File

@ -111,8 +111,6 @@ abstract class MsgIdHandler
*/ */
public static function toString(string $messageId): string public static function toString(string $messageId): string
{ {
return PHP_INT_SIZE === 8 return MsgIdHandler64::toStringInternal($messageId);
? MsgIdHandler64::toStringInternal($messageId)
: MsgIdHandler32::toStringInternal($messageId);
} }
} }

View File

@ -1014,9 +1014,14 @@ abstract class Tools extends StrTools
*/ */
public static function parseLink(string $link): ?array public static function parseLink(string $link): ?array
{ {
if (!\preg_match('@(?:t|telegram)\\.(?:me|dog)/(joinchat/|\+)?([a-z0-9_-]*)@i', $link, $matches)) { if (\preg_match('@([a-z0-9_-]*)\\.(?:t|telegram)\.(?:me|dog)@', $link, $matches)) {
return null; if ($link !== 'www') {
return [false, $matches[1]];
} }
}
if (\preg_match('@(?:t|telegram)\\.(?:me|dog)/(joinchat/|\+)?([a-z0-9_-]*)@i', $link, $matches)) {
return [!!$matches[1], $matches[2]]; return [!!$matches[1], $matches[2]];
} }
return null;
}
} }