A simple example of TDLib (Telegram Database Library) authentication using tdl (Node.js package)
User login information (phone number and authentication code) gets by Telegram API Bot.
After successfully logging in, if you send "Ping" in your saved messages, you will see that "Pong" sent automatically.
- Build the binary (https://github.com/tdlib/td#building)
You can also use prebuilt binaries: tdlib.native
git clone https://github.com/mortezaataiy/nodejs-tdlib-login-example.git
- initial config.js file (like config-example.js)
npm install
npm start
- Send
/start
in your Api bot (that you set token in config file) - The bot want you to send phone number like this:
/send c+123456789012
char 'c' need!
- The bot want you to send auth code like this: (The code that Telegram send you for log in)
/send c12345
char 'c' need! (if send code without a char with telegram the code has expired!)
- The bot want you to send password like this if needed: (If Two-Step Verification is actived)
/send c12345
char 'c' need!
-
Now you receive "Ready" and now you can test cli bot with:
-
Send
Ping
in saved messages in your telegram account like gif -
you will see that "Pong" sends automatically :)