update
This commit is contained in:
parent
4772cd7f71
commit
e185eff578
29
bot.go
29
bot.go
@ -188,17 +188,32 @@ func botPasswd(m *tb.Message) {
|
||||
bot.SendChat(m.Chat.ID, "User not registered.")
|
||||
return
|
||||
}
|
||||
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) {
|
||||
if !r.MatchString(m.Text) {
|
||||
bot.SendChat(m.Chat.ID, "No passwd provided")
|
||||
return
|
||||
}
|
||||
// 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))
|
||||
cc.Passwd = r.ReplaceAllString(m.Text, "${Passwd}")
|
||||
|
||||
err := bot.bot.Delete(m)
|
||||
logErrorDebug(err, "botPasswd : Delete")
|
||||
} else {
|
||||
bot.SendChat(m.Chat.ID, "No passwd provided")
|
||||
}
|
||||
|
||||
srv.SetPasswd(co.CompanyID, cc.Passwd)
|
||||
|
||||
bot.SendUser(int64(m.Sender.ID), fmt.Sprintf("Passwd set to \"%s\"", cc.Passwd))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
10
ttd.go
10
ttd.go
@ -735,3 +735,13 @@ func (s *ServerTTD) Initialize() {
|
||||
s.UpdateCompanies()
|
||||
s.UpdateClients()
|
||||
}
|
||||
|
||||
func (s *ServerTTD) SetPasswd(id uint8, passwd string) {
|
||||
px := PacketAdminRCon{
|
||||
Packet: Packet{PType: AdminPacketAdminRCon},
|
||||
Command: fmt.Sprintf("company_pw %d %s", id, passwd),
|
||||
}
|
||||
err := s.Send(px.Bytes())
|
||||
logErrorDebug(err, "Server.SetPasswd() : Send(AdminPacketAdminRCon)")
|
||||
return
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by version.sh (@generated) DO NOT EDIT.
|
||||
package main
|
||||
var githash = "8d58018"
|
||||
var buildstamp = "2021-11-10_04:56:39"
|
||||
var commits = "177"
|
||||
var version = "8d58018-b177 - 2021-11-10_04:56:39"
|
||||
var githash = "4772cd7"
|
||||
var buildstamp = "2021-11-10_05:41:24"
|
||||
var commits = "179"
|
||||
var version = "4772cd7-b179 - 2021-11-10_05:41:24"
|
||||
|
Loading…
Reference in New Issue
Block a user