Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telenode-js

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telenode-js - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

examples/long-polling.js

2

package.json
{
"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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc