1
0

mainjs.js 900 B

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