[TelegramBridge] Support new username URL format (#3257)

* [TelegramBridge] Support new username URL format

* [TelegramBridge] Fix text error
This commit is contained in:
Joseph 2023-02-13 21:19:41 +00:00 committed by GitHub
parent 06a4bc4b45
commit 67f72bfa5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -22,6 +22,8 @@ class TelegramBridge extends BridgeAbstract
'https://telegram.me/s/rssbridge' => ['username' => 'rssbridge'],
'https://telegram.me/rssbridge' => ['username' => 'rssbridge'],
'http://telegram.me/rssbridge' => ['username' => 'rssbridge'],
'http://rssbridge.t.me/' => ['username' => 'rssbridge'],
'https://rssbridge.t.me/' => ['username' => 'rssbridge'],
];
const CACHE_TIMEOUT = 60 * 15; // 15 mins
@ -360,10 +362,17 @@ EOD;
public function detectParameters($url)
{
$detectParamsRegex = '/^https?:\/\/(?:t|telegram)\.me\/(?:s\/)?([\w]+)$/';
$detectParamsRegex = '/^https?:\/\/(?:(?:t|telegram)\.me\/(?:s\/)?([\w]+)|([\w]+)\.t\.me\/?)$/';
$params = [];
if (preg_match($detectParamsRegex, $url, $matches) > 0) {
$params['username'] = $matches[1];
if ($matches[1] !== '') {
$params['username'] = $matches[1];
}
if (isset($matches[2]) && $matches[2] !== '') {
$params['username'] = $matches[2];
}
return $params;
}
return null;