Skip to content

Commit 9feb114

Browse files
authored
添加仅接受付费排队功能
1 parent 1038594 commit 9feb114

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

Config.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ type 配置文件 struct {
2020
PsC string
2121
LineKey string
2222
PPs string
23+
IsOnlyGift int
24+
Ppps string
2325
}
2426

25-
func GetConfig() (Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePrice float64, CommonPrintColor int, Linekey string) {
27+
func GetConfig() (Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePrice float64, CommonPrintColor int, Linekey string, IsOnlyGift int) {
2628
lineupConfigFile := "./lineupConfig.json"
2729
Configinfo, OpenErr := os.Open(lineupConfigFile)
2830
if OpenErr != nil {
@@ -40,13 +42,13 @@ func GetConfig() (Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePr
4042
if err != nil {
4143
return
4244
}
43-
return ConfigSetGet.RoomId, ConfigSetGet.GuardPrintColor, ConfigSetGet.GiftPrintColor, ConfigSetGet.GiftLinePrice, ConfigSetGet.CommonPrintColor, ConfigSetGet.LineKey
45+
return ConfigSetGet.RoomId, ConfigSetGet.GuardPrintColor, ConfigSetGet.GiftPrintColor, ConfigSetGet.GiftLinePrice, ConfigSetGet.CommonPrintColor, ConfigSetGet.LineKey, ConfigSetGet.IsOnlyGift
4446
}
4547
}
4648
return
4749
}
4850

49-
func SetConfig(Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePrice float64, CommonPrintColor int, Linekey string) bool {
51+
func SetConfig(Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePrice float64, CommonPrintColor int, Linekey string, IsOnlyGift int) bool {
5052
ConfigJsonType := 配置文件{
5153
RoomId: Roomid,
5254
Ps: "上面这个是房间号",
@@ -60,6 +62,8 @@ func SetConfig(Roomid string, GuardPrintColor, GiftPrintColor int, GiftLinePrice
6062
PsC: "上面这个是普通用户打印颜色",
6163
LineKey: Linekey,
6264
PPs: "上面这个是排队关键词",
65+
IsOnlyGift: IsOnlyGift,
66+
Ppps: "上面这个是仅限礼物以及舰长",
6367
}
6468
ConfigJson, _ := json.MarshalIndent(ConfigJsonType, "", " ")
6569
fmt.Println(string(ConfigJson))

main.go

+15-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ func main() {
2020
var SelectLine int
2121
KeyBordString := make(chan string, 1)
2222

23-
RoomId, GuardPrintColor, GiftPrintColor, GiftLinePrice, CommonPrintColor, Linekey := GetConfig()
23+
//IsOnlyGift := 0
24+
25+
RoomId, GuardPrintColor, GiftPrintColor, GiftLinePrice, CommonPrintColor, Linekey, IsOnlyGift := GetConfig()
2426

2527
if len(RoomId) < 1 || GuardPrintColor < 1 || GiftPrintColor < 1 || GiftLinePrice < 0.01 || CommonPrintColor < 1 || len(Linekey) < 1 {
2628
RoomId = "2233"
@@ -35,6 +37,8 @@ func main() {
3537
if len(Linekey) == 0 {
3638
Linekey = "排队"
3739
}
40+
fmt.Println("是否开启仅限礼物及舰长排队(开启后只有礼物用户及舰长会加入队列)输入1启用")
41+
_, _ = fmt.Scanln(&IsOnlyGift)
3842
fmt.Println("自定义颜色编号")
3943
for i := 1; i < 7; i++ {
4044
ColorPrint("这是测试字符"+" "+"编号"+strconv.Itoa(i), i)
@@ -63,9 +67,9 @@ func main() {
6367
fmt.Println("请输入普通队列颜色[编号]")
6468
_, _ = fmt.Scanln(&CommonPrintColor)
6569
}
66-
fmt.Println("请输入礼物队列触发价格(RMB),只有单次礼物大于此价格才会被加入")
70+
fmt.Println("请输入礼物队列触发价格(RMB),只有单次或累计礼物大于此价格才会被加入")
6771
_, _ = fmt.Scanln(&GiftLinePrice)
68-
if SetConfig(RoomId, GuardPrintColor, GiftPrintColor, GiftLinePrice, CommonPrintColor, Linekey) {
72+
if SetConfig(RoomId, GuardPrintColor, GiftPrintColor, GiftLinePrice, CommonPrintColor, Linekey, IsOnlyGift) {
6973
fmt.Println("配置信息已保存,下次启动将自动读取")
7074
} else {
7175
fmt.Println("配置文件保存失败")
@@ -151,12 +155,14 @@ func main() {
151155
})
152156
lineup.GuardLine = removeRepeatElement(lineup.GuardLine)
153157
} else {
154-
lineup.CommonLine = append(lineup.CommonLine, &Line{
155-
Uid: danmaku.Sender.Uid,
156-
UserName: danmaku.Sender.Uname,
157-
PrintColor: CommonPrintColor,
158-
})
159-
lineup.CommonLine = removeRepeatElement(lineup.CommonLine)
158+
if IsOnlyGift != 1 {
159+
lineup.CommonLine = append(lineup.CommonLine, &Line{
160+
Uid: danmaku.Sender.Uid,
161+
UserName: danmaku.Sender.Uname,
162+
PrintColor: CommonPrintColor,
163+
})
164+
lineup.CommonLine = removeRepeatElement(lineup.CommonLine)
165+
}
160166
}
161167
SetLine(lineup)
162168

0 commit comments

Comments
 (0)