ToransuShoujo / quesoqueue_plus

A queue system for Mario Maker 2
GNU General Public License v3.0
5 stars 3 forks source link

!rename command and store user id #7

Open liquidnya opened 2 years ago

liquidnya commented 2 years ago

A !rename command might be practical if the queue is not cleared between streams. A user's username or display name (or both) could change and that may lead to some issues.

liquidnya commented 2 years ago

Commands, that check the queue for someones level, e.g. !add (to prevent submitting 2 or more levels), !replace, !position, !list (if the current user is present in that short list of levels), !odds, ... (command list might not be complete) could also rename users automatically if possible. Automatically means, that if their user id is found and their username or displayName is different, then the queue will be updated automatically when those commands are used, or if their username is found (on an entry where the user id is null), then their displayName should be updated automatically! In those cases a separate bot message should be emitted.

liquidnya commented 2 years ago

Algorithm

Inputs

Output

Any of these:

rename algorithm

  1. Search the levels matching entryUserId with the currentUserId if both are present
    • Found a level (level is set) Check if the currentUsername is different than the entryUsername or if the currentDisplayName is different than the entryDisplayName
      • If any information is different Run the updateLevel algorithm
      • If nothing is different Return a NoRenameResult
  2. Search the levels matching previousName with entryUsername or entryDisplayName if previousName is present, ignoring an optional leading '@' in previousName
    • Found a level (level is set) Check if the currentUsername is different than the entryUsername or if the currentDisplayName is different than the entryDisplayName
      • If any information is different If entryUserId is null and entryUsername is currentUsername then run the updateLevel algorithm If isForced is true then run the updateLevel algorithm Otherwise run the noPermissions algorithm
      • If nothing is different Return a NoRenameResult
  3. Search the levels matching entryUsername with currentUsername and entryUserId and/or currentUserId needs to be null:
    • Found a level (level is set) Check if the currentUsername is different than the entryUsername or if the currentDisplayName is different than the entryDisplayName
      • If any information is different If the entryUserId is null then run the updateLevel algorithm If isForced is true then run the updateLevel algorithm Otherwise run the noPermissions algorithm
      • If nothing is different Return a NoRenameResult
  4. Set suggestPreviousName to true if there are any levels in the queue where entryUserId is not present, otherwise set it to false
  5. Return a NoEntryResult

updateLevel algorithm

  1. Set previousUsername to entryUsername
  2. Set previousDisplayName to entryDisplayName
  3. Update entryUsername to currentUsername
  4. Update entryDisplayName to currentDisplayName
  5. Update entryUserId to currentUserId if and only if entryUserId is null
  6. Set previousMatch to:
    • null if prevousName is not present
    • true if and only if the previousName matches previousUsername or previousDisplayName, ignoring an optional leading '@' in previousName
    • false otherwise
  7. edit: Merge the wait time of previousUsername to currentUsername
  8. Return a UpdatedResult

noPermissions algorithm

  1. Set fromUsername to entryUsername
  2. Set fromDisplayName to entryDisplayName
  3. If prevousName is present and if the previousName matches fromUsername or fromDisplayName, ignoring an optional leading '@' in previousName
    • then set fromName to previousName
    • otherwise set fromName to '@' + fromDisplayName
  4. Set toName to '@' + currentDisplayName
  5. Return with NoPermissionResult
liquidnya commented 2 years ago

Commands

!rename (automatic rename, not as the broadcaster)

→ Call the rename algorithm with the following arguments: isForced: false currentUsername, currentDisplayName, and currentUserId: the respectively values of the user who put the command in chat previousName: null or undefined levels: the levels list concatenated with the current level

!rename [previousName] (manual rename, not as the broadcaster)

→ Call the rename algorithm with the following arguments: isForced: false currentUsername, currentDisplayName, and currentUserId: the respectively values of the user who put the command in chat previousName: the previousName argument levels: the levels list concatenated with the current level

!rename [name] (automatic rename as the broadcaster)

→ Call the rename algorithm with the following arguments: isForced: true currentUsername, currentDisplayName, and currentUserId: find those values in the current_chatters list by matching the name argument with currentUsername or currentDisplayName, ignoring an optional leading '@' in name previousName: null or undefined levels: the levels list concatenated with the current level

!rename [fromName] [toName] (manual rename as the broadcaster)

→ Call the rename algorithm with the following arguments: isForced: true currentUsername, currentDisplayName, and currentUserId: find those values in the current_chatters list by matching the toName argument with currentUsername or currentDisplayName, ignoring an optional leading '@' in toName previousName: the fromName argument levels: the levels list concatenated with the current level

liquidnya commented 2 years ago

Important note: People can not just rename other people and they can not rename themselves to just anyone. Only the broadcaster could change someones name to something that is not their actual username.

Settings for this feature could be of interest, enabling: fully automatic rename, enabling the automatic rename commands (which still would need to be manually invoked), or enabling the manual rename commands, etc.