|
12 | 12 | using static TownOfHost.Translator;
|
13 | 13 | using TownOfHost.Modules.GameEventHistory;
|
14 | 14 | using TownOfHost.Modules.GameEventHistory.Events;
|
| 15 | +using TownOfHost.Modules.Webhook; |
15 | 16 |
|
16 | 17 | namespace TownOfHost
|
17 | 18 | {
|
@@ -257,26 +258,42 @@ public static void Postfix(EndGameManager __instance)
|
257 | 258 | if (PlayerControl.LocalPlayer.PlayerId == 0)
|
258 | 259 | {
|
259 | 260 | if (CustomWinnerHolder.WinnerTeam == CustomWinner.Draw)
|
| 261 | + { |
260 | 262 | Logger.Info("廃村のため試合結果の送信をキャンセル", "Webhook");
|
| 263 | + } |
261 | 264 | else
|
262 | 265 | {
|
| 266 | + var resultMessageBuilder = new WebhookMessageBuilder() |
| 267 | + { |
| 268 | + UserName = "試合結果", |
| 269 | + }; |
263 | 270 | if (Main.SendResultToDiscord.Value)
|
264 | 271 | {
|
265 |
| - var resultMessage = ""; |
| 272 | + resultMessageBuilder.ContentBuilder.AppendLine("### 各プレイヤーの最終結果"); |
266 | 273 | foreach (var id in Main.winnerList)
|
267 | 274 | {
|
268 |
| - resultMessage += Utils.ColorIdToDiscordEmoji(Palette.PlayerColors.IndexOf(Main.PlayerColors[id]), !PlayerState.GetByPlayerId(id).IsDead) + ":star:" + EndGamePatch.SummaryText[id].RemoveHtmlTags() + "\n"; |
| 275 | + resultMessageBuilder.ContentBuilder.Append(Utils.ColorIdToDiscordEmoji(Palette.PlayerColors.IndexOf(Main.PlayerColors[id]), !PlayerState.GetByPlayerId(id).IsDead)); |
| 276 | + resultMessageBuilder.ContentBuilder.Append(":star:"); |
| 277 | + resultMessageBuilder.ContentBuilder.Append(EndGamePatch.SummaryText[id].RemoveHtmlTags()); |
| 278 | + resultMessageBuilder.ContentBuilder.AppendLine(); |
269 | 279 | }
|
270 | 280 | foreach (var id in cloneRoles)
|
271 | 281 | {
|
272 |
| - resultMessage += Utils.ColorIdToDiscordEmoji(Palette.PlayerColors.IndexOf(Main.PlayerColors[id]), !PlayerState.GetByPlayerId(id).IsDead) + "\u3000" + EndGamePatch.SummaryText[id].RemoveHtmlTags() + "\n"; |
| 282 | + resultMessageBuilder.ContentBuilder.Append(Utils.ColorIdToDiscordEmoji(Palette.PlayerColors.IndexOf(Main.PlayerColors[id]), !PlayerState.GetByPlayerId(id).IsDead)); |
| 283 | + resultMessageBuilder.ContentBuilder.Append('\u3000'); |
| 284 | + resultMessageBuilder.ContentBuilder.Append(EndGamePatch.SummaryText[id].RemoveHtmlTags()); |
| 285 | + resultMessageBuilder.ContentBuilder.AppendLine(); |
273 | 286 | }
|
274 |
| - Utils.SendWebhook(resultMessage, GetString("LastResult")); |
275 | 287 | }
|
276 | 288 | if (Main.SendHistoryToDiscord.Value)
|
277 | 289 | {
|
278 |
| - var historyMessage = EventHistory.CurrentInstance.ToDiscordString(); |
279 |
| - Utils.SendWebhook(historyMessage, "ゲーム記録"); |
| 290 | + resultMessageBuilder.ContentBuilder.AppendLine("### 記録"); |
| 291 | + EventHistory.CurrentInstance.AppendDiscordString(resultMessageBuilder.ContentBuilder); |
| 292 | + } |
| 293 | + |
| 294 | + if (resultMessageBuilder.ContentBuilder.Length > 0) |
| 295 | + { |
| 296 | + WebhookManager.Instance.StartSend(resultMessageBuilder); |
280 | 297 | }
|
281 | 298 | }
|
282 | 299 | }
|
|
0 commit comments