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

8
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)
srv.DeleteCompany(uint8(ID64))
bot.SendChat(m.Chat.ID, "Deleting")
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")
}