You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have no way to be notified when the user finished the Wordle
We can keep track of the users currently playing as we already know when a user started
The only way to be sure that a user completed the Wordle is by watching for /share commands
When all the users currently playing leave the activity (not necessarily after completing!) the wordle message gets edited to use the past tense
If a user does /share after leaving the activity we can use the time when he left as end time
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
The Wordle message shows only the nickname and we can't reverse get the ID as nicknames are not unique
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
We need to keep track of the currently playing users in KV using a new field wordlePlayingUsers
When a user does /share we can:
Get the wordle data about the user id from the KV, aborting if it's present, is complete and is of the current day
Fetch the member to get the nickname
Get the wordle data about the nickname from the KV
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
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"})
Put the data with words, end time and start time in the KV paired with the ID
<@{userId}> ({nickname}) ha completato il Wordle {startTime & "in {endTime - startTime} "}(reason: {"left activity at {endTime}" | "message {id}" | "share"})