ClemBotProject/ClemBot

Improve !spongebob command

Closed this issue · 4 comments

Currently the !spongebob command just has a ~40% chance for each character to be uppercase/~60% chance to be lowercase (regardless of the original case). However, this often makes strings that don't quite capture the feel of the actual spongebob text meme.

Possible solutions:
-Use a more uniform distribution of capital letters
-Alternate small, random length runs of characters with the same case
-any more suggestions? Will update issue with more as suggested.

-Alternate small, random length runs of characters with the same case

A max length of 3 characters seems apt considering some words might not be long enough to see the change in case at all.

i = 1
result = random.choice((str.upper, str.lower))(args[0])
while i < len(args):
    helper = random.randint(1, 3)   
    if result[i-1].isupper():
        result += args[i : i+helper].lower()
    else:
        result += args[i : i+helper].upper()
    i += helper

-any more suggestions? Will update issue with more as suggested.

Totally random uppercase/lowercase

result = ''.join(random.choice((str.upper, str.lower))(char) for char in args)

explanation: choice() picks a random item from the tuple of (str.upper, str.lower) and applies to each character in the string which are then joined together

-Use a more uniform distribution of capital letters

I personally don't think this one as a good option as uniformity seems to be opposite of the desired result but this can be achieved just by moving the helper variable outside the while loop:

i = 0
helper = random.randint(2, 3)
result = ''  
while i < len(args): 
    result += args[i].upper()
    result += args[i+1 : i+helper].lower()
    i += helper

Please let me know if you prefer any of the above solutions. I would love to reattempt the PR that I failed earlier

@kspalm @jkriste Any of the solutions above that you think I should implement?

Any of the solutions above that you think I should implement?

Ultimately, it's up to you! Any of the solutions you've provided are more than enough. 😄

The !spongebob command has been moved to SockBot, so this feature will not be implemented here.