Skip to content

Commit

Permalink
🍊 Basic working example
Browse files Browse the repository at this point in the history
  • Loading branch information
Rnbsov committed Mar 10, 2024
1 parent 9b3309a commit 1f830ac
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 17 deletions.
22 changes: 5 additions & 17 deletions bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ import { slashCommandsListener } from './src/slashCommands.ts'
import { cancelMenuAndResetLabel } from "./src/menus.ts";
import { getUrlAndLabels } from "./src/utils/getUrlAndLabels.ts";
import { includeSourceChoiceMenu } from "./src/menus.ts";
import { Hono } from "https://deno.land/x/hono@v4.0.10/mod.ts"
import { webhookCallback } from "https://deno.land/x/grammy@v1.21.1/mod.ts";

await load({ export: true })


const app = new Hono()
const bot = new Bot<MyContext>(Deno.env.get('BOT_TOKEN') || '')

app.post('/', webhookCallback(bot, 'hono'))

// sessions
bot.use(sessionHandler())
Expand Down Expand Up @@ -110,20 +115,3 @@ You can get new by following this guide [Getting an API token](https://docs.omni

await ctx.conversation.enter('updateToken')
})

bot.start()

bot.catch(err => {
const ctx = err.ctx
console.error(
`Error while handling update ${ctx.update.update_id}:`
)
const e = err.error
if (e instanceof GrammyError) {
console.error('Error in request:', e.description)
} else if (e instanceof HttpError) {
console.error('Could not contact Telegram:', e)
} else {
console.error('Unknown error:', e)
}
})
64 changes: 64 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1f830ac

Please sign in to comment.