-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
232 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.. _morsecode: | ||
|
||
========= | ||
MorseCode | ||
========= | ||
|
||
This is the cog guide for the 'MorseCode' cog. This guide | ||
contains the collection of commands which you can use in the cog. | ||
|
||
Through this guide, ``[p]`` will always represent your prefix. Replace | ||
``[p]`` with your own prefix when you use these commands in Discord. | ||
|
||
.. note:: | ||
|
||
This guide was last updated for version 1.0.0. Ensure | ||
that you are up to date by running ``[p]cog update morsecode``. | ||
|
||
If there is something missing, or something that needs improving | ||
in this documentation, feel free to create an issue `here <https://github.com/Kreusada/Kreusada-Cogs/issues>`_. | ||
|
||
This documentation is auto-generated everytime this cog receives an update. | ||
|
||
-------------- | ||
About this cog | ||
-------------- | ||
|
||
Encode and decode morse code. | ||
|
||
-------- | ||
Commands | ||
-------- | ||
|
||
Here are all the commands included in this cog (3): | ||
|
||
+---------------------+-------------------------------+ | ||
| Command | Help | | ||
+=====================+===============================+ | ||
| ``[p]morse`` | Encode and decode morse code. | | ||
+---------------------+-------------------------------+ | ||
| ``[p]morse decode`` | Decode morse code. | | ||
+---------------------+-------------------------------+ | ||
| ``[p]morse encode`` | Encode morse code. | | ||
+---------------------+-------------------------------+ | ||
|
||
------------ | ||
Installation | ||
------------ | ||
|
||
If you haven't added my repo before, lets add it first. We'll call it | ||
"kreusada-cogs" here. | ||
|
||
.. code-block:: ini | ||
[p]repo add kreusada-cogs https://github.com/Kreusada/Kreusada-Cogs | ||
Now, we can install MorseCode. | ||
|
||
.. code-block:: ini | ||
[p]cog install kreusada-cogs morsecode | ||
Once it's installed, it is not loaded by default. Load it by running the following | ||
command: | ||
|
||
.. code-block:: ini | ||
[p]load morsecode | ||
--------------- | ||
Further Support | ||
--------------- | ||
|
||
For more support, head over to the `cog support server <https://discord.gg/GET4DVk>`_, | ||
I have my own channel over there at #support_kreusada-cogs. Feel free to join my | ||
`personal server <https://discord.gg/JmCFyq7>`_ whilst you're here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Useful Links | |
cog_flags | ||
cog_messagedeleter | ||
cog_minifier | ||
cog_morsecode | ||
cog_onthisday | ||
cog_pypi | ||
cog_qr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.. _morsecode: | ||
|
||
========= | ||
MorseCode | ||
========= | ||
|
||
This is the cog guide for the 'MorseCode' cog. This guide | ||
contains the collection of commands which you can use in the cog. | ||
|
||
Through this guide, ``[p]`` will always represent your prefix. Replace | ||
``[p]`` with your own prefix when you use these commands in Discord. | ||
|
||
.. note:: | ||
|
||
This guide was last updated for version 1.0.0. Ensure | ||
that you are up to date by running ``[p]cog update morsecode``. | ||
|
||
If there is something missing, or something that needs improving | ||
in this documentation, feel free to create an issue `here <https://github.com/Kreusada/Kreusada-Cogs/issues>`_. | ||
|
||
This documentation is auto-generated everytime this cog receives an update. | ||
|
||
-------------- | ||
About this cog | ||
-------------- | ||
|
||
Encode and decode morse code. | ||
|
||
-------- | ||
Commands | ||
-------- | ||
|
||
Here are all the commands included in this cog (3): | ||
|
||
+---------------------+-------------------------------+ | ||
| Command | Help | | ||
+=====================+===============================+ | ||
| ``[p]morse`` | Encode and decode morse code. | | ||
+---------------------+-------------------------------+ | ||
| ``[p]morse decode`` | Decode morse code. | | ||
+---------------------+-------------------------------+ | ||
| ``[p]morse encode`` | Encode morse code. | | ||
+---------------------+-------------------------------+ | ||
|
||
------------ | ||
Installation | ||
------------ | ||
|
||
If you haven't added my repo before, lets add it first. We'll call it | ||
"kreusada-cogs" here. | ||
|
||
.. code-block:: ini | ||
[p]repo add kreusada-cogs https://github.com/Kreusada/Kreusada-Cogs | ||
Now, we can install MorseCode. | ||
|
||
.. code-block:: ini | ||
[p]cog install kreusada-cogs morsecode | ||
Once it's installed, it is not loaded by default. Load it by running the following | ||
command: | ||
|
||
.. code-block:: ini | ||
[p]load morsecode | ||
--------------- | ||
Further Support | ||
--------------- | ||
|
||
For more support, head over to the `cog support server <https://discord.gg/GET4DVk>`_, | ||
I have my own channel over there at #support_kreusada-cogs. Feel free to join my | ||
`personal server <https://discord.gg/JmCFyq7>`_ whilst you're here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from morse3 import Morse | ||
|
||
from redbot.core import commands | ||
from redbot.core.utils import get_end_user_data_statement | ||
from redbot.core.utils.chat_formatting import box, pagify | ||
|
||
|
||
__red_end_user_data_statement__ = get_end_user_data_statement(__file__) | ||
|
||
|
||
class MorseCode(commands.Cog): | ||
"""Encode and decode morse code.""" | ||
|
||
__author__ = "Kreusada" | ||
__version__ = "1.0.0" | ||
|
||
def format_help_for_context(self, ctx: commands.Context) -> str: | ||
context = super().format_help_for_context(ctx) | ||
return f"{context}\n\nAuthor: {self.__author__}\nVersion: {self.__version__}" | ||
|
||
async def red_delete_data_for_user(self, **kwargs): | ||
return | ||
|
||
@staticmethod | ||
def safe_morse_encode(text: str): | ||
try: | ||
return Morse(text).stringToMorse() | ||
except Exception as e: | ||
return str(e) | ||
|
||
@staticmethod | ||
def safe_morse_decode(morse_code: str): | ||
try: | ||
return Morse(morse_code).morseToString() | ||
except Exception as e: | ||
return str(e) | ||
|
||
@commands.group() | ||
async def morse(self, ctx: commands.Context): | ||
"""Encode and decode morse code.""" | ||
|
||
@morse.command() | ||
async def encode(self, ctx: commands.Context, *, text: str): | ||
"""Encode morse code.""" | ||
for page in pagify(self.safe_morse_encode(text), page_length=1990): | ||
await ctx.send(box(page)) | ||
|
||
@morse.command() | ||
async def decode(self, ctx: commands.Context, *, morse_code: str): | ||
"""Decode morse code.""" | ||
for page in pagify(self.safe_morse_decode(morse_code), page_length=1990): | ||
await ctx.send(box(page)) | ||
|
||
|
||
async def setup(bot): | ||
await bot.add_cog(MorseCode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"author": [ | ||
"Kreusada" | ||
], | ||
"description": "Encode and decode morse code.", | ||
"disabled": false, | ||
"end_user_data_statement": "This cog does not persistently store data or metadata about users.", | ||
"hidden": false, | ||
"install_msg": "Thanks for installing, have fun. Please refer to my docs if you need any help: https://kreusadacogs.readthedocs.io/en/latest/cog_morsecode.html", | ||
"name": "MorseCode", | ||
"required_cogs": {}, | ||
"requirements": [ | ||
"morse3" | ||
], | ||
"short": "Encode and decode morse code.", | ||
"tags": [ | ||
"Morse", | ||
"Code", | ||
"Encode", | ||
"Decode" | ||
], | ||
"type": "COG" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
'flags', | ||
'messagedeleter', | ||
'minifier', | ||
'morsecode', | ||
'onthisday', | ||
'pypi', | ||
'qr', | ||
|