Compare commits
1 commit
main
...
pterodacty
Author | SHA1 | Date | |
---|---|---|---|
e90dc60643 |
36 changed files with 2756 additions and 2100 deletions
|
@ -10,7 +10,7 @@ Aurora is a fully-featured moderation system. It is heavily inspired by Galactic
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs aurora
|
||||
[p]cog load aurora
|
||||
```
|
||||
|
|
|
@ -5,14 +5,14 @@ Backup allows you to export a JSON list of all of your installed repositories an
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs backup
|
||||
[p]cog load backup
|
||||
```
|
||||
|
||||
## Version Compatibility
|
||||
|
||||
As of commit [1edb08a](https://www.coastalcommits.com/cswimr/SeaCogs/commit/1edb08a1271f12098ca0bed11a735f7162cedd14), the Backup cog no longer supports Red versions older than 3.5.6. If you want to use the cog on an earlier version (3.5.0 - 3.5.5), install the cog pinned to this commit: `43464db6a7c51bc69282b1ae3dc507a4aae851de`.
|
||||
As of commit [1edb08a](https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs/commit/1edb08a1271f12098ca0bed11a735f7162cedd14), the Backup cog no longer supports Red versions older than 3.5.6. If you want to use the cog on an earlier version (3.5.0 - 3.5.5), install the cog pinned to this commit: `43464db6a7c51bc69282b1ae3dc507a4aae851de`.
|
||||
|
||||
```bash
|
||||
[p]cog installversion sea-cogs 43464db6a7c51bc69282b1ae3dc507a4aae851de backup
|
||||
|
|
|
@ -6,7 +6,7 @@ This cog does require an api key to work.
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs bible
|
||||
[p]cog load bible
|
||||
```
|
||||
|
|
|
@ -5,7 +5,7 @@ EmojiInfo allows you to retrieve information about an emoji.
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs emojiinfo
|
||||
[p]cog load emojiinfo
|
||||
```
|
||||
|
|
|
@ -5,7 +5,7 @@ Nerdify allows you to nerdify other people's text.
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs nerdify
|
||||
[p]cog load nerdify
|
||||
```
|
||||
|
|
|
@ -28,7 +28,7 @@ The Downloader cog allows you to add Git repositories to your bot in order to do
|
|||
Now, use Downloader to add my repository to your bot:
|
||||
|
||||
```
|
||||
[p]repo add sea-cogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add sea-cogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
```
|
||||
|
||||
Now, install the Pterodactyl cog:
|
||||
|
|
|
@ -10,7 +10,7 @@ Pterodactyl allows for connecting to a Pterodactyl server through websockets. It
|
|||
## Installation
|
||||
|
||||
```bash
|
||||
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
[p]cog install seacogs pterodactyl
|
||||
[p]cog load aurora
|
||||
```
|
||||
|
|
|
@ -10,7 +10,7 @@ There are a few caveats to running an instance of Red on Pterodactyl.
|
|||
|
||||
- You will not receive any support from the Red developers.
|
||||
- The built-in Audio cog will not work.
|
||||
- Depending on your host, you might have to request a [`tmpfs` size increase](https://github.com/pelican-eggs/eggs/tree/master/bots/discord/redbot#additional-requirements).
|
||||
- Depending on your host, you might have to request a [`tmpfs` size increase](https://github.com/ign-gg/Pterodactyl-Eggs/tree/master/bots/discord/redbot#additional-requirements).
|
||||
|
||||
If these are unacceptable to you, you should [install Red normally](https://docs.discord.red/en/stable/install_guides/index.html).
|
||||
///
|
||||
|
@ -64,7 +64,7 @@ Red is quite a large bot, so I'll focus on the specifics of getting the bot work
|
|||
```
|
||||
2. Add my repository to the bot
|
||||
```bash
|
||||
[p]repo add sea-cogs https://www.coastalcommits.com/cswimr/SeaCogs
|
||||
[p]repo add sea-cogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
```
|
||||
3. Install and load the Pterodactyl cog
|
||||
```bash
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
name: Bug Report
|
||||
about: File a bug report
|
||||
title: "[Cog Name] "
|
||||
labels: [bug]
|
||||
ref: master
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
@ -11,7 +13,7 @@ body:
|
|||
attributes:
|
||||
label: Please confirm that;
|
||||
options:
|
||||
- label: I have checked that this bug does not already have an opened/closed [issue](https://www.coastalcommits.com/cswimr/SeaCogs/issues) or [pull request](https://www.coastalcommits.com/cswimr/SeaCogs/pulls) associated with it.
|
||||
- label: I have checked that this bug does not already have an opened/closed [issue](https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs/issues) or [pull request](https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs/pulls) associated with it.
|
||||
required: true
|
||||
- label: I have checked that I am on the latest version of [Red-DiscordBot](https://github.com/CogCreators/Red-DiscordBot), and SeaCogs.
|
||||
required: true
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
name: Suggestion
|
||||
about: Trying to suggest something for SeaCogs? Use this.
|
||||
labels: [enhancement]
|
||||
title: "[Cog Name] "
|
||||
labels: enhancement
|
||||
ref: master
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
@ -11,7 +13,7 @@ body:
|
|||
attributes:
|
||||
label: What cog is your feature request for?
|
||||
description: Specify the cog within the repository.
|
||||
placeholder: E.g., Pterodactyl
|
||||
placeholder: E.g., ModerationCog
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
<!-- Create a new issue, if it doesn't exist yet -->
|
||||
|
||||
- [ ] By submitting this pull request, I permit cswimr to license my work under
|
||||
the [Mozilla Public License Version 2.0](https://www.coastalcommits.com/cswimr/SeaCogs/src/branch/main/LICENSE).
|
||||
- [ ] By submitting this pull request, I permit SeaswimmerTheFsh to license my work under
|
||||
the [Mozilla Public License Version 2.0](https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs/src/branch/main/LICENSE).
|
||||
|
|
|
@ -1,46 +1,39 @@
|
|||
name: Actions
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint Code (Ruff & Pylint)
|
||||
Lint Code (Ruff & Pylint):
|
||||
runs-on: docker
|
||||
container: www.coastalcommits.com/cswimr/actions:uv
|
||||
container: www.coastalcommits.com/seaswimmerthefsh/actionscontainers-seacogs:latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install python
|
||||
run: uv python install 3.11
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync
|
||||
run: poetry install --with dev --no-root
|
||||
|
||||
- name: Analysing code with Ruff
|
||||
run: uv run ruff check $(git ls-files '*.py')
|
||||
run: ./.venv/bin/ruff check $(git ls-files '*.py')
|
||||
continue-on-error: true
|
||||
|
||||
- name: Analysing code with Pylint
|
||||
run: uv run pylint --rcfile=.forgejo/workflows/config/.pylintrc $(git ls-files '*.py')
|
||||
run: ./.venv/bin/pylint --rcfile=.forgejo/workflows/config/.pylintrc $(git ls-files '*.py')
|
||||
|
||||
docs:
|
||||
name: Build Documentation (MkDocs)
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
Build Documentation (MkDocs):
|
||||
runs-on: docker
|
||||
container: www.coastalcommits.com/cswimr/actions:docs
|
||||
container: www.coastalcommits.com/seaswimmerthefsh/actionscontainers-seacogs:latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install python
|
||||
run: uv python install 3.11
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --no-dev --extra=documentation
|
||||
run: poetry install --with docs --no-root
|
||||
|
||||
- name: Set environment variables
|
||||
uses: actions/env@v2
|
||||
|
@ -49,7 +42,7 @@ jobs:
|
|||
run: |
|
||||
export SITE_URL="https://$CI_ACTION_REF_NAME_SLUG.seacogs.coastalcommits.com"
|
||||
export EDIT_URI="src/branch/$CI_ACTION_REF_NAME/.docs"
|
||||
uv run mkdocs build -v
|
||||
./.venv/bin/mkdocs build -v
|
||||
|
||||
- name: Deploy documentation
|
||||
run: |
|
||||
|
@ -65,7 +58,7 @@ jobs:
|
|||
npx -p "@getmeli/cli" meli upload ./site \
|
||||
--url "https://pages.coastalcommits.com" \
|
||||
--site "${{ vars.MELI_SITE_ID }}" \
|
||||
--token "${{ secrets.MELI_TOKEN }}" \
|
||||
--token "${{ secrets.MELI_SECRET }}" \
|
||||
--release "$CI_ACTION_REF_NAME_SLUG/${{ env.GITHUB_SHA }}" \
|
||||
--branch "$CI_ACTION_REF_NAME_SLUG"
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ My assorted cogs for Red-DiscordBot.
|
|||
To get started with a development environment, first clone this repository.
|
||||
|
||||
```sh
|
||||
git clone https://coastalcommits.com/cswimr/SeaCogs.git
|
||||
git clone https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs.git
|
||||
```
|
||||
|
||||
Then, install Poetry.
|
||||
|
|
|
@ -9,15 +9,14 @@ import discord
|
|||
from red_commons.logging import getLogger
|
||||
from redbot.core import commands
|
||||
from redbot.core.bot import Config, Red
|
||||
from redbot.core.utils.chat_formatting import bold, humanize_list
|
||||
from redbot.core.utils.chat_formatting import humanize_list
|
||||
|
||||
|
||||
class AntiPolls(commands.Cog):
|
||||
"""AntiPolls deletes messages that contain polls, with a configurable per-guild role and channel whitelist and support for default Discord permissions (Manage Messages)."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.0.1"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "1.0.0"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/antipolls/"
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
|
@ -39,9 +38,9 @@ class AntiPolls(commands.Cog):
|
|||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {humanize_list(self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}",
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing AntiPolls!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing AntiPolls!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||
"name" : "AntiPolls",
|
||||
"short" : "AntiPolls deletes messages that contain polls.",
|
||||
"description" : "AntiPolls deletes messages that contain polls, with a configurable per-guild role and channel whitelist and support for default Discord permissions (Manage Messages).",
|
||||
|
|
|
@ -39,7 +39,7 @@ class Aurora(commands.Cog):
|
|||
It is heavily inspired by GalacticBot, and is designed to be a more user-friendly alternative to Red's core Mod cogs.
|
||||
This cog stores all of its data in an SQLite database."""
|
||||
|
||||
__author__ = ["cswimr"]
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "2.1.3"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/aurora/"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing Aurora!\nMost of this cog's functionality requires enabling slash commands.\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Aurora!\nMost of this cog's functionality requires enabling slash commands.\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||
"name" : "Aurora",
|
||||
"short" : "A full replacement for Red's core Mod cogs.",
|
||||
"description" : "Aurora is a fully-featured moderation system. It is heavily inspired by GalacticBot, and is designed to be a more user-friendly alternative to Red's core Mod cogs. This cog stores all of its data in an SQLite database.",
|
||||
|
|
|
@ -14,16 +14,15 @@ from redbot.cogs.downloader import errors
|
|||
from redbot.cogs.downloader.converters import InstalledCog
|
||||
from redbot.core import commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.utils.chat_formatting import bold, error, humanize_list, text_to_file
|
||||
from redbot.core.utils.chat_formatting import error, humanize_list, text_to_file
|
||||
|
||||
|
||||
# pylint: disable=protected-access
|
||||
class Backup(commands.Cog):
|
||||
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.1.1"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "1.1.0"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/backup/"
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
|
@ -36,9 +35,9 @@ class Backup(commands.Cog):
|
|||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {humanize_list(self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}",
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
@ -197,7 +196,7 @@ class Backup(commands.Cog):
|
|||
cog_modules = []
|
||||
for cog in cogs:
|
||||
# If you're forking this cog, make sure to change these strings!
|
||||
if cog["name"] == "backup" and "cswimr/SeaCogs" in url:
|
||||
if cog["name"] == "backup" and "SeaswimmerTheFsh/SeaCogs" in url:
|
||||
continue
|
||||
try:
|
||||
cog_module = await InstalledCog.convert(ctx, cog["name"])
|
||||
|
@ -233,7 +232,7 @@ class Backup(commands.Cog):
|
|||
commit = None
|
||||
|
||||
# If you're forking this cog, make sure to change these strings!
|
||||
if cog_name == "backup" and "cswimr/SeaCogs" in url:
|
||||
if cog_name == "backup" and "SeaswimmerTheFsh/SeaCogs" in url:
|
||||
continue
|
||||
|
||||
async with repository.checkout(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing Backup!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Backup!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||
"name" : "Backup",
|
||||
"short" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.",
|
||||
"description" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.",
|
||||
|
@ -8,7 +8,7 @@
|
|||
"hidden": false,
|
||||
"disabled": false,
|
||||
"min_bot_version": "3.5.6",
|
||||
"max_bot_version": "3.5.13",
|
||||
"max_bot_version": "3.5.10",
|
||||
"min_python_version": [3, 9, 0],
|
||||
"tags": [
|
||||
"utility",
|
||||
|
|
|
@ -15,7 +15,7 @@ from PIL import Image
|
|||
from red_commons.logging import getLogger
|
||||
from redbot.core import Config, commands, data_manager
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.utils.chat_formatting import bold, error, humanize_list
|
||||
from redbot.core.utils.chat_formatting import error, humanize_list
|
||||
|
||||
import bible.errors
|
||||
from bible.models import Version
|
||||
|
@ -24,10 +24,9 @@ from bible.models import Version
|
|||
class Bible(commands.Cog):
|
||||
"""Retrieve Bible verses from the API.bible API."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.1.1"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "1.1.0"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/bible/"
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
super().__init__()
|
||||
|
@ -45,13 +44,12 @@ class Bible(commands.Cog):
|
|||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {humanize_list(self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}",
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
||||
def get_icon(self, color: Colour) -> File:
|
||||
"""Get the docs.api.bible favicon with a given color."""
|
||||
image_path = data_manager.bundled_data_path(self) / "api.bible-logo.png"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing Bible!\nThis cog requires setting an API key for API.Bible. Please read the [documentation](https://seacogs.coastalcommits.com/bible/#setup) for more information.\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Bible!\nThis cog requires setting an API key for API.Bible. Please read the [documentation](https://seacogs.coastalcommits.com/bible/#setup) for more information.\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||
"name" : "Bible",
|
||||
"short" : "Retrieve Bible verses from API.Bible.",
|
||||
"description" : "Retrieve Bible verses from the API.Bible API. This cog requires an API.Bible api key.",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import io
|
||||
from typing import Any, Literal
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
|
@ -14,10 +15,9 @@ from .model import PartialEmoji
|
|||
class EmojiInfo(commands.Cog):
|
||||
"""Retrieve information about emojis."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.0.1"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/emojiinfo/"
|
||||
__author__: list[str] = ["SeaswimmerTheFsh"]
|
||||
__version__: str = "1.0.0"
|
||||
__documentation__: str = "https://seacogs.coastalcommits.com/emojiinfo/"
|
||||
|
||||
def __init__(self, bot: Red) -> None:
|
||||
super().__init__()
|
||||
|
@ -25,17 +25,16 @@ class EmojiInfo(commands.Cog):
|
|||
self.logger: RedTraceLogger = getLogger(name="red.SeaCogs.Emoji")
|
||||
|
||||
def format_help_for_context(self, ctx: commands.Context) -> str:
|
||||
pre_processed = super().format_help_for_context(ctx) or ""
|
||||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
pre_processed: Any | Literal[''] = super().format_help_for_context(ctx) or ""
|
||||
n: Literal['\n'] | Literal[''] = "\n" if "\n\n" not in pre_processed else ""
|
||||
text: list[str] = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {humanize_list(items=self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}",
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
||||
async def fetch_twemoji(self, unicode_emoji) -> str:
|
||||
base_url = "https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/72x72/"
|
||||
emoji_codepoint = "-".join([hex(ord(char))[2:] for char in unicode_emoji])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Emoji!",
|
||||
"name" : "Emoji",
|
||||
"short" : "Retrieve information about emojis.",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"author": [
|
||||
"cswimr"
|
||||
"SeaswimmerTheFsh (seasw.)"
|
||||
],
|
||||
"install_msg": "Thanks for installing my repo!\n\nIf you have any issues with any of the cogs, please create an issue [here](https://coastalcommits.com/cswimr/SeaCogs/issues) or join my [Discord Server](https://discord.gg/eMUMe77Yb8 ).",
|
||||
"install_msg": "Thanks for installing my repo!\n\nIf you have any issues with any of the cogs, please create an issue [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs/issues) or join my [Discord Server](https://discord.gg/eMUMe77Yb8 ).",
|
||||
"index_name": "sea-cogs",
|
||||
"short": "Various cogs for Red, by cswimr",
|
||||
"description": "Various cogs for Red, by cswimr"
|
||||
"short": "Various cogs for Red, by SeaswimmerTheFsh (seasw.)",
|
||||
"description": "Various cogs for Red, by SeaswimmerTheFsh (seasw.)"
|
||||
}
|
||||
|
|
10
mkdocs.yml
10
mkdocs.yml
|
@ -1,12 +1,12 @@
|
|||
site_name: SeaCogs Documentation
|
||||
site_url: !ENV [SITE_URL, 'https://seacogs.coastalcommits.com']
|
||||
repo_name: CoastalCommits
|
||||
repo_url: https://coastalcommits.com/cswimr/SeaCogs
|
||||
repo_url: https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs
|
||||
edit_uri: !ENV [EDIT_URI, 'src/branch/main/.docs']
|
||||
copyright: Copyright © 2023-2024, cswimr
|
||||
copyright: Copyright © 2023-2024, SeaswimmerTheFsh
|
||||
docs_dir: .docs
|
||||
|
||||
site_author: cswimr
|
||||
site_author: SeaswimmerTheFsh
|
||||
site_description: Documentation for my Red-DiscordBot Cogs.
|
||||
|
||||
nav:
|
||||
|
@ -30,7 +30,7 @@ nav:
|
|||
plugins:
|
||||
- git-authors
|
||||
- search
|
||||
- social
|
||||
#- social
|
||||
- git-revision-date-localized:
|
||||
enable_creation_date: true
|
||||
type: timeago
|
||||
|
@ -113,5 +113,3 @@ watch:
|
|||
- ./bible
|
||||
- ./nerdify
|
||||
- ./pterodactyl
|
||||
- ./emojiinfo
|
||||
- ./antipolls
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing Nerdify!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs). Based off of PhasecoreX's [UwU](<https://github.com/PhasecoreX/PCXCogs/tree/master/uwu>) cog.",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Nerdify!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs). Based off of PhasecoreX's [UwU](<https://github.com/PhasecoreX/PCXCogs/tree/master/uwu>) cog.",
|
||||
"name" : "Nerdify",
|
||||
"short" : "Nerdify your text!",
|
||||
"description" : "Nerdify your text!",
|
||||
|
|
|
@ -12,15 +12,13 @@ from typing import Any, Optional, Union
|
|||
import discord
|
||||
from redbot.core import commands
|
||||
from redbot.core.utils import chat_formatting, common_filters
|
||||
from redbot.core.utils.chat_formatting import bold, humanize_list
|
||||
|
||||
|
||||
class Nerdify(commands.Cog):
|
||||
"""Nerdify your text."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.3.5"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "1.3.4"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/nerdify/"
|
||||
|
||||
def __init__(self, bot):
|
||||
|
@ -31,13 +29,12 @@ class Nerdify(commands.Cog):
|
|||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {chat_formatting.humanize_list(self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}"
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
||||
@commands.command(aliases=["nerd"])
|
||||
async def nerdify(
|
||||
self, ctx: commands.Context, *, text: Optional[str] = None
|
||||
|
|
2501
poetry.lock
generated
Normal file
2501
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 65 KiB |
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing Pterodactyl!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).\nDocumentation can be found [here](https://seacogs.coastalcommits.com/pterodactyl ).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing Pterodactyl!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).\nDocumentation can be found [here](https://seacogs.coastalcommits.com/pterodactyl ).",
|
||||
"name" : "Pterodactyl",
|
||||
"short" : "Interface with Pterodactyl through websockets.",
|
||||
"description" : "Interface with Pterodactyl through websockets.",
|
||||
|
@ -9,7 +9,7 @@
|
|||
"disabled": false,
|
||||
"min_bot_version": "3.5.0",
|
||||
"min_python_version": [3, 8, 0],
|
||||
"requirements": ["git+https://github.com/cswimr/pydactyl", "websockets"],
|
||||
"requirements": ["git+https://github.com/SeaswimmerTheFsh/pydactyl", "websockets"],
|
||||
"tags": [
|
||||
"pterodactyl",
|
||||
"minecraft",
|
||||
|
|
|
@ -9,7 +9,7 @@ from pydactyl import PterodactylClient
|
|||
from redbot.core import app_commands, commands
|
||||
from redbot.core.app_commands import Choice
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.utils.chat_formatting import bold, box, error, humanize_list
|
||||
from redbot.core.utils.chat_formatting import box, error, humanize_list
|
||||
from redbot.core.utils.views import ConfirmView
|
||||
|
||||
from pterodactyl import mcsrvstatus
|
||||
|
@ -20,9 +20,8 @@ from pterodactyl.logger import logger
|
|||
class Pterodactyl(commands.Cog):
|
||||
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "2.0.4"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "2.0.0"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
|
@ -40,29 +39,12 @@ class Pterodactyl(commands.Cog):
|
|||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{bold('Author:')} {humanize_list(self.__author__)}",
|
||||
f"{bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {humanize_list(self.__author__)}",
|
||||
f"Documentation: {self.__documentation__}",
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
async def cog_load(self) -> None:
|
||||
pterodactyl_keys = await self.bot.get_shared_api_tokens("pterodactyl")
|
||||
api_key = pterodactyl_keys.get("api_key")
|
||||
if api_key is None:
|
||||
self.task.cancel()
|
||||
raise ValueError("Pterodactyl API key not set. Please set it using `[p]set api`.")
|
||||
base_url = await config.base_url()
|
||||
if base_url is None:
|
||||
self.task.cancel()
|
||||
raise ValueError("Pterodactyl base URL not set. Please set it using `[p]pterodactyl config url`.")
|
||||
server_id = await config.server_id()
|
||||
if server_id is None:
|
||||
self.task.cancel()
|
||||
raise ValueError("Pterodactyl server ID not set. Please set it using `[p]pterodactyl config serverid`.")
|
||||
|
||||
self.client = PterodactylClient(base_url, api_key).client
|
||||
|
||||
async def cog_unload(self) -> None:
|
||||
self.update_topic.cancel()
|
||||
self.task.cancel()
|
||||
|
@ -193,47 +175,76 @@ class Pterodactyl(commands.Cog):
|
|||
|
||||
async def power(self, ctx: Union[discord.Interaction, commands.Context], action: str, action_ing: str, warning: str = '') -> None:
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
ctx = await self.bot.get_context(ctx)
|
||||
author = ctx.user
|
||||
else:
|
||||
author = ctx.author
|
||||
|
||||
current_status = await config.current_status()
|
||||
|
||||
if current_status == action_ing:
|
||||
return await ctx.send(f"Server is already {action_ing}.", ephemeral=True)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
return await ctx.response.send_message(f"Server is already {action_ing}.", ephemeral=True)
|
||||
return await ctx.send(f"Server is already {action_ing}.")
|
||||
|
||||
if current_status in ["starting", "stopping"] and action != "kill":
|
||||
return await ctx.send("Another power action is already in progress.", ephemeral=True)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
return await ctx.response.send_message("Another power action is already in progress.", ephemeral=True)
|
||||
return await ctx.send("Another power action is already in progress.")
|
||||
|
||||
view = ConfirmView(ctx.author, disable_buttons=True)
|
||||
view = ConfirmView(author, disable_buttons=True)
|
||||
|
||||
message = await ctx.send(f"{warning}Are you sure you want to {action} the server?", view=view)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
await ctx.response.send_message(f"{warning}Are you sure you want to {action} the server?", view=view)
|
||||
else:
|
||||
message = await ctx.send(f"{warning}Are you sure you want to {action} the server?", view=view)
|
||||
|
||||
await view.wait()
|
||||
|
||||
if view.result is True:
|
||||
await message.edit(content=f"Sending websocket command to {action} server...", view=None)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
await ctx.edit_original_response(content=f"Sending websocket command to {action} server...", view=None)
|
||||
else:
|
||||
await message.edit(content=f"Sending websocket command to {action} server...", view=None)
|
||||
|
||||
await self.websocket.send(json.dumps({"event": "set state", "args": [action]}))
|
||||
|
||||
await message.edit(content=f"Server {action_ing}", view=None)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
await ctx.edit_original_response(content=f"Server {action_ing}", view=None)
|
||||
else:
|
||||
await message.edit(content=f"Server {action_ing}", view=None)
|
||||
|
||||
else:
|
||||
await message.edit(content="Cancelled.", view=None)
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
await ctx.edit_original_response(content="Cancelled.", view=None)
|
||||
else:
|
||||
await message.edit(content="Cancelled.", view=None)
|
||||
|
||||
async def send_command(self, ctx: Union[discord.Interaction, commands.Context], command: str):
|
||||
channel = self.bot.get_channel(await config.console_channel())
|
||||
if isinstance(ctx, discord.Interaction):
|
||||
ctx = await self.bot.get_context(ctx)
|
||||
if channel:
|
||||
await channel.send(f"Received console command from {ctx.author.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
|
||||
try:
|
||||
await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
|
||||
await ctx.send(f"Command sent to server. {box(command, 'json')}")
|
||||
except websockets.exceptions.ConnectionClosed as e:
|
||||
logger.error("WebSocket connection closed: %s", e)
|
||||
await ctx.send(error("WebSocket connection closed."))
|
||||
self.task.cancel()
|
||||
self.retry_counter = 0
|
||||
self.task = self.get_task()
|
||||
if channel:
|
||||
await channel.send(f"Received console command from {ctx.user.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
|
||||
try:
|
||||
await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
|
||||
await ctx.response.send_message(f"Command sent to server. {box(command, 'json')}", ephemeral=True)
|
||||
except websockets.exceptions.ConnectionClosed as e:
|
||||
logger.error("WebSocket connection closed: %s", e)
|
||||
await ctx.response.send_message(error("WebSocket connection closed."))
|
||||
self.task.cancel()
|
||||
self.retry_counter = 0
|
||||
self.task = self.get_task()
|
||||
else:
|
||||
if channel:
|
||||
await channel.send(f"Received console command from {ctx.author.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
|
||||
try:
|
||||
await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
|
||||
await ctx.send(f"Command sent to server. {box(command, 'json')}")
|
||||
except websockets.exceptions.ConnectionClosed as e:
|
||||
logger.error("WebSocket connection closed: %s", e)
|
||||
await ctx.send(error("WebSocket connection closed."))
|
||||
self.task.cancel()
|
||||
self.retry_counter = 0
|
||||
self.task = self.get_task()
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_red_api_tokens_update(self, service_name: str, api_tokens: Mapping[str,str]): # pylint: disable=unused-argument
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
# pylint: disable=cyclic-import
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple, Union
|
||||
from typing import Optional, Union
|
||||
|
||||
import aiohttp
|
||||
import discord
|
||||
import websockets
|
||||
from pydactyl import PterodactylClient
|
||||
from redbot.core.data_manager import bundled_data_path
|
||||
from redbot.core.utils.chat_formatting import bold, pagify
|
||||
|
||||
from pterodactyl.config import config
|
||||
|
@ -36,6 +34,7 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
|||
|
||||
while True: # pylint: disable=too-many-nested-blocks
|
||||
message = json.loads(await websocket.recv())
|
||||
logger.verbose("Received message: %s", message)
|
||||
if message['event'] in ('token expiring', 'token expired'):
|
||||
logger.info("Received token expiring/expired event. Refreshing token.")
|
||||
websocket_credentials = await retrieve_websocket_credentials(coginstance)
|
||||
|
@ -46,69 +45,61 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
|||
if message['event'] == 'auth success':
|
||||
logger.info("WebSocket authentication successful")
|
||||
|
||||
if message['event'] == 'console output' and await config.console_channel() is not None:
|
||||
regex_blacklist: dict = await config.regex_blacklist()
|
||||
matches = [re.search(regex, message['args'][0]) for regex in regex_blacklist.values()]
|
||||
if message['event'] == 'console output':
|
||||
content = remove_ansi_escape_codes(message['args'][0])
|
||||
if await config.mask_ip() is True:
|
||||
content = mask_ip(content)
|
||||
logger.verbose("Received console output: %s", content)
|
||||
|
||||
if await config.current_status() in ('running', '') and not any(matches):
|
||||
content = remove_ansi_escape_codes(message['args'][0])
|
||||
if await config.mask_ip() is True:
|
||||
content = mask_ip(content)
|
||||
if await config.console_channel() is not None:
|
||||
regex_blacklist: dict = await config.regex_blacklist()
|
||||
matches = [re.search(regex, message['args'][0]) for regex in regex_blacklist.values()]
|
||||
|
||||
console_channel = coginstance.bot.get_channel(await config.console_channel())
|
||||
chat_channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if console_channel is not None:
|
||||
if content.startswith('['):
|
||||
pagified_content = pagify(content, delims=[" ", "\n"])
|
||||
for page in pagified_content:
|
||||
await console_channel.send(content=page, allowed_mentions=discord.AllowedMentions.none())
|
||||
if await config.current_status() in ('running', '') and not any(matches):
|
||||
console_channel = coginstance.bot.get_channel(await config.console_channel())
|
||||
chat_channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if console_channel is not None:
|
||||
if content.startswith('['):
|
||||
pagified_content = pagify(content, delims=[" ", "\n"])
|
||||
for page in pagified_content:
|
||||
await console_channel.send(content=page, allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
server_message = await check_if_server_message(content)
|
||||
if server_message:
|
||||
if chat_channel is not None:
|
||||
await chat_channel.send(server_message if len(server_message) < 2000 else server_message[:1997] + '...', allowed_mentions=discord.AllowedMentions.none())
|
||||
server_message = await check_if_server_message(content)
|
||||
if server_message:
|
||||
if chat_channel is not None:
|
||||
await chat_channel.send(server_message if len(server_message) < 2000 else server_message[:1997] + '...', allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
chat_message = await check_if_chat_message(content)
|
||||
if chat_message:
|
||||
info = await get_info(chat_message['username'])
|
||||
if info is not None:
|
||||
await send_chat_discord(coginstance, chat_message['username'], chat_message['message'], info['data']['player']['avatar'])
|
||||
else:
|
||||
await send_chat_discord(coginstance, chat_message['username'], chat_message['message'], 'https://seafsh.cc/u/j3AzqQ.png')
|
||||
chat_message = await check_if_chat_message(content)
|
||||
if chat_message:
|
||||
info = await get_info(chat_message['username'])
|
||||
if info is not None:
|
||||
await send_chat_discord(coginstance, chat_message['username'], chat_message['message'], info['data']['player']['avatar'])
|
||||
else:
|
||||
await send_chat_discord(coginstance, chat_message['username'], chat_message['message'], 'https://seafsh.cc/u/j3AzqQ.png')
|
||||
|
||||
join_message = await check_if_join_message(content)
|
||||
if join_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
embed, img = await generate_join_leave_embed(coginstance=coginstance, username=join_message,join=True)
|
||||
if img:
|
||||
with open(img, 'rb') as file:
|
||||
await chat_channel.send(embed=embed, file=file)
|
||||
join_message = await check_if_join_message(content)
|
||||
if join_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_join_leave_embed(join_message, True))
|
||||
else:
|
||||
await chat_channel.send(embed=embed)
|
||||
else:
|
||||
await chat_channel.send(f"{join_message} joined the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
await chat_channel.send(f"{join_message} joined the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
leave_message = await check_if_leave_message(content)
|
||||
if leave_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
embed, img = await generate_join_leave_embed(coginstance=coginstance, username=leave_message,join=False)
|
||||
if img:
|
||||
with open(img, 'rb') as file:
|
||||
await chat_channel.send(embed=embed, file=file)
|
||||
leave_message = await check_if_leave_message(content)
|
||||
if leave_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_join_leave_embed(leave_message, False))
|
||||
else:
|
||||
await chat_channel.send(embed=embed)
|
||||
else:
|
||||
await chat_channel.send(f"{leave_message} left the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
await chat_channel.send(f"{leave_message} left the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
achievement_message = await check_if_achievement_message(content)
|
||||
if achievement_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_achievement_embed(coginstance, achievement_message['username'], achievement_message['achievement'], achievement_message['challenge']))
|
||||
else:
|
||||
await chat_channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}")
|
||||
achievement_message = await check_if_achievement_message(content)
|
||||
if achievement_message:
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_achievement_embed(achievement_message['username'], achievement_message['achievement'], achievement_message['challenge']))
|
||||
else:
|
||||
await chat_channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}")
|
||||
|
||||
if message['event'] == 'status':
|
||||
old_status = await config.current_status()
|
||||
|
@ -154,18 +145,18 @@ async def retrieve_websocket_credentials(coginstance: Pterodactyl) -> Optional[d
|
|||
websocket_credentials['data']['token'][:20]
|
||||
)
|
||||
return websocket_credentials
|
||||
#NOTE - The token is truncated to prevent it from being logged in its entirety, for security reasons
|
||||
# The token is truncated to prevent it from being logged in its entirety, for security reasons
|
||||
|
||||
def remove_ansi_escape_codes(text: str) -> str:
|
||||
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
||||
#NOTE - https://chat.openai.com/share/d92f9acf-d776-4fd6-a53f-b14ac15dd540
|
||||
# https://chatgpt.com/share/d92f9acf-d776-4fd6-a53f-b14ac15dd540
|
||||
return ansi_escape.sub('', text)
|
||||
|
||||
async def check_if_server_message(text: str) -> Union[bool, str]:
|
||||
regex = await config.server_regex()
|
||||
match: Optional[re.Match[str]] = re.match(regex, text)
|
||||
if match:
|
||||
logger.trace("Message is a server message")
|
||||
logger.debug("Message is a server message")
|
||||
return match.group(1)
|
||||
return False
|
||||
|
||||
|
@ -174,7 +165,7 @@ async def check_if_chat_message(text: str) -> Union[bool, dict]:
|
|||
match: Optional[re.Match[str]] = re.match(regex, text)
|
||||
if match:
|
||||
groups = {"username": match.group(1), "message": match.group(2)}
|
||||
logger.trace("Message is a chat message\n%s", json.dumps(groups))
|
||||
logger.debug("Message is a chat message\n%s", json.dumps(groups))
|
||||
return groups
|
||||
return False
|
||||
|
||||
|
@ -182,7 +173,7 @@ async def check_if_join_message(text: str) -> Union[bool, str]:
|
|||
regex = await config.join_regex()
|
||||
match: Optional[re.Match[str]] = re.match(regex, text)
|
||||
if match:
|
||||
logger.trace("Message is a join message")
|
||||
logger.debug("Message is a join message")
|
||||
return match.group(1)
|
||||
return False
|
||||
|
||||
|
@ -190,7 +181,7 @@ async def check_if_leave_message(text: str) -> Union[bool, str]:
|
|||
regex = await config.leave_regex()
|
||||
match: Optional[re.Match[str]] = re.match(regex, text)
|
||||
if match:
|
||||
logger.trace("Message is a leave message")
|
||||
logger.debug("Message is a leave message")
|
||||
return match.group(1)
|
||||
return False
|
||||
|
||||
|
@ -203,23 +194,23 @@ async def check_if_achievement_message(text: str) -> Union[bool, dict]:
|
|||
groups["challenge"] = True
|
||||
else:
|
||||
groups["challenge"] = False
|
||||
logger.trace("Message is an achievement message")
|
||||
logger.debug("Message is an achievement message")
|
||||
return groups
|
||||
return False
|
||||
|
||||
async def get_info(username: str) -> Optional[dict]:
|
||||
logger.verbose("Retrieving player info for %s", username)
|
||||
logger.debug("Retrieving player info for %s", username)
|
||||
endpoint = await config.api_endpoint()
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(f"https://playerdb.co/api/player/{endpoint}/{username}") as response:
|
||||
if response.status == 200:
|
||||
logger.verbose("Player info retrieved for %s", username)
|
||||
logger.debug("Player info retrieved for %s", username)
|
||||
return await response.json()
|
||||
logger.warning("Failed to retrieve player info for %s: %s", username, response.status)
|
||||
logger.error("Failed to retrieve player info for %s: %s", username, response.status)
|
||||
return None
|
||||
|
||||
async def send_chat_discord(coginstance: Pterodactyl, username: str, message: str, avatar_url: str) -> None:
|
||||
logger.trace("Sending chat message to Discord")
|
||||
logger.debug("Sending chat message to Discord")
|
||||
channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if channel is not None:
|
||||
webhooks = await channel.webhooks()
|
||||
|
@ -227,37 +218,33 @@ async def send_chat_discord(coginstance: Pterodactyl, username: str, message: st
|
|||
if webhook is None:
|
||||
webhook = await channel.create_webhook(name="Pterodactyl Chat")
|
||||
await webhook.send(content=message, username=username, avatar_url=avatar_url, allowed_mentions=discord.AllowedMentions(everyone=False, roles=False, users=True))
|
||||
logger.trace("Chat message sent to Discord")
|
||||
logger.debug("Chat message sent to Discord")
|
||||
else:
|
||||
logger.warning("Chat channel not set. Skipping sending chat message to Discord")
|
||||
|
||||
async def generate_join_leave_embed(coginstance: Pterodactyl, username: str, join: bool) -> Tuple[discord.Embed, Optional[Union[str, Path]]]:
|
||||
async def generate_join_leave_embed(username: str, join: bool) -> discord.Embed:
|
||||
embed = discord.Embed()
|
||||
embed.color = discord.Color.green() if join else discord.Color.red()
|
||||
embed.description = await config.join_msg() if join else await config.leave_msg()
|
||||
info = await get_info(username)
|
||||
if info:
|
||||
img = None
|
||||
embed.set_author(name=username, icon_url=info['data']['player']['avatar'])
|
||||
else:
|
||||
img = bundled_data_path(coginstance) / "unknown.png"
|
||||
embed.set_author(name=username, icon_url='attachment://unknown.png')
|
||||
embed.set_author(name=username, icon_url='https://seafsh.cc/u/j3AzqQ.png')
|
||||
embed.timestamp = discord.utils.utcnow()
|
||||
return embed, img
|
||||
return embed
|
||||
|
||||
async def generate_achievement_embed(coginstance: Pterodactyl, username: str, achievement: str, challenge: bool) -> Tuple[discord.Embed, Optional[Union[str, Path]]]:
|
||||
async def generate_achievement_embed(username: str, achievement: str, challenge: bool) -> discord.Embed:
|
||||
embed = discord.Embed()
|
||||
embed.color = discord.Color.from_str('#a800a7') if challenge else discord.Color.from_str('#54fb54')
|
||||
embed.description = f"{bold(username)} has {'completed the challenge' if challenge else 'made the advancement'} {bold(achievement)}"
|
||||
info = await get_info(username)
|
||||
if info:
|
||||
img = None
|
||||
embed.set_author(name=username, icon_url=info['data']['player']['avatar'])
|
||||
else:
|
||||
img = bundled_data_path(coginstance) / "unknown.png"
|
||||
embed.set_author(name=username, icon_url='attachment://unknown.png')
|
||||
embed.set_author(name=username, icon_url='https://seafsh.cc/u/j3AzqQ.png')
|
||||
embed.timestamp = discord.utils.utcnow()
|
||||
return embed, img
|
||||
return embed
|
||||
|
||||
def mask_ip(string: str) -> str:
|
||||
def check(match: re.Match[str]):
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
[project]
|
||||
[tool.poetry]
|
||||
name = "seacogs"
|
||||
version = "0.1.0"
|
||||
description = "My assorted cogs for Red-DiscordBot."
|
||||
authors = [{name = "cswimr", email = "seaswimmerthefsh@gmail.com"}]
|
||||
license = {file="LICENSE"}
|
||||
authors = ["SeaswimmerTheFsh"]
|
||||
license = "MPL 2"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"aiosqlite>=0.20.0",
|
||||
"beautifulsoup4>=4.12.3",
|
||||
"colorthief>=0.2.1",
|
||||
"markdownify>=0.13.1",
|
||||
"numpy>=2.1.2",
|
||||
"phx-class-registry>=5.0.0",
|
||||
"pillow>=10.4.0",
|
||||
"py-dactyl",
|
||||
"pydantic>=2.9.2",
|
||||
"red-discordbot>=3.5.13",
|
||||
"websockets>=13.1",
|
||||
]
|
||||
package-mode = false
|
||||
|
||||
[project.optional-dependencies]
|
||||
documentation = [
|
||||
"mkdocs>=1.6.1",
|
||||
"mkdocs-git-authors-plugin>=0.9.0",
|
||||
"mkdocs-git-revision-date-localized-plugin>=1.2.9",
|
||||
"mkdocs-material[imaging]>=9.5.40",
|
||||
"mkdocstrings[python]>=0.26.1",
|
||||
"mkdocs-redirects>=1.2.1",
|
||||
]
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.11,<3.12"
|
||||
Red-DiscordBot = "^3.5.5"
|
||||
py-dactyl = "^2.0.4"
|
||||
websockets = "^12.0"
|
||||
pillow = "^10.3.0"
|
||||
numpy = "^1.26.4"
|
||||
colorthief = "^0.2.1"
|
||||
beautifulsoup4 = "^4.12.3"
|
||||
markdownify = "^0.12.1"
|
||||
|
||||
[tool.uv]
|
||||
dev-dependencies = [
|
||||
"pylint>=3.3.1",
|
||||
"ruff>=0.6.9",
|
||||
"sqlite-web>=0.6.4",
|
||||
]
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
[tool.uv.sources]
|
||||
py-dactyl = { git = "https://github.com/cswimr/pydactyl" }
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ruff = "^0.3.1"
|
||||
pylint = "^3.1.0"
|
||||
|
||||
[tool.poetry.group.docs]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs = "1.5.3"
|
||||
mkdocstrings = {extras = ["python"], version = "0.24.0"}
|
||||
mkdocs-git-authors-plugin = "0.7.2"
|
||||
mkdocs-git-revision-date-localized-plugin = "1.2.2"
|
||||
mkdocs-material = {extras = ["imaging"], version = "^9.5.2"}
|
||||
mkdocs-redirects = "^1.2.1"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.ruff]
|
||||
# Exclude a variety of commonly ignored directories.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"author" : ["cswimr"],
|
||||
"install_msg" : "Thank you for installing SeaUtils!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
|
||||
"author" : ["SeaswimmerTheFsh (seasw.)"],
|
||||
"install_msg" : "Thank you for installing SeaUtils!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).",
|
||||
"name" : "SeaUtils",
|
||||
"short" : "A collection of useful utilities.",
|
||||
"description" : "A collection of useful utilities.",
|
||||
|
|
|
@ -38,26 +38,22 @@ def format_rfc_text(text: str, number: int) -> str:
|
|||
class SeaUtils(commands.Cog):
|
||||
"""A collection of random utilities."""
|
||||
|
||||
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
|
||||
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
|
||||
__version__ = "1.0.1"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/seautils/"
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "1.0.0"
|
||||
|
||||
def __init__(self, bot: Red) -> None:
|
||||
self.bot = bot
|
||||
|
||||
def format_help_for_context(self, ctx: commands.Context) -> str:
|
||||
pre_processed = super().format_help_for_context(ctx) or ""
|
||||
pre_processed = super().format_help_for_context(ctx=ctx) or ""
|
||||
n = "\n" if "\n\n" not in pre_processed else ""
|
||||
text = [
|
||||
f"{pre_processed}{n}",
|
||||
f"{cf.bold('Cog Version:')} [{self.__version__}]({self.__git__})",
|
||||
f"{cf.bold('Author:')} {cf.humanize_list(self.__author__)}",
|
||||
f"{cf.bold('Documentation:')} {self.__documentation__}",
|
||||
f"Cog Version: **{self.__version__}**",
|
||||
f"Author: {cf.humanize_list(items=self.__author__)}"
|
||||
]
|
||||
return "\n".join(text)
|
||||
|
||||
|
||||
def format_src(self, obj: Any) -> str:
|
||||
"""A large portion of this code is repurposed from Zephyrkul's RTFS cog.
|
||||
https://github.com/Zephyrkul/FluffyCogs/blob/master/rtfs/rtfs.py"""
|
||||
|
@ -251,4 +247,4 @@ class SeaUtils(commands.Cog):
|
|||
embed.set_footer(text=f"Page {content.index(embed) + 1}/{len(content)}")
|
||||
await SimpleMenu(pages=content, disable_after_timeout=True, timeout=300).start(ctx)
|
||||
else:
|
||||
await ctx.maybe_send_embed(message=cf.error(f"An error occurred while fetching RFC {number}. Status code: {response.status}."))
|
||||
await ctx.maybe_send_embed(content=cf.error(f"An error occurred while fetching RFC {number}. Status code: {response.status}."))
|
||||
|
|
Loading…
Reference in a new issue