add remove
This commit is contained in:
parent
86f29143fa
commit
564e0786b9
21
bot.go
21
bot.go
@ -97,6 +97,7 @@ func (b *Bot) BotHandlers() {
|
||||
b.bot.Handle("/ready", botReady)
|
||||
b.bot.Handle("/start", botStart)
|
||||
b.bot.Handle("/players", botPlayers)
|
||||
b.bot.Handle("/remove", botRemove)
|
||||
|
||||
b.bot.Handle("/give", botGive)
|
||||
b.bot.Handle("/take", botTake)
|
||||
@ -514,6 +515,26 @@ func botPlayers(m *tb.Message) {
|
||||
return
|
||||
}
|
||||
|
||||
func botRemove(m *tb.Message) {
|
||||
if m.Sender.ID != int(cfg.Telegram.AdminID) {
|
||||
bot.SendChat(m.Chat.ID, "Only the admin can use this command.")
|
||||
return
|
||||
}
|
||||
|
||||
r := regexp.MustCompile("^\\/remove (?P<Username>[a-zA-Z0-9]+)")
|
||||
|
||||
for _, cc := range cfg.Clients {
|
||||
if cc.Username == r.ReplaceAllString(m.Text, "${Username}") {
|
||||
delete(cfg.Clients, cc.UserID)
|
||||
bot.SendChat(m.Chat.ID, fmt.Sprintf("%s deleted.", cc.Username))
|
||||
return
|
||||
}
|
||||
}
|
||||
bot.SendChat(m.Chat.ID, "No such player.")
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func botPlayersStarted(m *tb.Message) {
|
||||
d1 := time.Now().Sub(cfg.Game.StartDate)
|
||||
days := int(time.Duration(d1.Hours()) / 24)
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||
package main
|
||||
var githash = "f21a8e5"
|
||||
var buildstamp = "2021-12-12_06:30:54"
|
||||
var commits = "257"
|
||||
var version = "f21a8e5-b257 - 2021-12-12_06:30:54"
|
||||
var githash = "86f2914"
|
||||
var buildstamp = "2021-12-28_15:02:08"
|
||||
var commits = "258"
|
||||
var version = "86f2914-b258 - 2021-12-28_15:02:08"
|
||||
|
Loading…
x
Reference in New Issue
Block a user