From 5363e5b85fbc1ab7475f9c11969dc55aa67aa9c9 Mon Sep 17 00:00:00 2001
From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com>
Date: Wed, 31 Jan 2024 17:55:32 +0800
Subject: [PATCH 1/2] Beta29 (#53)
* beta9
* beta11
* beta11
* beta13
* beta12
* beta13
* beta15
* beta16
* beta17
* beta18
* beta19
* beta20
* beta21
* add_playermanager_api
* beta22
* beta23
* beta24
* beta25
* beta26
* beta27
* beta28
* beta28
* beta29
---
rconclient.go | 2 +-
tool/rcon.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/rconclient.go b/rconclient.go
index 8200819..b584d98 100644
--- a/rconclient.go
+++ b/rconclient.go
@@ -62,7 +62,7 @@ func HandleMemoryUsage(threshold float64, RconClient *RconClient, config config.
if config.UseDll {
// 构建请求的URL
base := "http://127.0.0.1:53000/rcon?text="
- message := "broadcast " + url.QueryEscape(config.MaintenanceWarningMessage)
+ message := url.QueryEscape("broadcast " + config.MaintenanceWarningMessage)
fullURL := base + message
// 发送HTTP请求
diff --git a/tool/rcon.go b/tool/rcon.go
index ff1d9a5..e3f0f85 100644
--- a/tool/rcon.go
+++ b/tool/rcon.go
@@ -124,7 +124,7 @@ func Broadcast(config config.Config, message string) error {
// 如果config.Usedll为true,则使用HTTP方式发送消息
if config.UseDll {
base := "http://127.0.0.1:53000/rcon?text="
- messageText := "broadcast " + url.QueryEscape(message)
+ messageText := url.QueryEscape("broadcast " + message)
fullURL := base + messageText
// 发送HTTP请求
From 53fbd1cf93cdf8a82e6865bd6b974a81447871e3 Mon Sep 17 00:00:00 2001
From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com>
Date: Wed, 31 Jan 2024 21:35:20 +0800
Subject: [PATCH 2/2] Beta30 (#57)
* beta9
* beta11
* beta11
* beta13
* beta12
* beta13
* beta15
* beta16
* beta17
* beta18
* beta19
* beta20
* beta21
* add_playermanager_api
* beta22
* beta23
* beta24
* beta25
* beta26
* beta27
* beta28
* beta28
* beta29
* beta30
---
Broadcast.go | 24 ++++++++++++++++----
config/config.go | 4 ++--
front/palworld-front/src/pages/IndexView.vue | 6 +++++
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/Broadcast.go b/Broadcast.go
index a615e87..296706e 100644
--- a/Broadcast.go
+++ b/Broadcast.go
@@ -3,6 +3,8 @@ package main
import (
"log"
"math/rand"
+ "net/http"
+ "net/url"
"strconv"
"time"
@@ -29,7 +31,7 @@ func (task *palworldBroadcast) Schedule() {
}
func (task *palworldBroadcast) RunpalworldBroadcast() {
- log.Println("准备进行全服推送...由于帕鲁暂未支持中文,仅支持英文")
+ log.Println("准备进行全服推送...现已支持所有语言broadcast!")
// 初始化RCON客户端
address := task.Config.Address + ":" + strconv.Itoa(task.Config.WorldSettings.RconPort)
rconClient := NewRconClient(address, task.Config.WorldSettings.AdminPassword, task.BackupTask)
@@ -45,11 +47,23 @@ func (task *palworldBroadcast) RunpalworldBroadcast() {
// 获取随机选择的消息
randomMessage := task.Config.RegularMessages[randomIndex]
- // 如果只有一个消息,则使用它
- if len(task.Config.RegularMessages) == 1 {
- Broadcast(randomMessage, rconClient)
+ // 根据task.Config.UseDLL来决定发送方式
+ if task.Config.UseDll {
+ // 使用HTTP请求发送消息
+ base := "http://127.0.0.1:53000/rcon?text="
+ messageText := url.QueryEscape("broadcast " + randomMessage)
+ fullURL := base + messageText
+
+ resp, err := http.Get(fullURL)
+ if err != nil {
+ log.Printf("Error sending HTTP request: %v", err)
+ } else {
+ defer resp.Body.Close()
+ // 这里可以添加对resp的处理逻辑
+ log.Println("Broadcast message sent successfully via HTTP")
+ }
} else {
- // 使用随机选择的消息作为参数调用Broadcast
+ // 使用Broadcast函数发送消息
Broadcast(randomMessage, rconClient)
}
}
diff --git a/config/config.go b/config/config.go
index 3f77aec..f59a26b 100644
--- a/config/config.go
+++ b/config/config.go
@@ -80,7 +80,7 @@ var defaultConfig = Config{
TotalMemoryGB: 16, // 16G
MemoryCleanupInterval: 1800, // 内存清理时间间隔,设为半小时(1800秒)0代表不清理
RestartInterval: 0, // 自动重启间隔
- WhiteCheckTime: 0, //白名单检查周期
+ WhiteCheckTime: 0, // 白名单检查周期
RegularMessages: []string{"", ""}, // 默认的定期推送消息数组,初始可为空
MessageBroadcastInterval: 3600, // 默认消息广播周期,假设为1小时(3600秒)
MaintenanceWarningMessage: "server is going to rebot,please relogin at 1minute later.", // 默认的维护警告消息
@@ -291,7 +291,7 @@ func checkAndSetDefaults(config *Config) bool {
fieldName := typ.Field(i).Name
// 特殊处理RestartInterval字段
- if fieldName == "RestartInterval" || fieldName == "WhiteCheckTime" {
+ if fieldName == "RestartInterval" || fieldName == "WhiteCheckTime" || fieldName == "MemoryCleanupInterval" || fieldName == "BackupInterval" || fieldName == "MemoryCheckInterval" {
continue
}
diff --git a/front/palworld-front/src/pages/IndexView.vue b/front/palworld-front/src/pages/IndexView.vue
index d33bdeb..c86d0ef 100644
--- a/front/palworld-front/src/pages/IndexView.vue
+++ b/front/palworld-front/src/pages/IndexView.vue
@@ -100,6 +100,12 @@
label="自定义证书key,放到同目录下"
class="q-my-md"
/>
+