- improved bun support - deno support - use antfu/eslint-config - fixed some issues - removed pre-commit hooks
49 lines
1.1 KiB
Handlebars
49 lines
1.1 KiB
Handlebars
{{emit_if 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}}
|
|
|
|
{{#if (eq runtime "node")}}
|
|
import * as env from './env.js'
|
|
{{else}}
|
|
import * as env from './env.ts'
|
|
{{/if}}
|
|
{{#if features.i18n}}
|
|
{{#if (eq runtime "node")}}
|
|
import { tr } from './i18n/index.js'
|
|
{{else}}
|
|
import { tr } from './i18n/index.ts'
|
|
{{/if}}
|
|
{{/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)
|