update delete

This commit is contained in:
shoopea 2021-11-12 09:17:25 +08:00
parent caba808d8b
commit 24bf4dc386
3 changed files with 12 additions and 8 deletions

4
bot.go
View File

@ -121,8 +121,12 @@ func botDelete(m *tb.Message) {
if m.Sender.ID == int(bot.Config.AdminID) {
r := regexp.MustCompile("/delete (?P<CompanyID>[0-9]+)")
ID64, _ := strconv.ParseInt(r.ReplaceAllString(m.Text, "${CompanyID}"), 10, 64)
if _, ok := srv.Status.Companies[uint8(ID64)]; ok {
srv.DeleteCompany(uint8(ID64))
bot.SendChat(m.Chat.ID, "Deleting")
} else {
bot.SendChat(m.Chat.ID, "Company doesn't exist")
}
} else {
bot.SendChat(m.Chat.ID, "Not authorized to delete")
}

4
ttd.go
View File

@ -624,11 +624,11 @@ func (s *ServerTTD) ComputeClientTime() {
}
func (s *ServerTTD) DeleteCompany(id uint8) {
if _, ok := s.Status.Companies[id]; ok {
if co, ok := s.Status.Companies[id]; ok {
logInfoDebug("Server.DeleteCompany : deleting #%d", id)
px := PacketAdminRCon{
Packet: Packet{PType: AdminPacketAdminRCon},
Command: fmt.Sprintf("reset_company %d", id),
Command: fmt.Sprintf("reset_company %d", co.CompanyExtlID),
}
s.Send(px.Bytes())
px = PacketAdminRCon{

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "0d5c94e"
var buildstamp = "2021-11-10_07:04:16"
var commits = "187"
var version = "0d5c94e-b187 - 2021-11-10_07:04:16"
var githash = "caba808"
var buildstamp = "2021-11-12_01:17:14"
var commits = "188"
var version = "caba808-b188 - 2021-11-12_01:17:14"