Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an AFK timer #5002

Merged
merged 49 commits into from
Jun 30, 2019
Merged

Add an AFK timer #5002

merged 49 commits into from
Jun 30, 2019

Conversation

Asheviere
Copy link
Contributor

No description provided.

users.js Outdated Show resolved Hide resolved
users.js Outdated Show resolved Hide resolved
@Zarel Zarel force-pushed the master branch 3 times, most recently from c8b321b to d90ac63 Compare December 2, 2018 01:30
@Zarel Zarel force-pushed the master branch 2 times, most recently from 8091982 to 93a76f9 Compare February 21, 2019 08:03
@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 3, 2019 via email

@scheibo
Copy link
Contributor

scheibo commented Apr 3, 2019

Did some more thinking/research on this - I think what we (I?) really want is /away.

https://bisqwit.iki.fi/jutut/away.html has some good arguments against the pre|AFK 'away nick' @Zarel suggested. I think it would be useful if we added an /away command to toggle an 'away' state for a user (I don't know if we'd want to actually support /away messages, because they could potentially be inappropriate). The server can automatically set /away for a user based on inactivity (this change).

My ideal design:

  • when a user is /away, their name turns gray and they are sorted to the bottom of the room's user list, but they keep their rank, and clicking on their grayed out name shows a tag/indicator that they are away/AFK.
  • if the server detects a user as inactive they can set them to the /away state
  • I can manually set /away on my desktop without waiting for the server to timeout my client
  • a user can leave the /away state by using the /away command again, or if a user makes a non-passive action (replies publicly in chat, makes an action in battle/starts a challenge etc. simply joining a room or battle as an observer should not alter the away state IMO, neither should something like /help or /dt etc).

I'd want to get some consensus here though, and its a broader change than what you originally envisioned in this PR.

@Zarel
Copy link
Member

Zarel commented Apr 3, 2019

Your link is for IRC, and there's no reason we'd have to carry over the flaws mentioned in that article.

Also, my suggestion of |AFK was purely protocol-level; I definitely don't want it to be a literal name change.

Anyway, your outline matches my vision, except /back is the command to remove the away state, and the away state is set by /away with or without any description.

@scheibo
Copy link
Contributor

scheibo commented Apr 3, 2019

Gotcha. Works for me! @bumbadadabum - LMK if what I laid out is out of scope for what you were planning to do when you get back (no rush!) and I will take on anything you're not interested in :)

@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 3, 2019 via email

@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 3, 2019 via email

@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 10, 2019

Talked to pre and this is how we plan to implement the protocol for the away state:

For broadcasting to chatrooms: |a|username when a user is marked as away and |b|username when the user is back. We considered putting this into |n| but that would break the format of that protocol message, which would mess with bots.

When a user joins a room, users marked as away will have a ` at the end of their username in the |users| part of the |init| message. We thought ` made the most sense, as it is not allowed in usernames, and using pipes would make the whole message hell to parse. This seemed like the most compact way to indicate people being AFK in this message while retaining backwards compatibility.

Of course, it should also show up on /query userdetails but this uses JSON and would be trivial to add this to.

The final point is whether we show this to users in the top right. My idea for making that work is to change the NAMED field in the |updateuser| to be 0 if a user is a guest, 1 if a user is named, and 2 if a user is away. This still allowed boolean checks for named to work as they did before, while adding an easy way to check whether the user got marked as away without looking at chatrooms.

@scheibo
Copy link
Contributor

scheibo commented Apr 11, 2019

As for the client side, I think I need to:

  • change the parsing logic to understand the ` and, and this.users needs to store not just the name string but also away status. I assume we'd want to parse the away state out of the ID as soon as possible, but then we're stuck passing the two together everywhere, like to UserList.add etc. It would make more sense to have a User object to pass around/store in this.users, but I don't think we have the full details for that, just the ID + away bit pair?
  • observe |a| and |b| in the same way we do joins and leaves (which brings up the question - will we want |A| & |B| along with |a|& |b| and |away| & |back|? How frequent do we expect away to occur?
  • change the color in constructItem. Ideally I'd be able to add an 'away' class or something similar the the li, but because the color is an inline style it wouldn't apply thanks to cascade rules so I'd need apply it inline as well.
  • change the comparator logic to sort away users at the bottom (though still staff above regular users etc)

Probably missing some things, but thats my initial guess at what might be required (I might also need to make some changes for away in non-ChatRooms? Like for when an away user is spectating a battle?). I'd actually probably update the Preact client at the same time, because the code looks to already be there as well and be pretty much identical.

@Zarel
Copy link
Member

Zarel commented Apr 11, 2019

I don't like |a| and |b|; I think |n| should work fine.

I don't like the ` sigil. | shouldn't require that much parsing complexity.

@Zarel
Copy link
Member

Zarel commented Apr 11, 2019

@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 11, 2019 via email

@Zarel
Copy link
Member

Zarel commented Apr 11, 2019

PS already requires parsing variable amounts of pipes. I linked to the modern way this is achieved in client.

I would probably make the AFK state the third argument of |n|.

@Asheviere
Copy link
Contributor Author

Asheviere commented Apr 11, 2019 via email

@Asheviere
Copy link
Contributor Author

Ok talked to Zarel, he wants @ to be banned from usernames, and we could use that in the |init| message.

@Asheviere
Copy link
Contributor Author

Ok implemented the new protocol.

PROTOCOL.md Outdated Show resolved Hide resolved
server/users.js Outdated Show resolved Hide resolved
server/users.js Outdated Show resolved Hide resolved
server/chat-commands.js Outdated Show resolved Hide resolved
server/chat-commands.js Outdated Show resolved Hide resolved
PROTOCOL.md Outdated Show resolved Hide resolved
@smogon smogon deleted a comment from TravisBuddy Apr 11, 2019
Copy link
Contributor

@scheibo scheibo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this again locally and took another pass over the code (previously I'd only be reviewing it as it updated). I'm pretty confident this is good to go. Let's ship!

Copy link
Member

@Zarel Zarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I approved this before but it's not showing up?

Copy link
Member

@HoeenCoder HoeenCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great job guys!

server/users.js Outdated Show resolved Hide resolved
QuiteQuiet added a commit to QuiteQuiet/PokemonShowdownBot that referenced this pull request Jun 29, 2019
QuiteQuiet added a commit to QuiteQuiet/PokemonShowdownBot that referenced this pull request Jun 29, 2019
@Asheviere Asheviere merged commit ed5d534 into smogon:master Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants