From c294a652a329c15a7fb004e8b534b124225e7b8f Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 28 Feb 2021 13:20:44 +0000 Subject: [PATCH] [TelegramBridge] Add detectParameters() (#1998) --- bridges/TelegramBridge.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bridges/TelegramBridge.php b/bridges/TelegramBridge.php index a7296b8a..152e2da0 100644 --- a/bridges/TelegramBridge.php +++ b/bridges/TelegramBridge.php @@ -21,6 +21,18 @@ class TelegramBridge extends BridgeAbstract { private $itemTitle = ''; private $backgroundImageRegex = "/background-image:url\('(.*)'\)/"; + private $detectParamsRegex = '/^https?:\/\/t.me\/(?:s\/)?([\w]+)$/'; + + public function detectParameters($url) { + $params = array(); + + if(preg_match($this->detectParamsRegex, $url, $matches) > 0) { + $params['username'] = $matches[1]; + return $params; + } + + return null; + } public function collectData() {