]> Sergey Matveev's repositories - mmc.git/commitdiff
Forcefully update all user statuses
authorSergey Matveev <stargrave@stargrave.org>
Sun, 12 Mar 2023 18:09:52 +0000 (21:09 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 12 Mar 2023 18:15:56 +0000 (21:15 +0300)
cmd/mmc/main.go
cmd/start

index 12eb7df3bdcc4166d357dfe803bfac874da43ec4..c4ac2d57d3b1f21f9f5a0bcfd8aa5ad02ebf68f7 100644 (file)
@@ -230,7 +230,7 @@ func main() {
        }
 
        UserStatus := make(map[string]string)
-       if *userStatusFifo != "" {
+       updateUserStatus := func() {
                statuses, resp, err := c.GetUsersStatusesByIds(userIds)
                if err != nil {
                        if DebugFd != nil {
@@ -241,11 +241,12 @@ func main() {
                if DebugFd != nil {
                        spew.Fdump(DebugFd, teams)
                }
-               userIds = nil
                for _, s := range statuses {
                        UserStatus[Users[s.UserId].Username] = s.Status
                }
-               statuses = nil
+       }
+       if *userStatusFifo != "" {
+               updateUserStatus()
                go func() {
                        for {
                                time.Sleep(mmc.SleepTime)
@@ -482,6 +483,7 @@ func main() {
                for {
                        select {
                        case <-t.C:
+                               updateUserStatus()
                                if time.Now().Before(LastSent.Add(time.Minute)) {
                                        continue
                                }
index caae3fa4689d6df9e1079bff850851f42736f52b..52e6c00810f33a88af4245625988b7e161367294 100755 (executable)
--- a/cmd/start
+++ b/cmd/start
@@ -12,6 +12,6 @@ mkfifo debug users/status
     -e "s#CATFILE#$cmd/catfile#" \
     -e "s#DLPANE#$cmd/dlpane#" < "$cmd"/tmux.conf > tmux.conf
 $TMUX -f tmux.conf new-session -d -n ROOT -s mmc "cat debug | tai64n | tai64nlocal"
-$TMUX split-window -h 'while : ; do cat users/status | spc -e grn,"^O:.*" -e cya,"^A:.*" ; sleep 5 ; clear ; done'
+$TMUX split-window -h 'while : ; do cat users/status | spc -e grn,"^O:.*" -e cya,"^A:.*" ; sleep 30 ; clear ; done'
 $TMUX split-window -v "$cmd/mmc/mmc -debug debug -user-status users/status -newwin $cmd/newwin -notify $cmd/notify | tai64n | tai64nlocal"
 $TMUX attach-session