2023-10-22 20:18:12 +03:00
|
|
|
{{emit_if (not features.typescript)}}
|
|
|
|
{{#if features.dispatcher}}
|
|
|
|
import { Dispatcher, filters } from '@mtcute/dispatcher'
|
|
|
|
{{/if}}
|
2024-03-23 22:53:35 +03:00
|
|
|
{{#if (eq packageManager "bun")}}
|
|
|
|
import { TelegramClient } from '@mtcute/bun'
|
|
|
|
{{else}}
|
2024-03-06 21:24:33 +03:00
|
|
|
import { TelegramClient } from '@mtcute/node'
|
2024-03-23 22:53:35 +03:00
|
|
|
{{/if}}
|
2023-10-22 20:18:12 +03:00
|
|
|
|
|
|
|
import * as env from './env.js'
|
|
|
|
{{#if features.i18n}}
|
|
|
|
import { tr } from './i18n/index.js'
|
|
|
|
{{/if}}
|
|
|
|
|
2024-03-06 21:24:33 +03:00
|
|
|
const tg = new TelegramClient({
|
2023-10-22 20:18:12 +03:00
|
|
|
apiId: env.API_ID,
|
|
|
|
apiHash: env.API_HASH,
|
|
|
|
storage: 'bot-data/session',
|
|
|
|
})
|
|
|
|
|
|
|
|
{{#if features.dispatcher}}
|
2023-11-01 14:11:46 +03:00
|
|
|
const dp = Dispatcher.for(tg)
|
2023-10-22 20:18:12 +03:00
|
|
|
|
|
|
|
dp.onNewMessage(filters.start, async (msg) => {
|
|
|
|
{{#if features.i18n}}
|
|
|
|
await msg.answerText(tr(msg, 'helloWorld'))
|
|
|
|
{{else}}
|
|
|
|
await msg.answerText('Hello, world!')
|
|
|
|
{{/if}}
|
|
|
|
})
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
tg.run(
|
|
|
|
{{#if botToken}}
|
|
|
|
{ botToken: env.BOT_TOKEN },
|
|
|
|
{{/if}}
|
|
|
|
(user) => {
|
|
|
|
console.log('Logged in as', user.username)
|
|
|
|
},
|
|
|
|
)
|