telenode-js
Advanced tools
Comparing version 1.1.5 to 1.2.0
{ | ||
"name": "telenode-js", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Lightweight Telegram API framework for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,4 @@ # Telenode | ||
✅ Secret token support | ||
<br> | ||
✅ Long polling support | ||
@@ -72,2 +74,12 @@ ## Getting started | ||
### Long polling | ||
If you prefer to use long polling method over creating a server with webhook you can use the `startLongPolling` method instead of `createServer`. | ||
<br> | ||
The method accepts `pollingDelay` - a number that represents milliseconds (must be at least 50ms). | ||
<br> | ||
You can view an example of long polling usage [here](https://github.com/NivEz/telenode/tree/main/examples/long-polling.js). | ||
Note that long polling is usually not recommended and webhook is preferred for most use cases. | ||
### Usage | ||
@@ -74,0 +86,0 @@ |
const { runServer } = require('./server'); | ||
const { longPoll } = require('./longPolling'); | ||
const axios = require('axios'); | ||
@@ -22,3 +23,12 @@ | ||
startLongPolling({ pollingDelay } = {}) { | ||
longPoll({ | ||
bot: this, | ||
pollingDelay, | ||
url: this.#baseUrl, | ||
}); | ||
} | ||
telenodeHandler(reqBody, headersSecretToken, unauthorizedCallback) { | ||
// Note that if using long polling the secret token and unauthorizedCallback are irrelevant | ||
if (this.#secretToken && this.#secretToken !== headersSecretToken) { | ||
@@ -25,0 +35,0 @@ if (unauthorizedCallback) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18580
16
409
196
16