main.ts 692 B

12345678910111213141516171819202122
  1. import {TelegramClient} from "../gramjs";
  2. import {StringSession} from "../gramjs/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. })();