Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 1a797bb

Browse files
authored
Merge pull request #2 from ut-code/feat/mention
mention users
2 parents 9042502 + 0b8e1a0 commit 1a797bb

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

src/data.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const nameMap = new Map<string, `${number}`>([
2+
// 運営
3+
["KOBAYASHI Yuki / 小林", "502798784959479808"],
4+
["Yasumura Takuya / 安村拓也", "1225332719068643424"],
5+
["SHIBAYAMAKeiichiro", "660420646261489674"],
6+
["MANABEKaichi", "1119186793099710514"],
7+
["Ryuhei TAKANAKA", "905761740665528370"],
8+
["Hiroki Oya / 大矢宏輝", "735679928007131213"],
9+
["中村渉吾 (Shogo Nakamura)", "703588743738687488"],
10+
11+
// 運営ではないけど運営タスクに名前のある人
12+
["川端 悠斗", "943071631167860756"],
13+
]);

src/main.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as v from "valibot";
2+
import { nameMap } from "./data.ts";
23
import { queryNotion, retry, webhook } from "./io.ts";
34
import { NotionFetchResponse, type Task } from "./validator.ts";
45

@@ -36,19 +37,31 @@ const query = {
3637
],
3738
};
3839

39-
function formatTask(task: Task) {
40+
function formatTask(task: Task): string {
4041
const due = task.properties.期日?.date.start;
4142
const title = task.properties.タイトル?.title.map((title) => title.plain_text).join("");
42-
const assignee = task.properties.担当者?.people.map((person) => person.name).join(" / @");
43+
const assignees = task.properties.担当者?.people.map(
44+
(person): { success: true; id: string } | { success: false; display: string } => {
45+
if (!person.name) return { success: false, display: "-" };
46+
const d_id = nameMap.get(person.name);
47+
if (!d_id) return { success: false, display: person.name };
48+
return { success: true, id: d_id };
49+
},
50+
);
51+
52+
const assignee = assignees
53+
?.map((a) => {
54+
if (a.success) return `<@${a.id}>`;
55+
return `@${a.display}`;
56+
})
57+
.join(" ");
4358

4459
if (!assignee) {
4560
return `・【${due}${title} (担当者不在)`;
4661
}
47-
return `・【${due}${title} @${assignee}`;
62+
return `・【${due}${title} ${assignee}`;
4863
}
49-
/**
50-
- @throws on NetworkError and ParseError
51-
*/
64+
5265
async function main() {
5366
const res = await queryNotion(query);
5467
const json = v.parse(NotionFetchResponse, await res.json());

0 commit comments

Comments
 (0)