[TelegramBridge] Add detectParameters() (#1998)

This commit is contained in:
Joseph 2021-02-28 13:20:44 +00:00 committed by GitHub
parent a5f2175531
commit c294a652a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,18 @@ class TelegramBridge extends BridgeAbstract {
private $itemTitle = ''; private $itemTitle = '';
private $backgroundImageRegex = "/background-image:url\('(.*)'\)/"; 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() { public function collectData() {