From 4169b1f3e543391165e57edf441d904566322314 Mon Sep 17 00:00:00 2001 From: shoopea Date: Sat, 13 Nov 2021 13:56:55 +0800 Subject: [PATCH] update /say --- bot.go | 13 +++++++------ packet.go | 41 +++++++++++++++++++++-------------------- version.go | 8 ++++---- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/bot.go b/bot.go index a7bb328..73e5acc 100644 --- a/bot.go +++ b/bot.go @@ -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()) diff --git a/packet.go b/packet.go index e8db4eb..0124403 100644 --- a/packet.go +++ b/packet.go @@ -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) diff --git a/version.go b/version.go index 9e9d5a4..ca21441 100644 --- a/version.go +++ b/version.go @@ -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"