const { Client } = require('tdl')
const { TDLib } = require('tdl-tdlib-addon')
var path = require('path');

const tgclient = new Client(new TDLib(path.join(__dirname, 'td/build/libtdjson.so')), {
  apiId: 234569,
  apiHash: 'ee77bf549e61d3de158916126c8ef7dd'
})

tgclient.on('error', console.error)
tgclient.on('update', update => {
  console.log('Received update:', update)
})

async function main () {
  await tgclient.connectAndLogin()

  console.log(await tgclient.invoke({ _: 'getMe' }))

  // ...
}

main().catch(console.error)

module.exports = tgclient