Skip to content

Commit

Permalink
fix: template
Browse files Browse the repository at this point in the history
  • Loading branch information
cma2819 committed Dec 20, 2024
1 parent 77c876f commit 0c7d0ef
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions app/routes/_index/templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@ interface Template {
apply: (run: Run) => string;
}

const presentRunners = (runners: Run["runner"]) => {
const twitter = (twitterId: string | undefined) =>
twitterId ? `(@${twitterId})` : "";

const presentParticipants = (
participants: Run["runner"] | Run["commentary"]
) => {
return participants
.map((p) => {
const name = p.username.replaceAll("@", "@ ");
return `${name}さん${twitter(p.twitterid)}`;
})
.join("、");
};

const presentRunnerTimes = (runners: Run["runner"]) => {
return runners
.map((runner) => {
const name = runner.username.replaceAll("@", "@ ");
return `${name}さん(@${runner.twitterid})`;
return `${name}${twitter(runner.twitterid)} xx:xx:xx`;
})
.join("");
.join("\n");
};

export const templates: Template[] = [
Expand All @@ -26,32 +40,40 @@ export const templates: Template[] = [
apply: (run) =>
`次のタイムアタックは『${run.gamename}』\nカテゴリーは「${
run.category
}」\n走者は${presentRunners(
run.runner
)}です。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
}」\n走者は${presentParticipants(run.runner)}です。\n${
run.commentary.length > 0
? `解説は${presentParticipants(run.commentary)}です。`
: ""
}\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
},
{
label: "finishWithTime",
apply: (run) =>
`『${run.gamename}』のカテゴリー「${
run.category
}」RTA\n走者の${presentRunners(
run.runner
)}お疲れさまでした。\nクリアタイムはxx:xx:xxでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
}」RTA\n走者の${presentParticipants(run.runner)}${
run.commentary.length > 0
? `、解説の${presentParticipants(run.commentary)}`
: ""
}お疲れさまでした。\nクリアタイムはxx:xx:xxでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
},
{
label: "finishWithoutTime",
apply: (run) =>
`『${run.gamename}』のカテゴリー「${
run.category
}」RTA\n走者の${presentRunners(
run.runner
)}お疲れさまでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
}」RTA\n走者の${presentParticipants(run.runner)}${
run.commentary.length > 0
? `、解説の${presentParticipants(run.commentary)}`
: ""
}お疲れさまでした。\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
},
{
label: "finishOnlyTime",
apply: (run) =>
`『${run.gamename}』\nクリアタイムは次の通りです\n\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
`『${run.gamename}』\nクリアタイムは次の通りです\n\n${presentRunnerTimes(
run.runner
)}\n\n配信はこちらから⇒https://www.twitch.tv/rtainjapan\n#RTAinJapan`,
},
{
label: "running",
Expand Down

0 comments on commit 0c7d0ef

Please sign in to comment.