change whitelist to work with a JSON file
This commit is contained in:
parent
13a1cf3d50
commit
7b6fcdf650
4 changed files with 21 additions and 5 deletions
14
index.ts
14
index.ts
|
@ -1,6 +1,6 @@
|
|||
import type { UsersInfoResponse } from "@slack/web-api";
|
||||
|
||||
const { App, ExpressReceiver } = (await import("@slack/bolt"));
|
||||
const { App } = (await import("@slack/bolt"));
|
||||
import "dotenv/config";
|
||||
|
||||
const app = new App({
|
||||
|
@ -8,17 +8,21 @@ const app = new App({
|
|||
signingSecret: process.env.SLACK_SIGNING_SECRET,
|
||||
});
|
||||
|
||||
const whitelist: string[] = []
|
||||
const whitelist: string[] = (() => {
|
||||
try {
|
||||
return require('./whitelist.json')
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
})();
|
||||
|
||||
function checkUserOk(user: UsersInfoResponse['user']) {
|
||||
if (whitelist.includes(user!.id!)) return true
|
||||
|
||||
console.log(user)
|
||||
|
||||
return user!.is_admin || user!.is_owner || user!.is_primary_owner
|
||||
}
|
||||
|
||||
const eligibilityCmd = async ctx => {
|
||||
const eligibilityCmd = async (ctx: any) => {
|
||||
await ctx.ack();
|
||||
|
||||
const text = ctx.command.text.slice();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue