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

!rename command and store user id #7

Open
liquidnya opened this issue May 24, 2022 · 4 comments
Open

!rename command and store user id #7

liquidnya opened this issue May 24, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@liquidnya
Copy link

liquidnya commented May 24, 2022

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
Copy link
Author

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
Copy link
Author

Algorithm

Inputs

  • isForced: usually only the broadcaster can force a rename (required)
  • currentUsername (required)
  • currentDisplayName (required)
  • currentUserId (optional)
  • previousName: a username or a displayName (optional)
  • levels: level list concatenated with the current level containing the following information per level
    • entryUsername (required)
    • entryDisplayName (required)
    • entryUserId (optional)

Output

Any of these:

  • UpdatedResult containing previousUsername, previousDisplayName, previousMatch, and level
    Their username and/or displayName was updated to previousUsername and previousDisplayName respectively and previousMatch can contain the following results:

    • null if the previousName is not present
    • true if and only if the previousName matches
    • false otherwise

    level contains the level of the user

  • NoRenameResult containing level
    If they are in the queue and there is no need to rename anything
    level contains the level of the user

  • NoPermissionResult containing fromUsername, fromDisplayName, fromName, toName, and level
    If they do not have the permission to rename themselves
    fromUsername contains their potential previous username
    fromDisplayName contains their potential previous displayName
    fromName contains the fromDisplyName with an optional leading '@', to be used as the first argument of the modRename command
    toName contains the currentDisplayName with an optional leading '@', to be used as the second argument of the modRename command
    level contains the level of the user

  • NoEntryResult containing suggestPreviousName
    suggestPreviousName is true if there is a chance of finding a level if previousName would have been provided, and false otherwise

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
Copy link
Author

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants