diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8938dc6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+prefs.php
+vendor
diff --git a/README.md b/README.md
index 6fd3bcb..7f014dc 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,20 @@
-discord_webhook
+Post to Telegram
===============
-This plugin adds a [filter action](https://git.tt-rss.org/fox/tt-rss/wiki/ContentFilters) that sends new articles to a [webhook](https://support.discordapp.com/hc/en-us/articles/228383668) for a Discord server channel.
+This plugin adds a [filter action](https://git.tt-rss.org/fox/tt-rss/wiki/ContentFilters) that sends new articles to a Telegram channel.
Installation
------------
-Clone this repository into your `plugins.local` directory in your TT-RSS installation. Ensure the plugin directory is named EXACTLY `discord_webhook`, otherwise it won't work.
+Clone this repository into your `plugins.local` directory in your TT-RSS installation. Ensure the plugin directory is named EXACTLY `post_to_telegram`, otherwise it won't work.
Configuration
-------------
-Once you have enabled the plugin a new section called *Discord Webhook* should be available in the Preferences tab in your TT-RSS settings where you can enter a webhook URL.
+Once you have enabled the plugin a new section called *Post to Telegram* should be available in the Preferences tab in your TT-RSS settings where you can enter a webhook URL.
A new filter action should also be available. Select *Invoke plugin* as the filter action then *Discord_Webhook: Send to Discord*.
+
+Credits
+-------
+Based on "Discord Webhook" plugin by Roliga
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..72837e3
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,5 @@
+{
+ "require": {
+ "longman/telegram-bot": "^0.75.0"
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..fd21bb2
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,764 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "d8d5af0d90f9e8d12828b2dde7141af5",
+ "packages": [
+ {
+ "name": "guzzlehttp/guzzle",
+ "version": "7.4.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/guzzle.git",
+ "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
+ "reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "guzzlehttp/promises": "^1.5",
+ "guzzlehttp/psr7": "^1.8.3 || ^2.1",
+ "php": "^7.2.5 || ^8.0",
+ "psr/http-client": "^1.0",
+ "symfony/deprecation-contracts": "^2.2 || ^3.0"
+ },
+ "provide": {
+ "psr/http-client-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.4.1",
+ "ext-curl": "*",
+ "php-http/client-integration-tests": "^3.0",
+ "phpunit/phpunit": "^8.5.5 || ^9.3.5",
+ "psr/log": "^1.1 || ^2.0 || ^3.0"
+ },
+ "suggest": {
+ "ext-curl": "Required for CURL handler support",
+ "ext-intl": "Required for Internationalized Domain Name (IDN) support",
+ "psr/log": "Required for using the Log middleware"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "7.4-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "GuzzleHttp\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Jeremy Lindblom",
+ "email": "jeremeamia@gmail.com",
+ "homepage": "https://github.com/jeremeamia"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle is a PHP HTTP client library",
+ "keywords": [
+ "client",
+ "curl",
+ "framework",
+ "http",
+ "http client",
+ "psr-18",
+ "psr-7",
+ "rest",
+ "web service"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/guzzle/issues",
+ "source": "https://github.com/guzzle/guzzle/tree/7.4.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-12-06T18:43:05+00:00"
+ },
+ {
+ "name": "guzzlehttp/promises",
+ "version": "1.5.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.5"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^4.4 || ^5.1"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "GuzzleHttp\\Promise\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle promises library",
+ "keywords": [
+ "promise"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/promises/issues",
+ "source": "https://github.com/guzzle/promises/tree/1.5.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-22T20:56:57+00:00"
+ },
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "2.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
+ "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0",
+ "psr/http-factory": "^1.0",
+ "psr/http-message": "^1.0",
+ "ralouphie/getallheaders": "^3.0"
+ },
+ "provide": {
+ "psr/http-factory-implementation": "1.0",
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.4.1",
+ "http-interop/http-factory-tests": "^0.9",
+ "phpunit/phpunit": "^8.5.8 || ^9.3.10"
+ },
+ "suggest": {
+ "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://sagikazarmark.hu"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/psr7/issues",
+ "source": "https://github.com/guzzle/psr7/tree/2.1.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-10-06T17:43:30+00:00"
+ },
+ {
+ "name": "longman/telegram-bot",
+ "version": "0.75.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-telegram-bot/core.git",
+ "reference": "13879c499af126d9211751597fd2aaf7a1bcb094"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-telegram-bot/core/zipball/13879c499af126d9211751597fd2aaf7a1bcb094",
+ "reference": "13879c499af126d9211751597fd2aaf7a1bcb094",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-mbstring": "*",
+ "ext-pdo": "*",
+ "guzzlehttp/guzzle": "^6.0|^7.0",
+ "php": "^7.3|^8.0",
+ "psr/log": "^1.1"
+ },
+ "require-dev": {
+ "dms/phpunit-arraysubset-asserts": "^0.2",
+ "monolog/monolog": "^2.1",
+ "phpunit/phpunit": "^9.5",
+ "squizlabs/php_codesniffer": "^3.5"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Longman\\TelegramBot\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Avtandil Kikabidze aka LONGMAN",
+ "email": "akalongman@gmail.com",
+ "homepage": "http://longman.me",
+ "role": "Developer"
+ },
+ {
+ "name": "Armando Lüscher",
+ "email": "armando@noplanman.ch",
+ "homepage": "https://noplanman.ch",
+ "role": "Developer"
+ },
+ {
+ "name": "PHP Telegram Bot Team",
+ "homepage": "https://github.com/php-telegram-bot/core/graphs/contributors",
+ "role": "Developer"
+ }
+ ],
+ "description": "PHP Telegram bot",
+ "homepage": "https://github.com/php-telegram-bot/core",
+ "keywords": [
+ "api",
+ "bot",
+ "telegram"
+ ],
+ "support": {
+ "issues": "https://github.com/php-telegram-bot/core/issues",
+ "source": "https://github.com/php-telegram-bot/core"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/php-telegram-bot/core#donate",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/noplanman",
+ "type": "github"
+ },
+ {
+ "url": "https://ko-fi.com/phptelegrambot",
+ "type": "ko_fi"
+ },
+ {
+ "url": "https://liberapay.com/PHP-Telegram-Bot",
+ "type": "liberapay"
+ },
+ {
+ "url": "https://opencollective.com/php-telegram-bot",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://www.patreon.com/phptelegrambot",
+ "type": "patreon"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/longman/telegram-bot",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-12-29T05:36:01+00:00"
+ },
+ {
+ "name": "psr/http-client",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-client.git",
+ "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+ "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0 || ^8.0",
+ "psr/http-message": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Client\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP clients",
+ "homepage": "https://github.com/php-fig/http-client",
+ "keywords": [
+ "http",
+ "http-client",
+ "psr",
+ "psr-18"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-client/tree/master"
+ },
+ "time": "2020-06-29T06:28:15+00:00"
+ },
+ {
+ "name": "psr/http-factory",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-factory.git",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0.0",
+ "psr/http-message": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interfaces for PSR-7 HTTP message factories",
+ "keywords": [
+ "factory",
+ "http",
+ "message",
+ "psr",
+ "psr-17",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory/tree/master"
+ },
+ "time": "2019-04-30T12:38:16+00:00"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/master"
+ },
+ "time": "2016-08-06T14:39:51+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "1.1.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
+ "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "Psr/Log/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/1.1.4"
+ },
+ "time": "2021-05-03T11:20:27+00:00"
+ },
+ {
+ "name": "ralouphie/getallheaders",
+ "version": "3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ralouphie/getallheaders.git",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/getallheaders.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ralph Khattar",
+ "email": "ralph.khattar@gmail.com"
+ }
+ ],
+ "description": "A polyfill for getallheaders.",
+ "support": {
+ "issues": "https://github.com/ralouphie/getallheaders/issues",
+ "source": "https://github.com/ralouphie/getallheaders/tree/develop"
+ },
+ "time": "2019-03-08T08:55:37+00:00"
+ },
+ {
+ "name": "symfony/deprecation-contracts",
+ "version": "v3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/deprecation-contracts.git",
+ "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
+ "reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.0-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "files": [
+ "function.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A generic function and convention to trigger deprecation notices",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2021-11-01T23:48:49+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": [],
+ "plugin-api-version": "2.0.0"
+}
diff --git a/init.php b/init.php
index 5d4ab6f..c1106f9 100644
--- a/init.php
+++ b/init.php
@@ -1,13 +1,14 @@
add_hook($host::HOOK_ARTICLE_FILTER_ACTION, $this);
$host->add_hook($host::HOOK_FILTER_TRIGGERED, $this);
- $host->add_hook($host::HOOK_PREFS_TAB, $this);
- $host->add_filter_action($this, "action_discord", "Send to Discord");
+ $host->add_filter_action($this, "action_telegram", "Send to Telegram");
}
function flags() {
@@ -33,19 +33,14 @@ class Discord_Webhook extends Plugin {
if ($action["type"] === "filter") {
$delete = true;
}
- if ($delete && $action["param"] === "Discord_Webhook:action_discord") {
+ if ($delete && $action["param"] === "Post_To_Telegram:action_telegram") {
unset($article_filters[$action_key]);
}
}
}
- function validate_webhook_url($webhook_url) {
- return (filter_var($webhook_url, FILTER_VALIDATE_URL)
- && strpos($webhook_url, $this->discord_api_url) === 0);
- }
-
function hook_article_filter_action($article, $action) {
- if ($action == "action_discord") {
+ if ($action == "action_telegram") {
if (!function_exists("curl_init"))
return $article;
@@ -54,82 +49,29 @@ class Discord_Webhook extends Plugin {
WHERE guid = ? OR guid = ?");
$csth->execute([$article['guid'], $article['guid_hashed']]);
if ($row = $csth->fetch()) {
- Debug::log("Article already in database, not triggering webhook..", Debug::$LOG_VERBOSE);
+ Debug::log("Article already in database, not triggering telegram..", Debug::$LOG_VERBOSE);
return $article;
}
- $webhook_url = $this->host->get($this, 'webhook_url');
- if (!$this->validate_webhook_url($webhook_url)) {
- Debug::log("Invalid Discord webhook URL, not triggering webhook..", Debug::$LOG_VERBOSE);
- return $article;
- }
+ $content = '### '.$article["title"] . "\n" . $article["link"] . "\n" . $article['content'];
- $payload = array();
- $payload["content"] = $article["title"] . " " . $article["link"];
+ $telegram = new Longman\TelegramBot\Telegram(
+ TELEGRAM_API_KEY,
+ TELEGRAM_BOT_NAME
+ );
+ \Longman\TelegramBot\Request::sendMessage([
+ 'chat_id' => TELEGRAM_CHAT_ID,
+ 'text' => $content,
+ 'parse_mode' => 'Markdown'
+ ]);
+ }
- $content_length = $this->host->get($this, 'content_length');
- if (!is_numeric($content_length))
- $content_length = $this->default_content_length;
+ return $article;
+ }
- if ($content_length > 0) {
- $content_stripped = preg_replace('#
#i', "\n", $article["content"]);
- $content_stripped = strip_tags($content_stripped);
- $content_stripped = html_entity_decode($content_stripped);
- $content_stripped = trim($content_stripped);
-
- if (strlen($content_stripped) > $content_length) {
- $payload["content"] .= "\n_" . substr($content_stripped, 0, $content_length) . "..._";
- } else {
- $payload["content"] .= "\n_" . $content_stripped . "_";
- }
- }
-
- $sth = $this->pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?");
- $sth->execute([$article["feed"]["id"]]);
-
- if ($row = $sth->fetch()) {
- $payload["username"] = $row["title"];
- }
-
- $ch = curl_init($webhook_url);
- curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
-
- curl_exec($ch);
- curl_close($ch);
- }
-
- return $article;
- }
-
- function hook_prefs_tab($args)
- {
- if ($args != "prefPrefs") return;
-
- $replacements = array(
- '{webhook_url}' => $this->host->get($this, 'webhook_url'),
- '{content_length}' => $this->host->get($this, 'content_length'),
- '{default_content_length}' => $this->default_content_length,
- '{discord_api_url}' => $this->discord_api_url
- );
-
- $template = file_get_contents(__DIR__."/pref_template.html");
- $template = str_replace(array_keys($replacements), array_values($replacements), $template);
- print $template;
- }
-
- function save()
- {
- $this->host->set($this, 'webhook_url', $_POST['webhook_url']);
- $this->host->set($this, 'content_length', $_POST['content_length']);
- echo __("Configuration saved");
- }
-
- function api_version() {
- return 2;
- }
+ function api_version() {
+ return 2;
+ }
}
?>
diff --git a/pref_template.html b/pref_template.html
deleted file mode 100644
index 3b820b5..0000000
--- a/pref_template.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
- Instructions for how to create a webhook URL for a server channel can be found here. -
- -