mainjs.js 673 B

123456789101112131415161718
  1. const { TelegramClient } = require("telegram");
  2. const { StringSession } = require("telegram/sessions");
  3. (async () => {
  4. console.log("Loading interactive example...");
  5. const apiId = -1; // put your api id here [for example 123456789]
  6. const apiHash = ""; // put your api hash here [for example '123456abcfghe']
  7. const client = new TelegramClient(new StringSession(""), apiId, apiHash, {
  8. connectionRetries: 3,
  9. });
  10. await client.start({
  11. botAuthToken: "YOUR BOT TOKEN",
  12. });
  13. console.log("You should now be connected.");
  14. console.log(await client.getMe());
  15. // USE THIS STRING TO AVOID RELOGGING EACH TIME
  16. console.log(await client.session.save());
  17. })();