aboutsummaryrefslogtreecommitdiffstats
path: root/src/middleware.ts
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2021-04-18 18:07:54 +0300
committerJan Tuomi <jan.tuomi@valuemotive.com>2021-04-18 18:07:54 +0300
commitbaacc7676c688cd2728033e9051208d655255ee5 (patch)
tree5a3819b1c5f6ad616d82f84b3a62cca20d54c0f7 /src/middleware.ts
parent12f3de7a9ec911cf5945eee31c7680aa75c4f8af (diff)
Work on tg bot
Diffstat (limited to 'src/middleware.ts')
-rw-r--r--src/middleware.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/middleware.ts b/src/middleware.ts
index bdc006a..e2814e0 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -1,5 +1,18 @@
-import { NextFunction, Request, Response } from "@tinyhttp/app";
+import { Context } from "telegraf";
+import config from "./config";
-export const auth = async (_req: Request, _res: Response, next: NextFunction): Promise<void> => {
- await next();
+const auth = async (ctx: Context, next: () => Promise<void>): Promise<void> => {
+ const userId = ctx.message?.from.id;
+
+ if (!userId || !config.tgUserIds.includes(userId)) {
+ ctx.reply("Käyttäjälläsi ei ole oikeuksia startata HommaBottia.");
+ } else {
+ await next();
+ }
+};
+
+export const tgMiddleware = {
+ auth,
};
+
+export const httpMiddleware = {};