npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-node-telegrambot

v0.1.6

Published

Telegram userbot nodes for Node-RED

Downloads

1,105

Readme

Telegram client nodes for Node-RED

Platform License Downloads Total Downloads NPM Known Vulnerabilities Telegram Package Quality Build Open Issues Closed Issues ...

This package contains a node which act as a Telegram Client. It is based on gramjs which implements the mtproto mobile protocol. (see https://core.telegram.org/mtproto). Unlike node-red-contrib-telegrambot it does not support the telegram bot api. The package can be used to create so-called userbots or selfbots which to automate things under your own user-name. However you should be aware of the fact, that if you cause flooding and other havoc telegram will quickly ban your account either for 24h or even forever. It is recommended to use a test account while developing.

Thanks for your donation

If you want to support this free project. Any help is welcome. You can donate by clicking one of the following links:

Credits

Installation

NPM

You can install the nodes using node-red's "Manage palette" in the side bar.

Or run the following command in the root directory of your Node-RED installation

npm install node-red-node-telegrambot --save

Note that the minimum node-red version 1.3.7 and minimum nodejs version is 12.x.

Dependencies

The nodes are tested with Node.js v18.12.1 and Node-RED v3.0.2.

Changelog

Changes can be followed here.

Usage

Basics

Authentication

The Telegram client receiver node receives messages from like a telegram client. You need to login with a phone-number and an API ID and API Hash in order to be able to receive message under your own user name. In addition to that you can also login using a bot token retrieved from @botfather.

You can create an API ID and Hash when you login to your telegram account here https://my.telegram.org/auth Then go to 'API Development Tools' and create your API ID and API Hash. Both are required when configuring your nodes. The nodes login only once to create a so-called session string. This string can be created from within the config node or as an alternative you can also create it online here https://tgsnake.js.org/login This session string is used instead of interactive login (where you need to enter a phone-code and your password if set).

Receiver Node

The Telegram client receiver node receives message which are sent to your account or bot. Just add a debug node to the output and investigate the objects in msg.payload.

Sender Node

The Telegram client sender node is able to call nearly all functions provides by gramjs. For a full list of methods please visit https://gram.js.org/ under TL.

Examples

Api.messages.SendMessage

To call the SendMessage function, you must do the following: Create a function node and enter 'messages' for the api property and 'SendMessage' for the func property. The arguments described in the api must be added to args. SendMessage contains a field randomId which must be set by the user to a random number to prevent message looping in the telegram server. Peer must be set to the name of the user you want to send the message to.

let randomId = BigInt(Math.floor(Math.random() * 1e15));
let username = msg.payload;
msg.payload = {
   api: 'messages',
   func: 'SendMessage',
   args: {
       peer: "to username",
       message: "Test1",
       randomId: randomId,
       noWebpage: true,
       noforwards: true,
       scheduleDate: 0,
       // sendAs: "from username",
   }
}
return msg;

send message flow

Api.account.CheckUsername

To call the CheckUsername function, you must do the following: Create a function node and enter 'account' for the api property and 'CheckUsername' for the func property. The arguments described in the api must be added to args. In this case it is only the username property.

let username = msg.payload;
msg.payload = {
   api: "account",
   func: "CheckUsername",
   args: {
       username: 'usernameToCheckHere'
   }
}
return msg;

check username flow