update
This commit is contained in:
35
bot.go
35
bot.go
@@ -188,17 +188,32 @@ func botPasswd(m *tb.Message) {
|
||||
bot.SendChat(m.Chat.ID, "User not registered.")
|
||||
return
|
||||
}
|
||||
r := regexp.MustCompile("^\\/passwd( )+(?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")
|
||||
if cc.CompanyID == 255 {
|
||||
bot.SendChat(m.Chat.ID, "No company registered.")
|
||||
return
|
||||
}
|
||||
co, ok := srv.Status.Companies[cc.CompanyID]
|
||||
if !ok {
|
||||
bot.SendChat(m.Chat.ID, "Registered company doesn't exist.")
|
||||
cc.CompanyID = 255
|
||||
return
|
||||
}
|
||||
|
||||
r := regexp.MustCompile("^\\/passwd( )+(?P<Passwd>[^ ]+)$")
|
||||
if !r.MatchString(m.Text) {
|
||||
bot.SendChat(m.Chat.ID, "No passwd provided")
|
||||
return
|
||||
}
|
||||
// we have a parameter
|
||||
cc.Passwd = r.ReplaceAllString(m.Text, "${Passwd}")
|
||||
|
||||
err := bot.bot.Delete(m)
|
||||
logErrorDebug(err, "botPasswd : Delete")
|
||||
|
||||
srv.SetPasswd(co.CompanyID, cc.Passwd)
|
||||
|
||||
bot.SendUser(int64(m.Sender.ID), fmt.Sprintf("Passwd set to \"%s\"", cc.Passwd))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user