aboutsummaryrefslogtreecommitdiffstats
path: root/src/middleware.ts
blob: e2814e0b9f85b46c7eea67bab47c8707aa866fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { Context } from "telegraf";
import config from "./config";

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 = {};