update /say

This commit is contained in:
shoopea 2021-11-13 13:56:55 +08:00
parent 40a0b5e800
commit 4169b1f3e5
3 changed files with 32 additions and 30 deletions

13
bot.go
View File

@ -309,12 +309,13 @@ func botSay(m *tb.Message) {
msg := r.ReplaceAllString(m.Text, "${Message}") msg := r.ReplaceAllString(m.Text, "${Message}")
px := PacketAdminChat{ px := PacketServerChat{
Packet: Packet{PType: AdminPacketAdminChat}, Packet: Packet{PType: AdminPacketServerChat},
ActionType: AdminNetworkActionChat, ActionID: AdminNetworkActionChat,
DestinationType: AdminDestinationTypeBroadcast, DestinationID: AdminDestinationTypeBroadcast,
DestinationID: 0, ClientID: 0,
Message: msg, Message: msg,
Amount: 0,
} }
srv.Send(px.Bytes()) srv.Send(px.Bytes())

View File

@ -95,11 +95,6 @@ type PacketAdminJoin struct {
AppVersion string AppVersion string
} }
type PacketAdminRCon struct {
Packet
Command string
}
type PacketAdminChat struct { type PacketAdminChat struct {
Packet Packet
ActionType uint8 ActionType uint8
@ -108,6 +103,11 @@ type PacketAdminChat struct {
Message string Message string
} }
type PacketAdminRCon struct {
Packet
Command string
}
type PacketServerProtocol struct { type PacketServerProtocol struct {
Packet Packet
ProtocolVersion uint8 ProtocolVersion uint8
@ -265,21 +265,6 @@ func (p *PacketAdminRCon) Bytes() []byte {
return buf.Bytes() return buf.Bytes()
} }
func (p *PacketAdminChat) Bytes() []byte {
buf := new(bytes.Buffer)
p.PLength = uint16(len(p.Message) + 10)
binary.Write(buf, binary.LittleEndian, p.PLength)
binary.Write(buf, binary.LittleEndian, p.ActionType)
binary.Write(buf, binary.LittleEndian, p.DestinationType)
binary.Write(buf, binary.LittleEndian, p.DestinationID)
buf.WriteString(p.Message)
buf.WriteByte(0)
return buf.Bytes()
}
func (p *PacketAdminUpdateFrequency) Bytes() []byte { func (p *PacketAdminUpdateFrequency) Bytes() []byte {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
p.PLength = 7 p.PLength = 7
@ -520,6 +505,22 @@ func (p *PacketServerChat) Read(b []byte) {
p.Amount = binary.LittleEndian.Uint64(bs[0:]) p.Amount = binary.LittleEndian.Uint64(bs[0:])
} }
func (p *PacketServerChat) Bytes() []byte {
buf := new(bytes.Buffer)
p.PLength = uint16(len(p.Message) + 17)
binary.Write(buf, binary.LittleEndian, p.PLength)
binary.Write(buf, binary.LittleEndian, p.ActionID)
binary.Write(buf, binary.LittleEndian, p.DestinationID)
binary.Write(buf, binary.LittleEndian, p.ClientID)
buf.WriteString(p.Message)
buf.WriteByte(0)
binary.Write(buf, binary.LittleEndian, p.Amount)
return buf.Bytes()
}
func (p *PacketServerConsole) Read(b []byte) { func (p *PacketServerConsole) Read(b []byte) {
r := bufio.NewReader(bytes.NewReader(b)) r := bufio.NewReader(bytes.NewReader(b))
r.Discard(3) r.Discard(3)

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT. // Code generated by version.sh (@generated) DO NOT EDIT.
package main package main
var githash = "bb1a7d0" var githash = "40a0b5e"
var buildstamp = "2021-11-13_05:44:46" var buildstamp = "2021-11-13_05:56:40"
var commits = "193" var commits = "194"
var version = "bb1a7d0-b193 - 2021-11-13_05:44:46" var version = "40a0b5e-b194 - 2021-11-13_05:56:40"