import { Client } from 'tdl'; import { TDLib } from 'tdl-tdlib-addon'; import path from 'path'; import dotenv from 'dotenv' dotenv.config() const __dirname = path.dirname(new URL(import.meta.url).pathname); function onUpdate(update){ console.log('UPDATE HERE', update) } const client = new Client(new TDLib(path.join(__dirname, 'libtdjson.so')), { apiId: process.env.APP_ID, apiHash: process.env.APP_HASH }) client.login() client.on('update', onUpdate) client.on('error', console.error) async function main(){ const chats = await client.invoke({ _: 'getChats', chat_list: { _: 'chatListMain' }, limit: 4000 }) console.log('current chats', chats) }