Skip to content

Commit

Permalink
Beta30 (#57)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Hoshinonyaruko authored Jan 31, 2024
1 parent 5363e5b commit 53fbd1c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
24 changes: 19 additions & 5 deletions Broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"log"
"math/rand"
"net/http"
"net/url"
"strconv"
"time"

Expand All @@ -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)
Expand All @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.", // 默认的维护警告消息
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions front/palworld-front/src/pages/IndexView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
label="自定义证书key,放到同目录下"
class="q-my-md"
/>
<q-input
filled
v-model="config.address"
label="Rcon地址(只包含ip)大部分场景,默认127.0.0.1即可!"
class="q-my-md"
/>

<!-- 数字输入框 -->
<q-input
Expand Down

0 comments on commit 53fbd1c

Please sign in to comment.