{{emit_if (not features.typescript)}}
{{#if features.dispatcher}}
import { Dispatcher, filters } from '@mtcute/dispatcher'
{{/if}}
{{#if (eq runtime "bun")}}
import { TelegramClient } from '@mtcute/bun'
{{else if (eq runtime "deno")}}
import { TelegramClient } from '@mtcute/deno'
{{else}}
import { TelegramClient } from '@mtcute/node'
{{/if}}

import * as env from './env.js'
{{#if features.i18n}}
import { tr } from './i18n/index.js'
{{/if}}

const tg = new TelegramClient({
    apiId: env.API_ID,
    apiHash: env.API_HASH,
    storage: 'bot-data/session',
})

{{#if features.dispatcher}}
const dp = Dispatcher.for(tg)

dp.onNewMessage(filters.start, async (msg) => {
    {{#if features.i18n}}
    await msg.answerText(tr(msg, 'helloWorld'))
    {{else}}
    await msg.answerText('Hello, world!')
    {{/if}}
})
{{/if}}

{{#if botToken}}
const user = await tg.start({ botToken: env.BOT_TOKEN })
{{else}}
const user = await tg.start()
{{/if}}
console.log('Logged in as', user.username)
