-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathWebhookJson.cs
62 lines (54 loc) · 1.74 KB
/
WebhookJson.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Palworld_server_protector_DotNet
{
internal class WebhookJson
{
public string GenerateJson(string url, string jsontitle, string message)
{
// 判断URL是否包含特定字符串
if (url.Contains("weixin.qq"))
{
var markdownObject = new
{
msgtype = "markdown",
markdown = new
{
content = $"<font color=\"warning\">服务端监控 </font>{jsontitle}\n ><font color=\"comment\">{message}</font>"
}
};
return JsonConvert.SerializeObject(markdownObject);
}
else if (url.Contains("dingtalk.com"))
{
var markdownObject = new
{
msgtype = "markdown",
markdown = new
{
title = jsontitle,
text = $"#### 服务端监控:{jsontitle} \n > {message}\n > \n "
}
};
return JsonConvert.SerializeObject(markdownObject);
}
else
{
var unknownObject = new
{
msgtype = "normal",
data =new
{
title = jsontitle,
content = message
}
};
return JsonConvert.SerializeObject(unknownObject);
}
}
}
}