JonnyPtn / zomboi

A discord bot for project zomboid multiplayer servers
49 stars 32 forks source link

!users not reflecting real users playing #68

Closed hernandocav closed 1 year ago

hernandocav commented 1 year ago

i dont know how to explain this.. but basically, when i type !users command on discord, the users list, is higher than the users playing on server, this always happens in morning, when theres only 2 users playing, and the discord list something like 23:00 PLUS the users playing now, i would like to know how can i gather log information to send to you

JonnyPtn commented 1 year ago

This is kind of expected behaviour - It doesn't just show the online players, it shows all players detected in the log files. Look at the "Online" column of the output to know whether they are currently online or not

hernandocav commented 1 year ago

@JonnyPtn well just to clarify more i discover that in users.py `´´´

    if "disconnected" in message:
        matches = re.search(r"\"(.*)\".*\((\d+),(\d+),\d+\)", message)
        name = matches.group(1)
        user = self.getUser(name)
        if timestamp > user.lastSeen:
            user.online = False
            user.lastSeen = timestamp
            user.lastLocation = (matches.group(2), matches.group(3))
        if timestamp > self.lastUpdateTimestamp:
            self.bot.log.info(f"{user.name} disconnected")
            if self.notifyDisconnect:
                return f":person_running: {user.name} has left"

` in line 126, the second if, hes not performing this, all users stays online with that column 'online' marked YES, so i removed this if under, and the original behaviour returns showing only the online users