Skip to content

Commit

Permalink
remove legacy methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyz-sui committed Apr 9, 2024
1 parent 62a2d58 commit 72b63b0
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions Modules/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,50 +1130,6 @@ public static void FlashColor(Color color, float duration = 1f)
obj.GetComponent<SpriteRenderer>().color = new(color.r, color.g, color.b, Mathf.Clamp01((-2f * Mathf.Abs(t - 0.5f) + 1) * color.a)); //アルファ値を0→目標→0に変化させる
})));
}
public static void MakeWebhookUrlFile()
{
Logger.Info("WebhookUrl.txtを作成", "Webhook");
try
{
File.WriteAllText("WebhookUrl.txt", "この文章を削除してウェブフックのURLを記述/Remove this text and enter Webhook url");
}
catch (Exception ex)
{
Logger.Error(ex.ToString(), "Webhook");
}
}
public static void SendWebhook(string text, string userName = "Town Of Host")
{
if (!File.Exists("WebhookUrl.txt"))
MakeWebhookUrlFile();
HttpClient client = new();
Dictionary<string, string> message = new()
{
{ "content", text },
{ "username", userName },
{ "avatar_url", "https://raw.githubusercontent.com/Hyz-sui/TownOfHost-H/images-H/Images/discord-avatar.png" }
};
using StreamReader sr = new("WebhookUrl.txt", Encoding.UTF8);
string webhookUrl = sr.ReadLine();
if (!Regex.IsMatch(webhookUrl, "^(https://(ptb.|canary.)?discord(app)?.com/api/webhooks/)")) // ptbとcanaryとappはあってもなくてもいい
{
Logger.Info("WebhookUrl.txtの内容がdiscordのウェブフックurlではなかったためウェブフックの送信をキャンセル", "Webhook");
return;
}
try
{
TaskAwaiter<HttpResponseMessage> awaiter = client.PostAsync(webhookUrl, new FormUrlEncodedContent(message)).GetAwaiter();
var response = awaiter.GetResult();
Logger.Info("ウェブフックを送信しました", "Webhook");
if (!response.IsSuccessStatusCode)
Logger.Warn("応答が異常です", "Webhook");
Logger.Info($"{(int)response.StatusCode} {response.ReasonPhrase}", "Webhook"); // 正常な応答: 204 No Content
}
catch (Exception ex)
{
Logger.Error(ex.ToString(), "Webhook");
}
}
public static string ColorIdToDiscordEmoji(int colorId, bool alive)
{
if (alive)
Expand Down

0 comments on commit 72b63b0

Please sign in to comment.