New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

telenode-js

Package Overview
Dependencies
Maintainers
1
Versions
20
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.0.1-0 to 1.0.1

LICENSE

0

index.js
module.exports = require('./src/bot');

80

package.json
{
"name": "telenode-js",
"version": "1.0.1-0",
"description": "Lightweight Telegram API framework for Node.js",
"main": "index.js",
"author": "Niv Ezra",
"license": "MIT",
"scripts": {
"dev": "nodemon ./examples",
"publish:dry": "npm publish --dry-run",
"set-webhook": "node ./scripts/setWebhook.js"
},
"bin": {
"set-webhook": "./scripts/setWebhook.js"
},
"files": [
"src/**"
],
"repository": {
"type": "git",
"url": "https://github.com/NivEz/telenode"
},
"keywords": [
"telegram",
"telegram bot",
"telegram api",
"telegram bot api",
"telegram framework",
"bot",
"telenode"
],
"dependencies": {
"axios": "^1.2.3",
"express": "^4.18.2"
},
"devDependencies": {
"nodemon": "^2.0.20",
"dotenv": "^16.0.3"
}
"name": "telenode-js",
"version": "1.0.1",
"description": "Lightweight Telegram API framework for Node.js",
"main": "index.js",
"author": "Niv Ezra <dev@nivezra.com>",
"license": "MIT",
"scripts": {
"dev": "nodemon ./scripts/runDev.js",
"publish:dry": "npm publish --dry-run",
"set-webhook": "node ./scripts/setWebhook.js",
"postinstall": "husky install"
},
"bin": {
"set-webhook": "./scripts/setWebhook.js"
},
"files": [
"src/**"
],
"repository": {
"type": "git",
"url": "https://github.com/NivEz/telenode"
},
"keywords": [
"telegram",
"telegram bot",
"telegram api",
"telegram bot api",
"telegram framework",
"bot",
"telenode"
],
"dependencies": {
"axios": "^1.2.3",
"express": "^4.18.2"
},
"devDependencies": {
"dotenv": "^16.0.3",
"husky": "^8.0.3",
"nodemon": "^2.0.20",
"prettier": "^2.8.3",
"pretty-quick": "^3.1.3"
}
}

@@ -1,2 +0,2 @@

# telenode-js
# Telenode

@@ -6,2 +6,6 @@

![npm package](https://img.shields.io/badge/-grey?logo=telegram)
[![npm package](https://img.shields.io/npm/v/telenode-js?color=orange&logo=npm)](https://www.npmjs.org/package/telenode-js)
[![MIT licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://raw.githubusercontent.com/NivEz/telenode/main/LICENSE)
---

@@ -26,3 +30,3 @@

```
npm exec set-webhook
npx set-webhook
```

@@ -33,6 +37,6 @@

```
const TeleNode = require('../src/bot');
const Telenode = require('telenode-js');
require('dotenv').config();
const bot = new TeleNode({
const bot = new Telenode({
apiToken: process.env.API_TOKEN,

@@ -51,3 +55,13 @@ });

Additional examples can be found in the [examples folder](https://github.com/NivEz/telenode/tree/main/examples).
Additional examples can be found in the [examples folder](https://github.com/NivEz/telenode/tree/main/examples).
---
### TODO's
- [x] Regex matching on text messages
- [ ] Buttons support (sending & listening)
- [ ] Direct respond function in message handler without passing chat ID
- [ ] Chat ID handlers
- [ ] Arguments validations
- [ ] Add tests

@@ -0,0 +0,0 @@ #!/usr/bin/env node

const { runServer } = require('./server');
const axios = require('axios');
class TeleNode {
class Telenode {
#baseUrl;

@@ -9,2 +9,3 @@

this.textHandlers = {};
this.arrRegexHandlers = [];
this.anyTextHandler = null;

@@ -19,9 +20,24 @@ this.#baseUrl = 'https://api.telegram.org/bot' + apiToken;

messageHandler(receivedMessage) {
if (receivedMessage.text) {
const textHandler = this.textHandlers[receivedMessage.text];
if (textHandler) {
textHandler(receivedMessage);
} else if (this.anyTextHandler) {
this.anyTextHandler(receivedMessage);
const msg = receivedMessage.text;
if (!msg) {
return;
}
const textHandler = this.textHandlers[msg];
if (textHandler) {
textHandler(receivedMessage);
return;
}
this.arrRegexHandlers.some(re => {
const isMatch = msg.match(re.pattern);
if (isMatch) {
re.handler(receivedMessage);
// Return true to stop the loop
return true;
}
});
// This should be the final step to validate that no matches occurred
if (this.anyTextHandler) {
this.anyTextHandler(receivedMessage);
return;
}

@@ -33,5 +49,11 @@ };

this.anyTextHandler = handler;
} else {
} else if (message instanceof RegExp) {
this.arrRegexHandlers.push({
pattern: message,
handler,
});
} else if (typeof message === 'string') {
this.textHandlers[message] = handler;
}
};

@@ -48,2 +70,3 @@

module.exports = TeleNode;
module.exports = Telenode;

@@ -0,0 +0,0 @@ const express = require('express');

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