diff --git a/docs/cog_texteditor.rst b/docs/cog_texteditor.rst index 71fe4e7f0..8e175eafb 100644 --- a/docs/cog_texteditor.rst +++ b/docs/cog_texteditor.rst @@ -12,7 +12,7 @@ Through this guide, ``[p]`` will always represent your prefix. Replace .. note:: - This guide was last updated for version 3.4.0. Ensure + This guide was last updated for version 3.4.1. Ensure that you are up to date by running ``[p]cog update texteditor``. If there is something missing, or something that needs improving @@ -30,54 +30,60 @@ Edit and manipulate with text. Commands -------- -Here are all the commands included in this cog (23): +Here are all the commands included in this cog (24): * ``[p]editor`` - Base command for editing text. + Base command for editing text. * ``[p]editor alternating `` - Convert the text to alternating case. + Convert the text to alternating case. * ``[p]editor bullet [items...]`` - Bullet point a selection of items. + Bullet point a selection of items. * ``[p]editor camu `` - Jumble text in Cambridge University style. + Jumble text in Cambridge University style. + + https://www.mrc-cbu.cam.ac.uk/people/matt.davis/cmabridge/ * ``[p]editor charcount `` - Count the number of characters appearing in the text. + Count the number of characters appearing in the text. * ``[p]editor formatnumber `` - Format a number with commas. + Format a number with commas. * ``[p]editor lower `` - Convert the text to lowercase. + Convert the text to lowercase. * ``[p]editor multiply `` - Multiply the text. + Multiply the text. * ``[p]editor occurance `` - Count how many times something appears in the text. + Count how many times something appears in the text. * ``[p]editor permutate `` - Generate permutations for given combinations of words/digits. + Generate permutations for given combinations of words/digits. * ``[p]editor remove `` - Remove something from the text. + Remove something from the text. * ``[p]editor replace `` - Replace certain parts of the text. + Replace certain parts of the text. * ``[p]editor reverse `` - Reverse the text. + Reverse the text. * ``[p]editor shlex `` - Shlex split a given string. + Shlex split a given string. * ``[p]editor shuffle `` - Shuffle the word order in the text. + Shuffle the word order in the text. * ``[p]editor snake `` - Convert all spaces to underscores. + Convert all spaces to underscores. * ``[p]editor squash `` - Squash all the words into one. + Squash all the words into one. * ``[p]editor swapcase `` - Swap the casing for text. + Swap the casing for text. * ``[p]editor title `` - Convert the text to titlecase. + Convert the text to titlecase. * ``[p]editor trim [trimmer= ] `` - Trim the outskirts of the text. + Trim the outskirts of the text. +* ``[p]editor typoglycemia `` + Scrambles all letters except the first and last letters in a word. + + Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. * ``[p]editor upper `` - Convert the text to uppercase. + Convert the text to uppercase. * ``[p]editor wordcount `` - Count the number of words appearing in the text. + Count the number of words appearing in the text. * ``[p]editor wrap [cut_words=True] `` - Wrap the text. + Wrap the text. ------------ Installation diff --git a/texteditor/README.rst b/texteditor/README.rst index 71fe4e7f0..8e175eafb 100644 --- a/texteditor/README.rst +++ b/texteditor/README.rst @@ -12,7 +12,7 @@ Through this guide, ``[p]`` will always represent your prefix. Replace .. note:: - This guide was last updated for version 3.4.0. Ensure + This guide was last updated for version 3.4.1. Ensure that you are up to date by running ``[p]cog update texteditor``. If there is something missing, or something that needs improving @@ -30,54 +30,60 @@ Edit and manipulate with text. Commands -------- -Here are all the commands included in this cog (23): +Here are all the commands included in this cog (24): * ``[p]editor`` - Base command for editing text. + Base command for editing text. * ``[p]editor alternating `` - Convert the text to alternating case. + Convert the text to alternating case. * ``[p]editor bullet [items...]`` - Bullet point a selection of items. + Bullet point a selection of items. * ``[p]editor camu `` - Jumble text in Cambridge University style. + Jumble text in Cambridge University style. + + https://www.mrc-cbu.cam.ac.uk/people/matt.davis/cmabridge/ * ``[p]editor charcount `` - Count the number of characters appearing in the text. + Count the number of characters appearing in the text. * ``[p]editor formatnumber `` - Format a number with commas. + Format a number with commas. * ``[p]editor lower `` - Convert the text to lowercase. + Convert the text to lowercase. * ``[p]editor multiply `` - Multiply the text. + Multiply the text. * ``[p]editor occurance `` - Count how many times something appears in the text. + Count how many times something appears in the text. * ``[p]editor permutate `` - Generate permutations for given combinations of words/digits. + Generate permutations for given combinations of words/digits. * ``[p]editor remove `` - Remove something from the text. + Remove something from the text. * ``[p]editor replace `` - Replace certain parts of the text. + Replace certain parts of the text. * ``[p]editor reverse `` - Reverse the text. + Reverse the text. * ``[p]editor shlex `` - Shlex split a given string. + Shlex split a given string. * ``[p]editor shuffle `` - Shuffle the word order in the text. + Shuffle the word order in the text. * ``[p]editor snake `` - Convert all spaces to underscores. + Convert all spaces to underscores. * ``[p]editor squash `` - Squash all the words into one. + Squash all the words into one. * ``[p]editor swapcase `` - Swap the casing for text. + Swap the casing for text. * ``[p]editor title `` - Convert the text to titlecase. + Convert the text to titlecase. * ``[p]editor trim [trimmer= ] `` - Trim the outskirts of the text. + Trim the outskirts of the text. +* ``[p]editor typoglycemia `` + Scrambles all letters except the first and last letters in a word. + + Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. * ``[p]editor upper `` - Convert the text to uppercase. + Convert the text to uppercase. * ``[p]editor wordcount `` - Count the number of words appearing in the text. + Count the number of words appearing in the text. * ``[p]editor wrap [cut_words=True] `` - Wrap the text. + Wrap the text. ------------ Installation diff --git a/texteditor/texteditor.py b/texteditor/texteditor.py index 1d9bc0da0..9f766e7f4 100644 --- a/texteditor/texteditor.py +++ b/texteditor/texteditor.py @@ -29,7 +29,7 @@ class TextEditor(commands.Cog): """ __author__ = "Kreusada" - __version__ = "3.4.0" + __version__ = "3.4.1" def __init__(self, bot): self.bot = bot @@ -218,3 +218,22 @@ async def editor_formatnumber(self, ctx: commands.Context, number: int): async def editor_bullet(self, ctx: commands.Context, bullet: str, *items: str): """Bullet point a selection of items.""" await send_safe(ctx, "\n".join(f"{bullet} {item}" for item in items)) + + @editor.command(name="typoglycemia") + async def editor_typoglycemia(self, ctx: commands.Context, *, text: str): + """Scrambles all letters except the first and last letters in a word. + + Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.""" + ret = [] + for word in text.split(): + if len(word) < 4: + ret.append(word) + continue + while True: + middle = list(word[1:-1]) + random.shuffle(middle) + middle = "".join(middle) + if middle != word: + break + ret.append(word[0] + middle + word[-1]) + await send_safe(ctx, " ".join(ret)) \ No newline at end of file