diff options
| author | Dhravya <[email protected]> | 2024-06-23 17:09:34 -0500 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-06-23 17:09:34 -0500 |
| commit | 7117885a27672561e3f16f30afc6c05dbad738a6 (patch) | |
| tree | 57668642405c9c90f2e0466e949abc5065663aa3 /apps | |
| parent | add: telegram bot setup with grammy lib (diff) | |
| download | supermemory-feat/telegram-api.tar.xz supermemory-feat/telegram-api.zip | |
error out if there's no idfeat/telegram-api
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/app/api/telegram/route.ts | 15 | ||||
| -rw-r--r-- | apps/web/cf-env.d.ts | 1 |
2 files changed, 12 insertions, 4 deletions
diff --git a/apps/web/app/api/telegram/route.ts b/apps/web/app/api/telegram/route.ts index 0a140b40..b80f6173 100644 --- a/apps/web/app/api/telegram/route.ts +++ b/apps/web/app/api/telegram/route.ts @@ -3,19 +3,26 @@ import { User } from "grammy/types"; export const runtime = "edge"; -const token = process.env.TELEGRAM_BOT_TOKEN ?? ""; +if (!process.env.TELEGRAM_BOT_TOKEN) { + throw new Error("TELEGRAM_BOT_TOKEN is not defined"); +} + +console.log("Telegram bot activated"); +const token = process.env.TELEGRAM_BOT_TOKEN; const bot = new Bot(token); bot.command("start", async (ctx) => { const user: User = (await ctx.getAuthor()).user; - await ctx.reply(`Welcome to Supermemory bot, ${user.first_name}. I am here to help you remember things better.`); + await ctx.reply( + `Welcome to Supermemory bot, ${user.first_name}. I am here to help you remember things better.`, + ); }); bot.on("message", async (ctx) => { await ctx.reply( - "Hi there! This is Supermemory bot. I am here to help you remember things better." + "Hi there! This is Supermemory bot. I am here to help you remember things better.", ); }); -export const POST = webhookCallback(bot, "std/http");
\ No newline at end of file +export const POST = webhookCallback(bot, "std/http"); diff --git a/apps/web/cf-env.d.ts b/apps/web/cf-env.d.ts index be5c991a..3072a528 100644 --- a/apps/web/cf-env.d.ts +++ b/apps/web/cf-env.d.ts @@ -11,6 +11,7 @@ declare global { R2_BUCKET_NAME: string; BACKEND_SECURITY_KEY: string; BACKEND_BASE_URL: string; + TELEGRAM_BOT_TOKEN: string; } } } |