Skip to content

Calculate the time and words the user took to guess the Wordle from /share #981

@DTrombett

Description

@DTrombett
  1. We have no way to be notified when the user finished the Wordle
  2. We can keep track of the users currently playing as we already know when a user started
  3. The only way to be sure that a user completed the Wordle is by watching for /share commands
  4. When all the users currently playing leave the activity (not necessarily after completing!) the wordle message gets edited to use the past tense
  5. If a user does /share after leaving the activity we can use the time when he left as end time
  6. For convention we also allow users to send a "fast" message before share and that one should be used as end time if sent before at most 5 seconds the /share
  7. The Wordle message shows only the nickname and we can't reverse get the ID as nicknames are not unique
  8. When the Wordle message gets edited to use the past tense we can set a possibleEndTime field to the edited timestamp for all the currently playing users and users which username is in the message
  9. We need to keep track of the currently playing users in KV using a new field wordlePlayingUsers
  10. When a user does /share we can:
    1. Get the wordle data about the user id from the KV, aborting if it's present, is complete and is of the current day
    2. Fetch the member to get the nickname
    3. Get the wordle data about the nickname from the KV
    4. Choose an end time for the user as follow:
      • Fetch the last messages from the channel and find the least recent one sent by user and edited or created within 5 seconds from the share
      • Choose the min between the message edited/created timestamp and possibleEndTime
      • If none is present, use the share timestamp
    5. Send a message in the channel like <@{userId}> ({nickname}) ha completato il Wordle {startTime & "in {endTime - startTime} "}(reason: {"left activity at {endTime}" | "message {id}" | "share"})
    6. Put the data with words, end time and start time in the KV paired with the ID

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions