test
This commit is contained in:
parent
d624800839
commit
65b22a2975
@ -33,3 +33,4 @@ sopel.plugins =
|
|||||||
spicebot_command_lower = spicebot_command_lower
|
spicebot_command_lower = spicebot_command_lower
|
||||||
spicebot_command_upper = spicebot_command_upper
|
spicebot_command_upper = spicebot_command_upper
|
||||||
spicebot_command_echo = spicebot_command_echo
|
spicebot_command_echo = spicebot_command_echo
|
||||||
|
spicebot_command_spongemock = spicebot_command_spongemock
|
||||||
|
|||||||
49
spicebot_command_spongemock/__init__.py
Normal file
49
spicebot_command_spongemock/__init__.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
import unicodedata
|
||||||
|
import random
|
||||||
|
|
||||||
|
from sopel import plugin
|
||||||
|
|
||||||
|
from sopel_SpiceBot_Core_Prerun import prerun
|
||||||
|
|
||||||
|
|
||||||
|
@prerun()
|
||||||
|
@plugin.command('spongemock', 'smock')
|
||||||
|
def upper(bot, trigger, comrun):
|
||||||
|
comrun.say(mock_case(comrun.command["trigger_str"]))
|
||||||
|
|
||||||
|
|
||||||
|
def mock_case(text):
|
||||||
|
text = text.strip()
|
||||||
|
|
||||||
|
out = text[0].lower()
|
||||||
|
lower = True
|
||||||
|
repeat = 1
|
||||||
|
|
||||||
|
for char in text[1:]:
|
||||||
|
lo = char.lower()
|
||||||
|
up = char.upper()
|
||||||
|
|
||||||
|
if unicodedata.category(char) == 'Zs' or lo == up:
|
||||||
|
# whitespace shouldn't affect the case-repeat counting
|
||||||
|
# nor should characters whose case cannot be transformed
|
||||||
|
out += char
|
||||||
|
continue
|
||||||
|
|
||||||
|
if repeat == 2:
|
||||||
|
repeat = 1
|
||||||
|
lower = not lower
|
||||||
|
out += lo if lower else up
|
||||||
|
else:
|
||||||
|
which = random.choice([True, False])
|
||||||
|
if which:
|
||||||
|
out += lo
|
||||||
|
else:
|
||||||
|
out += up
|
||||||
|
if lower == which:
|
||||||
|
repeat += 1
|
||||||
|
else:
|
||||||
|
repeat = 1
|
||||||
|
lower = which
|
||||||
|
|
||||||
|
return out
|
||||||
Loading…
Reference in New Issue
Block a user