forked from ubiquity/ubiquibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.ts
More file actions
21 lines (18 loc) · 716 Bytes
/
Copy pathshared.ts
File metadata and controls
21 lines (18 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { getBotContext } from "../bindings";
import { Payload, UserType } from "../types";
const contextNamesToSkip = ["workflow_run"];
export const shouldSkip = (): { skip: boolean; reason: string } => {
const context = getBotContext();
const { name } = context;
const payload = context.payload as Payload;
const res: { skip: boolean; reason: string } = { skip: false, reason: "" };
if (contextNamesToSkip.includes(name)) {
res.skip = true;
res.reason = `excluded context name: ${name}`;
} else if (payload.sender.type === UserType.Bot) {
res.skip = true;
res.reason = "sender is a bot";
}
return res;
};
export const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));