koishi-plugin-tmp-bot 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,204 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title></title>
6
- <link href="./package/leaflet/leaflet.min.css" rel="stylesheet">
7
- <script src="./package/leaflet/leaflet.min.js"></script>
8
- <script src="./package/leaflet/heatmap.min.js"></script>
9
- <script src="./package/leaflet/leaflet-heatmap.js"></script>
10
- <style>
11
- body, html {
12
- margin: 0;
13
- padding: 0;
14
- }
15
- * {
16
- font-family: "微软雅黑", serif;
17
- }
18
- #container {
19
- width: 1000px;
20
- position: relative;
21
- }
22
- .map {
23
- width: 100%;
24
- height: 900px;
25
- background-color: #4b4b4b;
26
- }
27
- .traffic-box {
28
- //position: absolute;
29
- //bottom: 0;
30
- //left: 0;
31
- //z-index: 9999999;
32
- width: 100%;
33
- backdrop-filter: blur(3px);
34
- background-color: #4b4b4b;
35
- padding: 12px 16px;
36
- box-sizing: border-box;
37
- overflow-y: hidden;
38
- }
39
- .traffic-item {
40
- color: #ffffff;
41
- width: 33.3333%;
42
- float: left;
43
- margin-top: 8px;
44
- font-size: 14px;
45
- border-right: 1px solid rgba(255, 255, 255, 0.3);
46
- box-sizing: border-box;
47
- padding: 0 10px;
48
- display: flex;
49
- flex-direction: row;
50
- align-items: center;
51
- justify-content: center;
52
- }
53
- .traffic-item:nth-child(-n+3) {
54
- margin-top: 0;
55
- }
56
- .traffic-item:last-child, .traffic-item:nth-child(3n) {
57
- border-right: 0;
58
- }
59
- .traffic-item .region-info {
60
- display: inline-block;
61
- width: 72%;
62
- white-space: nowrap;
63
- overflow: hidden;
64
- text-overflow: ellipsis;
65
- }
66
- .traffic-item .player-count {
67
- display: inline-block;
68
- width: 16%;
69
- text-align: center;
70
- }
71
- .traffic-item .traffic-status {
72
- display: inline-block;
73
- width: 12%;
74
- text-align: right;
75
- }
76
- </style>
77
- </head>
78
- <body>
79
- <div id="container">
80
- <div id="map" class="map"></div>
81
- <div class="traffic-box"></div>
82
- </div>
83
- <script>
84
- let mapConfig = {
85
- ets: {
86
- tileUrl: 'https://ets-map.oss-cn-beijing.aliyuncs.com/ets2/05102019/{z}/{x}/{y}.png',
87
- multipliers: {
88
- x: 71292,
89
- y: 60412
90
- },
91
- breakpoints: {
92
- uk: {
93
- x: -31056.8,
94
- y: -5832.867
95
- }
96
- },
97
- bounds: {
98
- y: 131072,
99
- x: 131072
100
- },
101
- maxZoom: 8,
102
- minZoom: 2,
103
- // 游戏地转地图坐标
104
- calculateMapCoordinate (x, y) {
105
- return [
106
- x / 1.325928 + mapConfig.ets.multipliers.x,
107
- y / 1.325928 + mapConfig.ets.multipliers.y
108
- ];
109
- }
110
- },
111
- promods: {
112
- tileUrl: 'https://tiles.truckyapp.com/promods/05102019/{z}/{x}/{y}.png',
113
- multipliers: {
114
- x: 41828,
115
- y: 77369
116
- },
117
- breakpoints: {
118
- uk: {
119
- x: -31056.8,
120
- y: -5832.867
121
- }
122
- },
123
- bounds: {
124
- y: 131072,
125
- x: 131072
126
- },
127
- maxZoom: 8,
128
- minZoom: 2,
129
- // 游戏地转地图坐标
130
- calculateMapCoordinate (x, y) {
131
- return [
132
- x / 2.303589 + mapConfig.promods.multipliers.x,
133
- y / 2.303589 + mapConfig.promods.multipliers.y
134
- ]
135
- }
136
- }
137
- }
138
-
139
- // 定义地图
140
- let map = L.map('map', {
141
- attributionControl: false,
142
- crs: L.CRS.Simple,
143
- zoomControl: false
144
- });
145
-
146
- function setData(data) {
147
- // 边界
148
- let bounds = L.latLngBounds(
149
- map.unproject([0, mapConfig[data.mapType].bounds.y], mapConfig[data.mapType].maxZoom),
150
- map.unproject([mapConfig[data.mapType].bounds.x, 0], mapConfig[data.mapType].maxZoom)
151
- );
152
-
153
- // 瓦片地图
154
- L.tileLayer(mapConfig[data.mapType].tileUrl, {
155
- minZoom: 1,
156
- maxZoom: 8,
157
- tileSize: 512,
158
- bounds: bounds,
159
- reuseTiles: true
160
- }).addTo(map);
161
- map.setMaxBounds(
162
- new L.LatLngBounds(
163
- map.unproject([0, mapConfig[data.mapType].bounds.y], mapConfig[data.mapType].maxZoom),
164
- map.unproject([mapConfig[data.mapType].bounds.x, 0], mapConfig[data.mapType].maxZoom)
165
- )
166
- );
167
-
168
- // 展示地图全貌
169
- map.fitBounds(bounds)
170
-
171
- // 热力图
172
- let heatmapLayer = new HeatmapOverlay({
173
- radius: 3,
174
- maxOpacity: 0.8,
175
- scaleRadius: true,
176
- useLocalExtrema: true,
177
- latField: "lat",
178
- lngField: "lng",
179
- valueField: "count"
180
- });
181
- map.addLayer(heatmapLayer);
182
- let heatmapData = []
183
- for (const arrayElement of data.playerCoordinateList) {
184
- let unprojected = map.unproject(mapConfig[data.mapType].calculateMapCoordinate(arrayElement[0], arrayElement[1]), 8);
185
- heatmapData.push({ lat: unprojected.lat, lng: unprojected.lng, count: 1 });
186
- }
187
- heatmapLayer.setData({
188
- min: 1,
189
- max: 5000,
190
- data: heatmapData
191
- })
192
-
193
- // 展示热门地区路况状态
194
- for (const traffic of data.trafficList) {
195
- document.getElementsByClassName('traffic-box')[0].insertAdjacentHTML('beforeend', `
196
- <div class="traffic-item">
197
- <span class="region-info"><strong>${traffic.country}</strong> ${traffic.province}</span><span class="player-count">${traffic.playerCount}人</span><span class="traffic-status" style="color: ${traffic.severity.color}">${traffic.severity.text}</span>
198
- </div>
199
- `);
200
- }
201
- }
202
- </script>
203
- </body>
204
- </html>
@@ -1,37 +0,0 @@
1
- const md5 = require('js-md5')
2
- const translateCache = require('../database/translateCache')
3
- const TRANSLATE_API = 'https://fanyi-api.baidu.com/api/trans/vip/translate'
4
-
5
- module.exports = async (ctx, cfg, content, cache = true) => {
6
- // 没有开启百度翻译功能,直接返回文本
7
- if (!cfg.baiduTranslateEnable) {
8
- return content
9
- }
10
-
11
- // 如果开启了缓存,尝试从缓存中查询翻译
12
- if (cfg.baiduTranslateCacheEnable && cache) {
13
- let translateContent = await translateCache.getTranslate(ctx.database, md5(content))
14
- if (translateContent) {
15
- return translateContent
16
- }
17
- }
18
-
19
- // 创建请求秘钥
20
- let randomInt = Math.floor(Math.random() * 10000)
21
- let sign = md5(cfg.baiduTranslateAppId + content + randomInt + cfg.baiduTranslateKey)
22
-
23
- // 调用请求
24
- let result = await ctx.http.get(`${TRANSLATE_API}?q=${encodeURI(content)}&from=auto&to=zh&appid=${cfg.baiduTranslateAppId}&salt=${randomInt}&sign=${sign}`);
25
-
26
- // 如果翻译失败,直接返回内容
27
- if (result.error_code) {
28
- return content
29
- }
30
-
31
- // 如果开启了缓存,将翻译内容缓存到数据库
32
- if (cfg.baiduTranslateCacheEnable && cache) {
33
- translateCache.save(ctx.database, md5(content), content, result.trans_result[0].dst)
34
- }
35
-
36
- return result.trans_result[0].dst
37
- }
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- sleep (ms) {
3
- return new Promise(resolve => setTimeout(resolve, ms));
4
- }
5
- }