tux.handlers.event
¶
Classes:
Name | Description |
---|---|
EventHandler | |
Classes¶
EventHandler(bot: Tux)
¶
Bases: Cog
Methods:
Name | Description |
---|---|
handle_harmful_message | This function detects harmful linux commands and replies to the user with a warning. |
Source code in tux/handlers/event.py
Functions¶
handle_harmful_message(message: discord.Message) -> None
async
staticmethod
¶
This function detects harmful linux commands and replies to the user with a warning.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message | Message | The message to check. | required |
Returns:
Type | Description |
---|---|
None | |
Source code in tux/handlers/event.py
Python
@staticmethod
async def handle_harmful_message(message: discord.Message) -> None:
"""
This function detects harmful linux commands and replies to the user with a warning.
Parameters
----------
message : discord.Message
The message to check.
Returns
-------
None
"""
if message.author.bot:
return
stripped_content = strip_formatting(message.content)
harmful = is_harmful(stripped_content)
if harmful == "RM_COMMAND":
await message.reply(
"-# ⚠️ **This command is likely harmful. By running it, all directory contents will be deleted. There is no undo. Ensure you fully understand the consequences before proceeding. If you have received this message in error, please disregard it.**",
)
return
if harmful == "FORK_BOMB":
await message.reply(
"-# ⚠️ **This command is likely harmful. By running it, all the memory in your system will be used. Ensure you fully understand the consequences before proceeding. If you have received this message in error, please disregard it.**",
)
return
if harmful == "DD_COMMAND":
await message.reply(
"-# ⚠️ **This command is likely harmful. By running it, your disk will be overwritten or erased irreversibly. Ensure you fully understand the consequences before proceeding. If you have received this message in error, please disregard it.**",
)
return
if harmful == "FORMAT_COMMAND":
await message.reply(
"-# ⚠️ **This command is likely harmful. By running it, your disk will be formatted. Ensure you fully understand the consequences before proceeding. If you have received this message in error, please disregard it.**",
)