1
0

mainjs.js 705 B

1234567891011121314151617181920
  1. const { TelegramClient } = require('telegram/dist')
  2. const { StringSession } = require('telegram/dist/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. })()