add passwd
This commit is contained in:
21
bot.go
21
bot.go
@@ -59,6 +59,7 @@ func (b *Bot) BotHandlers() {
|
||||
b.bot.Handle("/players", botPlayers)
|
||||
b.bot.Handle("/give", botGive)
|
||||
b.bot.Handle("/take", botTake)
|
||||
b.bot.Handle("/passwd", botPasswd)
|
||||
|
||||
b.bot.Handle(tb.OnPhoto, botPhoto)
|
||||
b.bot.Handle(tb.OnChannelPost, botChannelPost)
|
||||
@@ -181,6 +182,26 @@ func botTake(m *tb.Message) {
|
||||
PrintText(m)
|
||||
}
|
||||
|
||||
func botPasswd(m *tb.Message) {
|
||||
cc, ok := cfg.Clients[m.Sender.ID]
|
||||
if !ok {
|
||||
bot.SendChat(m.Chat.ID, "User not registered.")
|
||||
return
|
||||
}
|
||||
r := regexp.MustCompile("^\\/register( )+(?P<Passwd>[.^\\ ]+)$")
|
||||
if r.MatchString(m.Text) {
|
||||
// we have a parameter
|
||||
passwd := r.ReplaceAllString(m.Text, "${Passwd}")
|
||||
cc.Passwd = passwd
|
||||
bot.SendUser(int64(m.Sender.ID), fmt.Sprintf("Passwd set to \"%s\"", passwd))
|
||||
err := bot.bot.Delete(m)
|
||||
logErrorDebug(err, "botPasswd : Delete")
|
||||
} else {
|
||||
bot.SendChat(m.Chat.ID, "No passwd provided")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func botDeregister(m *tb.Message) {
|
||||
cc, ok := cfg.Clients[m.Sender.ID]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user