Telegram userbot nodes for Node-RED
npm install node-red-node-telegrambot
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.
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.
Node.js v18.12.1 and Node-RED v3.0.2.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).
msg.payload. ``javascript`
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;
#### 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.
`javascript``
let username = msg.payload;
msg.payload = {
api: "account",
func: "CheckUsername",
args: {
username: 'usernameToCheckHere'
}
}
return msg;