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}")
px := PacketAdminChat{
Packet: Packet{PType: AdminPacketAdminChat},
ActionType: AdminNetworkActionChat,
DestinationType: AdminDestinationTypeBroadcast,
DestinationID: 0,
Message: msg,
px := PacketServerChat{
Packet: Packet{PType: AdminPacketServerChat},
ActionID: AdminNetworkActionChat,
DestinationID: AdminDestinationTypeBroadcast,
ClientID: 0,
Message: msg,
Amount: 0,
}
srv.Send(px.Bytes())

View File

@ -95,11 +95,6 @@ type PacketAdminJoin struct {
AppVersion string
}
type PacketAdminRCon struct {
Packet
Command string
}
type PacketAdminChat struct {
Packet
ActionType uint8
@ -108,6 +103,11 @@ type PacketAdminChat struct {
Message string
}
type PacketAdminRCon struct {
Packet
Command string
}
type PacketServerProtocol struct {
Packet
ProtocolVersion uint8
@ -265,21 +265,6 @@ func (p *PacketAdminRCon) Bytes() []byte {
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 {
buf := new(bytes.Buffer)
p.PLength = 7
@ -520,6 +505,22 @@ func (p *PacketServerChat) Read(b []byte) {
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) {
r := bufio.NewReader(bytes.NewReader(b))
r.Discard(3)

View File

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