update cron for tributes

This commit is contained in:
shoopea 2020-10-20 11:07:52 +02:00
parent bf4344e412
commit f792d2c1d2
3 changed files with 19 additions and 3 deletions

View File

@ -301,6 +301,22 @@ func clientMsgMeAck(m *ChatWarsMessageMeAck) {
}
}
func clientMsgGListAck(msg *ChatWarsMessageGListAck) {
muxClients.Lock()
for _, clt := range clients {
for _, m := range msg.Members {
clt.Mux.Lock()
if m.Name == clt.Nickname {
if m.Class2 == `⚔️` {
clt.CWClass2 = `Knight`
}
}
clt.Mux.Unlock()
}
}
muxClients.Unlock()
}
func clientMsgGoQuestAck(m *ChatWarsMessageGoQuestAck) {
if clt, ok := getLockedClient(m.Msg.TGUserID64, false); ok {
if clt.Active {

View File

@ -77,7 +77,7 @@ func cronTribute() {
muxClients.RLock()
for _, c := range clients {
if c.Active {
if c.CWClass == `Knight` {
if c.CWClass == `Knight` || c.CWClass2 == `Knight` {
clientSendCWMsgDelay(c.TGUserID64, `/tributes`, 0)
}
}

4
msg.go
View File

@ -472,7 +472,7 @@ func parseSubTypeMessageGListAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
cwm.Msg = m
cwm.Members = make([]ChatWarsGuildMember, 0)
log.Printf("parseSubTypeMessageGListAck : Guild : %s\n", r.ReplaceAllString(m.Text, "${GuildName}"))
//log.Printf("parseSubTypeMessageGListAck : Guild : %s\n", r.ReplaceAllString(m.Text, "${GuildName}"))
// log.Printf("parseSubTypeMessageGListAck : Members : %s\n", r.ReplaceAllString(m.Text, "${Members}"))
re := regexp.MustCompile(`\n#(?P<Id>[0-9]+) (?P<Class1>(⚒|⚗️|📦|🏹|⚔️|🛡))(?P<Class2>(⚒|⚗️|📦|🏹|⚔️|🛡){0,1})(?P<Level>[0-9]+) \[(?P<Status>.*)\] (?P<Name>[a-zA-z0-9 ]+)`)
@ -485,7 +485,7 @@ func parseSubTypeMessageGListAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWar
m.Status = re.ReplaceAllString(l, "${Status}")
i, _ := strconv.ParseInt(re.ReplaceAllString(l, "${Level}"), 10, 64)
m.Level = int(i)
log.Printf("parseSubTypeMessageGListAck : %s : %s/%s [%d] => %s\n", m.Name, m.Class1, m.Class2, m.Level, m.Status)
//log.Printf("parseSubTypeMessageGListAck : %s : %s/%s [%d] => %s\n", m.Name, m.Class1, m.Class2, m.Level, m.Status)
cwm.Members = append(cwm.Members, m)
}