Compare commits

..

124 commits

Author SHA1 Message Date
9549690767
Merge remote-tracking branch 'origin/main' into tts
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 50s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 1m2s
2024-09-15 23:40:34 -04:00
a43fd3cce1
added __pycache__ to .gitignore 2024-09-15 11:14:14 -04:00
1392a9324a
chore(poetry): update deps
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 34s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 44s
2024-08-28 17:01:58 -04:00
9cba1767e6
fix(repo): update all instances of SeaswimmerTheFsh to cswimr
Some checks failed
Actions / Build Documentation (MkDocs) (push) Failing after 22s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 39s
2024-08-27 14:25:14 -04:00
cbfff6d211
fix(backup): update for red 3.5.13
All checks were successful
Actions / Lint Code (Ruff & Pylint) (push) Successful in 40s
Actions / Build Documentation (MkDocs) (push) Successful in 28s
2024-08-27 14:22:38 -04:00
56d1e14454
feat(repo): updated all cogs (except aurora) to use the help formatting present in the indev version of aurora 2024-08-27 14:22:19 -04:00
571be4e245
fix(pterodactyl): fixed a missing argument in one of the websocket events
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 37s
2024-08-27 14:05:10 -04:00
6b2793e692
fix(actions): updated container tags
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-08-27 14:03:15 -04:00
ad0bb7cf00
fix(pterodactyl): fixed join and leave listeners throwing errors
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 31s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 56s
2024-08-26 19:43:57 -04:00
1244d5a941
fix(pterodactyl): don't depend on a website to host images when i can bundle image files in the cog itself
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 30s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 54s
2024-08-26 17:46:42 -04:00
1c0f12660b
chore(pterodactyl): clean up some dirty code
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 30s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 54s
2024-08-26 15:03:37 -04:00
b4a54d214d
misc(poetry): add sqlite-web dev dependency
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 29s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 50s
2024-08-21 14:31:49 -04:00
260438f397
misc(poetry): update to red 3.5.12
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 32s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 45s
2024-08-21 00:17:48 -04:00
5bfb74de47
fix(seautils): fixed a maybe_send_embed call having an invalid kwarg
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 31s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 44s
2024-08-13 02:39:40 -04:00
b7bde42672
Update backup/info.json
All checks were successful
Actions / Lint Code (Ruff & Pylint) (push) Successful in 45s
Actions / Build Documentation (MkDocs) (push) Successful in 34s
2024-08-08 00:36:44 -04:00
0f36badbea
update backup for Red 3.5.11
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 32s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 42s
2024-08-05 14:22:26 -04:00
f04b452396
add __pycache__ to .gitignore
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 32s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 45s
2024-08-02 10:33:49 -04:00
7d4a6b9930
Update antipolls/info.json
All checks were successful
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
Actions / Build Documentation (MkDocs) (push) Successful in 29s
2024-07-23 13:54:04 -04:00
f6570dd072
docs(pterodactyl): fixed some incorrect markdown formatting in one of the admonitions
All checks were successful
Actions / Lint Code (Ruff & Pylint) (push) Successful in 43s
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Signed-off-by: Seaswimmer <seaswimmerthefsh@gmail.com>
2024-07-12 13:52:22 -04:00
ff68d6ea19
docs(backup): removed reload from the backup docs
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 38s
due to some techincal limitations, the `backup` cog does not actually reload cogs it reinstalls. the end user still has to do that, this is because there's no good way for `backup` to confirm if a cog is loaded or not whenever exporting the list of repos/cogs.

Signed-off-by: Seaswimmer <seaswimmerthefsh@gmail.com>
2024-07-11 23:30:42 +00:00
825a373a9b
fix(backup): support 3.5.10
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
2024-07-11 23:20:06 +00:00
d173dd68a5
fix(workflow): nvm
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
2024-06-11 16:50:15 -04:00
24239425c5
fix(workflows): missing -e argument
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 40s
2024-06-11 16:48:03 -04:00
e3e96e5b84
fix(workflow): changed meli token
Some checks failed
Actions / Build Documentation (MkDocs) (push) Failing after 25s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 38s
2024-06-11 16:39:04 -04:00
28f814db56
fix(seautils): pylint fix
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 45s
2024-06-04 12:16:09 -04:00
7354769962
fix(emojiinfo): pylint fix 2024-06-04 12:16:01 -04:00
2ac1dacd19
fix(backup): added another error type caught by backup import, in the case where you didn't reply to a message or upload a file
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 43s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 1m9s
2024-06-03 01:10:00 -04:00
66b933569b
misc(seautils): soup
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 38s
2024-06-01 15:03:23 -04:00
c06db07f08
misc(seautils): bunch of miscellaneous changes
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
2024-06-01 15:02:08 -04:00
46f189a297
fix(seautils): pylint fix
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 37s
2024-05-30 11:02:22 -04:00
545106d496
fix(seautils): fixed a typo in a function name
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 22:25:47 -04:00
037a26deb0
misc(seautils): switch to datatracker.ietf.org links for publicly facing urls
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 22:20:51 -04:00
f51329524c
fix(seautils): oops lmao
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 22:19:09 -04:00
5b23f2f0fb
feat(seautils): add the url of the rfc document being retrieved to the embed
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 22:17:20 -04:00
8f492cd937
fix(seautils): hopefully actually fixed the docstring
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 41s
2024-05-28 22:14:35 -04:00
dfabac55f5
misc(seautils): hopefully fixed [p]rfc's help from overflowing into a second page
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 22:13:18 -04:00
4f25e3d0f3
fix(seautils): removed some text from the rfc docstring
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
Actions / Build Documentation (MkDocs) (push) Successful in 26s
2024-05-28 22:11:11 -04:00
7207cd3747
misc(seautils): improved the rfc docstring
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 22:09:56 -04:00
069ea800db
feat(seautils): added a detailed docstring to the rfc command
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 22:02:42 -04:00
58245c621c
misc(seautils): changed a function name 2024-05-28 21:58:20 -04:00
b9f0dbf98a
fix(seautils): removed big gap at the bottom of rfc embeds
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 21:56:43 -04:00
2d895d16c9
fix(seautils): fixed body error
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 21:54:48 -04:00
861a03719b
fix(seautils): added a bad solution to a stupid problem
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 21:22:30 -04:00
ac5d4df36b
fix(seautils): fixed broken regex
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 21:18:49 -04:00
ae8d0d5db4
fix(seautils): added missing ()
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 21:17:29 -04:00
0ea80075f6
fix(seautils): fixed a missing argument
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 41s
2024-05-28 21:16:45 -04:00
8d3f5c1d5f
fix(seautils): fix table of contents in rfc documents
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Has been cancelled
2024-05-28 21:16:10 -04:00
42e209b547
misc(seautils): include the number of the rfc document in the embed
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 21:10:28 -04:00
0ed96babdb
fix(seautils): ACTUALLY fixed broken regex
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 20:40:48 -04:00
29b6a2141a
fix(seautils): actually actually fixed incorrect regex
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 20:39:19 -04:00
c4ef2a7d4b
fix(seautils): fixed some broken regex
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 20:38:39 -04:00
99cd13ccf1
feat(seautils): add correct formatting for masked links
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 20:35:25 -04:00
28246121a6
feat(seautils): use markdownify to convert rfc html documents to markdown
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 20:29:39 -04:00
a641cae640
feat(seautils): add [p]rfc command
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-28 20:20:21 -04:00
2886d5e80d
feat(seautils): use prolog syntax highlighting for dig results
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 19:29:26 -04:00
50094b85fc
fix(seautils): fixed the wrong thing lmao
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 19:26:07 -04:00
7f46d6accc
fix(seautils): fixed empty answer section
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 19:25:01 -04:00
cb6ddabb4d
fix(seautils): prevent duplicates in dig
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 19:10:15 -04:00
8608e6a34e
fix(seautils): fixed only the first A response being used
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 19:06:11 -04:00
fb468ee63e
fix(seautils): retrieve A, AAAA, and CNAME records by default (& docstring changes)
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 18:55:09 -04:00
b27a3ee778
fix(seautils): fall back to the embed description if answer_section is too long
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 18:46:32 -04:00
54491cb9c9
fix(seautils): convert port number to a string
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 36s
2024-05-28 18:44:01 -04:00
29bb64b35c
fix(seautils): query ANY instead of A records
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 18:42:42 -04:00
5ffc42480a
fix(seautils): revert breaking dig
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 39s
2024-05-28 18:40:43 -04:00
7d51814a28
misc(seautils): purposefully breaking dig so i can test nslookup fallback
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 18:35:17 -04:00
25fdf7b402
feat(seautils): default to nslookup if dig is not present
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 18:31:38 -04:00
091f4fe36d
fix(seautils): fixed maybe_send_message
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 18:02:17 -04:00
d444242245
fix(seautils): catch the error that is raised if dig is not installed on the system
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 18:01:35 -04:00
7a2ee0a655
misc(seautils): added an error symbol to the failed dns query result message
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 17:57:10 -04:00
8b68cb7530
fix(seautils): don't use match and case
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 17:54:46 -04:00
028cae9e99
feat(seautils): improve error code handling
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 17:53:58 -04:00
aa7e347a95
fix(seautils): fix a keyerror
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-28 17:48:00 -04:00
93f358cfad
fix(seautils): fixed timestamp
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 17:46:14 -04:00
8867cc627f
feat(seautils): add an embed to the dig command
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 24s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 37s
2024-05-28 16:33:15 -04:00
e2059eac77
Merge branch 'main' of https://www.coastalcommits.com/Seaswimmer/SeaCogs
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 24s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 36s
2024-05-28 16:23:56 -04:00
e9c062afa9
feat(seautils): added dig command 2024-05-28 16:22:22 -04:00
Sea
ee9b62db5b
misc(repo): add index_name key to info.json
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 40s
2024-05-23 18:00:56 +00:00
1405dae49e
fix(aurora): add roles to evidenceformat
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
2024-05-20 20:59:01 -04:00
7ed836a1cd
fix(seautils): pylint fixes
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 42s
2024-05-19 00:18:48 -04:00
d95c9b3255
fix(emojiinfo): oops lmao
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 26s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
2024-05-17 00:57:30 -04:00
c9a47603a7
fix(emojiinfo): add a debug logging call
Some checks failed
Actions / Lint Code (Ruff & Pylint) (push) Failing after 38s
Actions / Build Documentation (MkDocs) (push) Successful in 25s
2024-05-17 00:48:14 -04:00
d8758cfb1d
misc(emojiinfo): verbosity
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 25s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 41s
2024-05-17 00:46:25 -04:00
3fd91d9776
misc(emojiinfo): default slash command to ephemeral true
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 44s
2024-05-17 00:44:19 -04:00
d556ee3704
fix(seautils): minor syntax change
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-17 00:20:00 -04:00
7019b9ffe5
fix(seautils): catch an UnboundLocalError
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 40s
2024-05-17 00:14:33 -04:00
5116598788
feat(seautils): add support for cogs and slash commands
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 42s
2024-05-17 00:12:40 -04:00
2dcbcb0a59
fix(seautils): use ctx.embed_requested()
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 40s
2024-05-13 21:14:15 -04:00
059badaa9b
fix(seautils): use length_hint
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 42s
2024-05-13 21:12:51 -04:00
84d2728d3a
misc(seautils): optimized showcode
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 40s
2024-05-13 21:11:15 -04:00
bb1aca83dd
feat(seautils): added some more functionality to showcode
All checks were successful
Actions / Lint Code (Ruff & Pylint) (push) Successful in 38s
Actions / Build Documentation (MkDocs) (push) Successful in 40s
2024-05-13 21:09:02 -04:00
59848fe857
misc(seautils): added more aliases to showcode
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 29s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 43s
2024-05-13 20:22:13 -04:00
516c0feecc
fix(seautils): catch the attributeerror
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 41s
2024-05-13 20:17:00 -04:00
7bd9531b58
feat(seautils): added the cog
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 30s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 44s
2024-05-13 19:26:13 -04:00
09ab8aa69d
docs(emojiinfo): changed a string
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 42s
2024-05-08 16:11:09 -04:00
fb34593707
docs(emojiinfo): made docs visible on the navigation header
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Has been cancelled
2024-05-08 16:10:34 -04:00
ebdd3e3525
Merge pull request 'Add EmojiInfo cog' (#27) from emoji into main
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 42s
Reviewed-on: SeaswimmerTheFsh/SeaCogs#27
2024-05-08 20:07:30 +00:00
e1bfa79cb9
fix(emojiinfo): pylint fixes
All checks were successful
Actions / Build Documentation (MkDocs) (pull_request) Successful in 29s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 44s
2024-05-08 16:06:22 -04:00
e59503829f
fix(emojiinfo): add the PartialEmoji.from_str call to the try and except blocks
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 29s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 43s
2024-05-08 16:02:56 -04:00
d126f1e6d3
fix(emojiinfo): made the ephemeral argument optional in the slash command 2024-05-08 16:00:36 -04:00
66df7664a5
fix(emojiinfo): awaited a coroutine 2024-05-08 15:59:10 -04:00
ce53908938
fix(emojiinfo): seperated the slash command from the normal command 2024-05-08 15:58:26 -04:00
8f6afe754d
docs(emojiinfo): added documentation 2024-05-08 15:49:19 -04:00
aa6e0d7590
fix(emojiinfo): added descriptions to the application command parameters 2024-05-08 15:48:18 -04:00
d65d04fa7a
fix(emojiinfo): added group to the emojiinfo string 2024-05-08 15:40:58 -04:00
bc9bc53967
fix(emojiinfo): fixed another unboundlocal error 2024-05-08 15:39:51 -04:00
2b5a00f512
fix(emojiinfo): fixed an unboundlocal error 2024-05-08 15:38:51 -04:00
4bf3e85df2
fix(emojiinfo): fixed a syntax error 2024-05-08 15:37:20 -04:00
ce595e50da
fix(emojiinfo): open the emojis.json file before attempting to read from it 2024-05-08 15:36:17 -04:00
9ed16a44f2
feat(emojiinfo): added aliases and groups 2024-05-08 15:34:04 -04:00
59097b676d
fix(emojiinfo): forgot to return early lol 2024-05-08 14:46:28 -04:00
537b2edafa
fix(emojiinfo): catch errors if the emoji is invalid 2024-05-08 14:45:46 -04:00
8ebb383a84
fix(emojiinfo): fixed an issue with markdown 2024-05-08 14:38:39 -04:00
1ed1eb2681
fix(emojiinfo): fixed a syntax error 2024-05-08 14:35:47 -04:00
a02a7ab3d7
fix(emojiinfo): fixed formatting 2024-05-08 14:34:28 -04:00
80dcfea95e
fix(emojiinfo): use aiohttp.ClientSession 2024-05-08 14:30:07 -04:00
7ae8226ca5
fix(emojiinfo): added colorthief to the requirements 2024-05-08 14:26:40 -04:00
b910d8c614
feat(emojiinfo): added most of the cog's functionality 2024-05-08 14:26:03 -04:00
d87c37239d
fix(emojiinfo): fixed error if you input a default discord emoji 2024-05-08 13:58:58 -04:00
c266997a78
fix(emojiinfo): use commands.Cog instead of commands.cog 2024-05-08 13:54:55 -04:00
20c3007306
renamed emoji to emojiinfo 2024-05-08 13:53:21 -04:00
8fdf587bde
fix(emoji): specify a name for the hybrid command 2024-05-08 13:50:46 -04:00
ea1f7a7f8e
fix(emoji): fixed the cog refusing to load 2024-05-08 13:47:33 -04:00
384ce7fc6d
feat(emoji): added the cog 2024-05-08 13:43:33 -04:00
c618f9be72
fix(aurora): updated the aurora importer to have all of the currently implemented moderation types
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 33s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 46s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 31s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 43s
2024-05-04 12:57:27 -04:00
43 changed files with 7153 additions and 1073 deletions

View file

@ -10,7 +10,7 @@ Aurora is a fully-featured moderation system. It is heavily inspired by Galactic
## Installation ## Installation
```bash ```bash
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs aurora [p]cog install seacogs aurora
[p]cog load aurora [p]cog load aurora
``` ```

View file

@ -1,18 +1,18 @@
# Backup # Backup
Backup allows you to export a JSON list of all of your installed repositories and cogs, then reimport them and automatically reinstall/reload the cogs. Backup allows you to export a JSON list of all of your installed repositories and cogs, then reimport them and automatically reinstall the cogs.
## Installation ## Installation
```bash ```bash
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs backup [p]cog install seacogs backup
[p]cog load backup [p]cog load backup
``` ```
## Version Compatibility ## Version Compatibility
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`. 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`.
```bash ```bash
[p]cog installversion sea-cogs 43464db6a7c51bc69282b1ae3dc507a4aae851de backup [p]cog installversion sea-cogs 43464db6a7c51bc69282b1ae3dc507a4aae851de backup

View file

@ -6,7 +6,7 @@ This cog does require an api key to work.
## Installation ## Installation
```bash ```bash
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs bible [p]cog install seacogs bible
[p]cog load bible [p]cog load bible
``` ```

19
.docs/emojiinfo.md Normal file
View file

@ -0,0 +1,19 @@
# EmojiInfo
EmojiInfo allows you to retrieve information about an emoji.
## Installation
```bash
[p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs emojiinfo
[p]cog load emojiinfo
```
## Commands
### emoji
- Usage: `[p]emoji <emoji> [ephemeral]`
Retrieve information about the provided emoji. If `ephemeral` is provided and the command is used as a slash command, the response will be sent as an ephemeral message.

View file

@ -5,7 +5,7 @@ Nerdify allows you to nerdify other people's text.
## Installation ## Installation
```bash ```bash
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs nerdify [p]cog install seacogs nerdify
[p]cog load nerdify [p]cog load nerdify
``` ```

View file

@ -69,10 +69,10 @@ Default value: `None`
/// admonition | This has no effect on the `[p]pterodactyl command` text command, or the matching slash command. /// admonition | This has no effect on the `[p]pterodactyl command` text command, or the matching slash command.
type: danger type: danger
If you want to disable the ability to execute commands on the server through Discord, use the following commands: If you want to disable the ability to execute commands on the server through Discord, use the following commands:
`[p]pterodactyl config console commands False` - this command `[p]pterodactyl config console commands False` - this command
`[p]command disable pterodactyl command` - disables the text command that lets you execute commands on the server `[p]command disable pterodactyl command` - disables the text command that lets you execute commands on the server
`[p]slash disable pterodactyl` - due to how slash commands are laid out, this is the only way to disable the ability to execute commands on the server `[p]slash disable pterodactyl` - due to how slash commands are laid out, this is the only way to disable the ability to execute commands on the server
`[p]slash sync` - apply above slash command change `[p]slash sync` - apply above slash command change
/// ///

View file

@ -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: Now, use Downloader to add my repository to your bot:
``` ```
[p]repo add sea-cogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add sea-cogs https://www.coastalcommits.com/cswimr/SeaCogs
``` ```
Now, install the Pterodactyl cog: Now, install the Pterodactyl cog:

View file

@ -10,7 +10,7 @@ Pterodactyl allows for connecting to a Pterodactyl server through websockets. It
## Installation ## Installation
```bash ```bash
[p]repo add seacogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add seacogs https://www.coastalcommits.com/cswimr/SeaCogs
[p]cog install seacogs pterodactyl [p]cog install seacogs pterodactyl
[p]cog load aurora [p]cog load aurora
``` ```

View file

@ -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 2. Add my repository to the bot
```bash ```bash
[p]repo add sea-cogs https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs [p]repo add sea-cogs https://www.coastalcommits.com/cswimr/SeaCogs
``` ```
3. Install and load the Pterodactyl cog 3. Install and load the Pterodactyl cog
```bash ```bash

View file

@ -13,7 +13,7 @@ body:
attributes: attributes:
label: Please confirm that; label: Please confirm that;
options: options:
- 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. - 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.
required: true required: true
- label: I have checked that I am on the latest version of [Red-DiscordBot](https://github.com/CogCreators/Red-DiscordBot), and SeaCogs. - label: I have checked that I am on the latest version of [Red-DiscordBot](https://github.com/CogCreators/Red-DiscordBot), and SeaCogs.
required: true required: true

View file

@ -2,5 +2,5 @@
<!-- Create a new issue, if it doesn't exist yet --> <!-- Create a new issue, if it doesn't exist yet -->
- [ ] By submitting this pull request, I permit SeaswimmerTheFsh to license my work under - [ ] By submitting this pull request, I permit cswimr to license my work under
the [Mozilla Public License Version 2.0](https://www.coastalcommits.com/SeaswimmerTheFsh/SeaCogs/src/branch/main/LICENSE). the [Mozilla Public License Version 2.0](https://www.coastalcommits.com/cswimr/SeaCogs/src/branch/main/LICENSE).

View file

@ -18,4 +18,5 @@
import-self, import-self,
relative-beyond-top-level, relative-beyond-top-level,
too-many-instance-attributes, too-many-instance-attributes,
duplicate-code duplicate-code,
too-many-nested-blocks

View file

@ -8,7 +8,7 @@ on:
jobs: jobs:
Lint Code (Ruff & Pylint): Lint Code (Ruff & Pylint):
runs-on: docker runs-on: docker
container: www.coastalcommits.com/seaswimmerthefsh/actionscontainers-seacogs:latest container: www.coastalcommits.com/cswimr/actions:seacogs
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -25,7 +25,7 @@ jobs:
Build Documentation (MkDocs): Build Documentation (MkDocs):
runs-on: docker runs-on: docker
container: www.coastalcommits.com/seaswimmerthefsh/actionscontainers-seacogs:latest container: www.coastalcommits.com/cswimr/actions:seacogs
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -58,7 +58,7 @@ jobs:
npx -p "@getmeli/cli" meli upload ./site \ npx -p "@getmeli/cli" meli upload ./site \
--url "https://pages.coastalcommits.com" \ --url "https://pages.coastalcommits.com" \
--site "${{ vars.MELI_SITE_ID }}" \ --site "${{ vars.MELI_SITE_ID }}" \
--token "${{ secrets.MELI_SITE_SECRET }}" \ --token "${{ secrets.MELI_SECRET }}" \
--release "$CI_ACTION_REF_NAME_SLUG/${{ env.GITHUB_SHA }}" \ --release "$CI_ACTION_REF_NAME_SLUG/${{ env.GITHUB_SHA }}" \
--branch "$CI_ACTION_REF_NAME_SLUG" --branch "$CI_ACTION_REF_NAME_SLUG"

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.vscode .vscode
site site
.venv .venv
__pycache__

View file

@ -11,7 +11,7 @@ My assorted cogs for Red-DiscordBot.
To get started with a development environment, first clone this repository. To get started with a development environment, first clone this repository.
```sh ```sh
git clone https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs.git git clone https://coastalcommits.com/cswimr/SeaCogs.git
``` ```
Then, install Poetry. Then, install Poetry.

View file

@ -9,14 +9,15 @@ import discord
from red_commons.logging import getLogger from red_commons.logging import getLogger
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Config, Red from redbot.core.bot import Config, Red
from redbot.core.utils.chat_formatting import humanize_list from redbot.core.utils.chat_formatting import bold, humanize_list
class AntiPolls(commands.Cog): 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).""" """AntiPolls deletes messages that contain polls, with a configurable per-guild role and channel whitelist and support for default Discord permissions (Manage Messages)."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__version__ = "1.0.0" __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "1.0.1"
__documentation__ = "https://seacogs.coastalcommits.com/antipolls/" __documentation__ = "https://seacogs.coastalcommits.com/antipolls/"
def __init__(self, bot: Red): def __init__(self, bot: Red):
@ -38,9 +39,9 @@ class AntiPolls(commands.Cog):
n = "\n" if "\n\n" not in pre_processed else "" n = "\n" if "\n\n" not in pre_processed else ""
text = [ text = [
f"{pre_processed}{n}", f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**", f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"Author: {humanize_list(self.__author__)}", f"{bold('Author:')} {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}", f"{bold('Documentation:')} {self.__documentation__}",
] ]
return "\n".join(text) return "\n".join(text)

View file

@ -1,11 +1,11 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "author" : ["cswimr"],
"install_msg" : "Thank you for installing AntiPolls!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).", "install_msg" : "Thank you for installing AntiPolls!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
"name" : "AntiPolls", "name" : "AntiPolls",
"short" : "AntiPolls deletes messages that contain polls.", "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).", "description" : "AntiPolls deletes messages that contain polls, with a configurable per-guild role and channel whitelist and support for default Discord permissions (Manage Messages).",
"end_user_data_statement" : "This cog does not store any user data.", "end_user_data_statement" : "This cog does not store any user data.",
"hidden": false, "hidden": true,
"disabled": false, "disabled": false,
"min_bot_version": "3.5.0", "min_bot_version": "3.5.0",
"min_python_version": [3, 10, 0], "min_python_version": [3, 10, 0],

View file

@ -19,8 +19,7 @@ from redbot.core import app_commands, commands, data_manager
from redbot.core.app_commands import Choice from redbot.core.app_commands import Choice
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.commands.converter import parse_relativedelta, parse_timedelta from redbot.core.commands.converter import parse_relativedelta, parse_timedelta
from redbot.core.utils.chat_formatting import (box, error, humanize_list, from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning
humanize_timedelta, warning)
from aurora.importers.aurora import ImportAuroraView from aurora.importers.aurora import ImportAuroraView
from aurora.importers.galacticbot import ImportGalacticBotView from aurora.importers.galacticbot import ImportGalacticBotView
@ -29,19 +28,10 @@ from aurora.menus.guild import Guild
from aurora.menus.immune import Immune from aurora.menus.immune import Immune
from aurora.menus.overrides import Overrides from aurora.menus.overrides import Overrides
from aurora.utilities.config import config, register_config from aurora.utilities.config import config, register_config
from aurora.utilities.database import (connect, create_guild_table, fetch_case, from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log
mysql_log) from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed
from aurora.utilities.factory import (addrole_embed, case_factory,
changes_factory, evidenceformat_factory,
guild_embed, immune_embed,
message_factory, overrides_embed)
from aurora.utilities.logger import logger from aurora.utilities.logger import logger
from aurora.utilities.utils import (check_moddable, check_permissions, from aurora.utilities.utils import check_moddable, check_permissions, convert_timedelta_to_str, fetch_channel_dict, fetch_user_dict, generate_dict, get_footer_image, log, send_evidenceformat, timedelta_from_relativedelta
convert_timedelta_to_str,
fetch_channel_dict, fetch_user_dict,
generate_dict, get_footer_image, log,
send_evidenceformat,
timedelta_from_relativedelta)
class Aurora(commands.Cog): class Aurora(commands.Cog):
@ -49,8 +39,8 @@ 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. 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.""" This cog stores all of its data in an SQLite database."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["cswimr"]
__version__ = "2.1.2" __version__ = "2.1.3"
__documentation__ = "https://seacogs.coastalcommits.com/aurora/" __documentation__ = "https://seacogs.coastalcommits.com/aurora/"
async def red_delete_data_for_user(self, *, requester, user_id: int): async def red_delete_data_for_user(self, *, requester, user_id: int):

View file

@ -43,7 +43,7 @@ class ImportAuroraView(ui.View):
file = await self.ctx.message.attachments[0].read() file = await self.ctx.message.attachments[0].read()
data: list[dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"]) data: list[dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"])
user_mod_types = ["NOTE", "WARN", "MUTE", "UNMUTE", "KICK", "BAN", "UNBAN"] user_mod_types = ["NOTE", "WARN", "ADDROLE", "REMOVEROLE", "MUTE", "UNMUTE", "KICK", "TEMPBAN", "BAN", "UNBAN"]
channel_mod_types = ["SLOWMODE", "LOCKDOWN"] channel_mod_types = ["SLOWMODE", "LOCKDOWN"]
@ -58,6 +58,8 @@ class ImportAuroraView(ui.View):
case["target_type"] = "USER" case["target_type"] = "USER"
elif case["moderation_type"] in channel_mod_types: elif case["moderation_type"] in channel_mod_types:
case["target_type"] = "CHANNEL" case["target_type"] = "CHANNEL"
else:
case["target_type"] = "USER"
if "role_id" not in case or not case["role_id"]: if "role_id" not in case or not case["role_id"]:
case["role_id"] = 0 case["role_id"] = 0

View file

@ -1,6 +1,6 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "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/SeaswimmerTheFsh/SeaCogs).", "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).",
"name" : "Aurora", "name" : "Aurora",
"short" : "A full replacement for Red's core Mod cogs.", "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.", "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.",

View file

@ -381,6 +381,10 @@ async def evidenceformat_factory(interaction: Interaction, case_dict: dict) -> s
content = f"Case: {case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})" content = f"Case: {case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})"
if case_dict["role_id"] != "0":
role = interaction.guild.get_role(int(case_dict["role_id"]))
content += "\nRole: " + (role.name if role is not None else case_dict["role_id"])
if case_dict["duration"] != "NULL": if case_dict["duration"] != "NULL":
hours, minutes, seconds = map(int, case_dict["duration"].split(":")) hours, minutes, seconds = map(int, case_dict["duration"].split(":"))
td = timedelta(hours=hours, minutes=minutes, seconds=seconds) td = timedelta(hours=hours, minutes=minutes, seconds=seconds)

View file

@ -14,15 +14,16 @@ from redbot.cogs.downloader import errors
from redbot.cogs.downloader.converters import InstalledCog from redbot.cogs.downloader.converters import InstalledCog
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import error, humanize_list, text_to_file from redbot.core.utils.chat_formatting import bold, error, humanize_list, text_to_file
# pylint: disable=protected-access # pylint: disable=protected-access
class Backup(commands.Cog): class Backup(commands.Cog):
"""A utility to make reinstalling repositories and cogs after migrating the bot far easier.""" """A utility to make reinstalling repositories and cogs after migrating the bot far easier."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__version__ = "1.1.0" __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "1.1.1"
__documentation__ = "https://seacogs.coastalcommits.com/backup/" __documentation__ = "https://seacogs.coastalcommits.com/backup/"
def __init__(self, bot: Red): def __init__(self, bot: Red):
@ -35,9 +36,9 @@ class Backup(commands.Cog):
n = "\n" if "\n\n" not in pre_processed else "" n = "\n" if "\n\n" not in pre_processed else ""
text = [ text = [
f"{pre_processed}{n}", f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**", f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"Author: {humanize_list(self.__author__)}", f"{bold('Author:')} {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}", f"{bold('Documentation:')} {self.__documentation__}",
] ]
return "\n".join(text) return "\n".join(text)
@ -100,7 +101,7 @@ class Backup(commands.Cog):
except (json.JSONDecodeError, IndexError): except (json.JSONDecodeError, IndexError):
try: try:
export = json.loads(await ctx.message.reference.resolved.attachments[0].read()) export = json.loads(await ctx.message.reference.resolved.attachments[0].read())
except (json.JSONDecodeError, IndexError): except (json.JSONDecodeError, IndexError, AttributeError):
await ctx.send(error("Please provide a valid JSON export file.")) await ctx.send(error("Please provide a valid JSON export file."))
return return
@ -196,7 +197,7 @@ class Backup(commands.Cog):
cog_modules = [] cog_modules = []
for cog in cogs: for cog in cogs:
# If you're forking this cog, make sure to change these strings! # If you're forking this cog, make sure to change these strings!
if cog["name"] == "backup" and "SeaswimmerTheFsh/SeaCogs" in url: if cog["name"] == "backup" and "cswimr/SeaCogs" in url:
continue continue
try: try:
cog_module = await InstalledCog.convert(ctx, cog["name"]) cog_module = await InstalledCog.convert(ctx, cog["name"])
@ -232,7 +233,7 @@ class Backup(commands.Cog):
commit = None commit = None
# If you're forking this cog, make sure to change these strings! # If you're forking this cog, make sure to change these strings!
if cog_name == "backup" and "SeaswimmerTheFsh/SeaCogs" in url: if cog_name == "backup" and "cswimr/SeaCogs" in url:
continue continue
async with repository.checkout( async with repository.checkout(

View file

@ -1,6 +1,6 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "author" : ["cswimr"],
"install_msg" : "Thank you for installing Backup!\nYou can find the source code of this cog [here](https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs).", "install_msg" : "Thank you for installing Backup!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
"name" : "Backup", "name" : "Backup",
"short" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.", "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.", "description" : "A utility to make reinstalling repositories and cogs after migrating the bot far easier.",
@ -8,7 +8,7 @@
"hidden": false, "hidden": false,
"disabled": false, "disabled": false,
"min_bot_version": "3.5.6", "min_bot_version": "3.5.6",
"max_bot_version": "3.5.9", "max_bot_version": "3.5.13",
"min_python_version": [3, 9, 0], "min_python_version": [3, 9, 0],
"tags": [ "tags": [
"utility", "utility",

View file

@ -15,7 +15,7 @@ from PIL import Image
from red_commons.logging import getLogger from red_commons.logging import getLogger
from redbot.core import Config, commands, data_manager from redbot.core import Config, commands, data_manager
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import error, humanize_list from redbot.core.utils.chat_formatting import bold, error, humanize_list
import bible.errors import bible.errors
from bible.models import Version from bible.models import Version
@ -24,9 +24,10 @@ from bible.models import Version
class Bible(commands.Cog): class Bible(commands.Cog):
"""Retrieve Bible verses from the API.bible API.""" """Retrieve Bible verses from the API.bible API."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__version__ = "1.1.0" __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__documentation__ = "https://seacogs.coastalcommits.com/bible/" __version__ = "1.1.1"
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
def __init__(self, bot: Red): def __init__(self, bot: Red):
super().__init__() super().__init__()
@ -44,12 +45,13 @@ class Bible(commands.Cog):
n = "\n" if "\n\n" not in pre_processed else "" n = "\n" if "\n\n" not in pre_processed else ""
text = [ text = [
f"{pre_processed}{n}", f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**", f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"Author: {humanize_list(self.__author__)}", f"{bold('Author:')} {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}", f"{bold('Documentation:')} {self.__documentation__}",
] ]
return "\n".join(text) return "\n".join(text)
def get_icon(self, color: Colour) -> File: def get_icon(self, color: Colour) -> File:
"""Get the docs.api.bible favicon with a given color.""" """Get the docs.api.bible favicon with a given color."""
image_path = data_manager.bundled_data_path(self) / "api.bible-logo.png" image_path = data_manager.bundled_data_path(self) / "api.bible-logo.png"

View file

@ -1,6 +1,6 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "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/SeaswimmerTheFsh/SeaCogs).", "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).",
"name" : "Bible", "name" : "Bible",
"short" : "Retrieve Bible verses from API.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.", "description" : "Retrieve Bible verses from the API.Bible API. This cog requires an API.Bible api key.",

5
emojiinfo/__init__.py Normal file
View file

@ -0,0 +1,5 @@
from .emojiinfo import EmojiInfo
async def setup(bot):
await bot.add_cog(EmojiInfo(bot))

5309
emojiinfo/data/emojis.json Normal file

File diff suppressed because it is too large Load diff

130
emojiinfo/emojiinfo.py Normal file
View file

@ -0,0 +1,130 @@
import io
import aiohttp
import discord
from colorthief import ColorThief
from red_commons.logging import RedTraceLogger, getLogger
from redbot.core import app_commands, commands
from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import bold, humanize_list
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/"
def __init__(self, bot: Red) -> None:
super().__init__()
self.bot: Red = bot
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 = [
f"{pre_processed}{n}",
f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"{bold('Author:')} {humanize_list(self.__author__)}",
f"{bold('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])
segments = emoji_codepoint.split("-")
valid_segments = [seg for seg in segments if len(seg) >= 4]
emoji_url = f"{base_url}{valid_segments[0]}.png"
return emoji_url
async def fetch_primary_color(self, emoji_url: str) -> discord.Color | None:
async with aiohttp.ClientSession() as session:
async with session.get(emoji_url) as response:
if response.status != 200:
return None
image = await response.read()
dominant_color = ColorThief(io.BytesIO(image)).get_color(quality=1)
color = discord.Color.from_rgb(*dominant_color)
return color
async def get_emoji_info(self, emoji: PartialEmoji) -> tuple[str, str]:
if emoji.is_unicode_emoji():
try:
emoji_url = await self.fetch_twemoji(unicode_emoji=emoji.name)
except IndexError as e:
raise e
else:
emoji_url = emoji.url
if emoji.id is not None:
emoji_id = f"{bold('ID:')} `{emoji.id}`\n"
markdown = f"`<{'a' if emoji.animated else ''}:{emoji.name}:{emoji.id}>`"
name = f"{bold('Name:')} {emoji.name}\n"
aliases = ""
group = ""
else:
emoji_id = ""
markdown = f"`{emoji}`"
name = f"{bold('Name:')} {emoji.aliases.pop(0)}\n"
aliases = f"{bold('Aliases:')} {', '.join(emoji.aliases)}\n" if emoji.aliases else ""
group = f"{bold('Group:')} {emoji.group}\n"
return (
f"{name}"
f"{emoji_id}"
f"{bold('Native:')} {emoji.is_unicode_emoji()}\n"
f"{group}"
f"{aliases}"
f"{bold('Animated:')} {emoji.animated}\n"
f"{bold('Markdown:')} {markdown}\n"
f"{bold('URL:')} [Click Here]({emoji_url})"
), emoji_url
@app_commands.command(name="emoji")
@app_commands.describe(
emoji="What emoji would you like to get information on?",
ephemeral="Would you like the response to be hidden?"
)
async def emoji_slash(self, interaction: discord.Interaction, emoji: str, ephemeral: bool = True) -> None:
"""Retrieve information about an emoji."""
await interaction.response.defer(ephemeral=ephemeral)
try:
emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji)
string, emoji_url, = await self.get_emoji_info(emoji)
self.logger.verbose(f"Emoji:\n{string}")
except (IndexError, UnboundLocalError):
return await interaction.followup.send("Please provide a valid emoji!")
if await self.bot.embed_requested(channel=interaction.channel):
embed = embed = discord.Embed(title="Emoji Information", description=string, color = await self.fetch_primary_color(emoji_url) or await self.bot.get_embed_color(interaction.channel))
embed.set_thumbnail(url=emoji_url)
await interaction.followup.send(embed=embed)
else:
await interaction.followup.send(content=string)
@commands.command(name="emoji")
async def emoji(self, ctx: commands.Context, *, emoji: str) -> None:
"""Retrieve information about an emoji."""
try:
emoji: PartialEmoji = PartialEmoji.from_str(self, value=emoji)
string, emoji_url, = await self.get_emoji_info(emoji)
self.logger.verbose(f"Emoji:\n{string}")
except (IndexError, UnboundLocalError):
return await ctx.send("Please provide a valid emoji!")
if await ctx.embed_requested():
embed = embed = discord.Embed(title="Emoji Information", description=string, color = await self.fetch_primary_color(emoji_url) or await ctx.embed_color)
embed.set_thumbnail(url=emoji_url)
await ctx.send(embed=embed)
else:
await ctx.send(content=string)

16
emojiinfo/info.json Normal file
View file

@ -0,0 +1,16 @@
{
"author" : ["cswimr"],
"install_msg" : "Thank you for installing Emoji!",
"name" : "Emoji",
"short" : "Retrieve information about emojis.",
"description" : "Retrieve information about emojis.",
"end_user_data_statement" : "This cog does not store end user data.",
"hidden": false,
"disabled": false,
"min_bot_version": "3.5.0",
"min_python_version": [3, 10, 0],
"requirements": ["colorthief"],
"tags": [
"utility"
]
}

91
emojiinfo/model.py Normal file
View file

@ -0,0 +1,91 @@
import json
import discord
from redbot.core import commands, data_manager
class PartialEmoji(discord.PartialEmoji):
"""Represents a "partial" emoji. Subclasses `discord.PartialEmoji`
.. container:: operations
.. describe:: x == y
Checks if two emoji are the same.
.. describe:: x != y
Checks if two emoji are not the same.
.. describe:: hash(x)
Return the emoji's hash.
.. describe:: str(x)
Returns the emoji rendered for discord.
Attributes
-----------
name: Optional[:class:`str`]
The custom emoji name, if applicable, or the unicode codepoint
of the non-custom emoji. This can be ``None`` if the emoji
got deleted (e.g. removing a reaction with a deleted emoji).
animated: :class:`bool`
Whether the emoji is animated or not.
id: Optional[:class:`int`]
The ID of the custom emoji, if applicable.
group: Optional[:class:`str`]
The group name of the emoji if it is a native emoji.
"""
def __init__(self, *, name: str, animated: bool = False, id: int | None = None, group: str | None = None, aliases: list | None = None) -> None: # pylint: disable=redefined-builtin
super().__init__(name=name, animated=animated, id=id)
self.group = group
self.aliases = aliases
@classmethod
def from_str(cls, coginstance: commands.Cog, value: str) -> "PartialEmoji":
"""Converts a Discord string representation of an emoji to a :class:`PartialEmoji`.
The formats accepted are:
- ``a:name:id``
- ``<a:name:id>``
- ``name:id``
- ``<:name:id>``
If the format does not match then it is assumed to be a unicode emoji.
.. versionadded:: 2.0
Parameters
------------
value: :class:`str`
The string representation of an emoji.
Returns
--------
:class:`PartialEmoji`
The partial emoji from this string.
"""
match = cls._CUSTOM_EMOJI_RE.match(value)
if match is not None:
groups = match.groupdict()
animated = bool(groups['animated'])
emoji_id = int(groups['id'])
name = groups['name']
return cls(name=name, animated=animated, id=emoji_id)
path: data_manager.Path = data_manager.bundled_data_path(coginstance) / "emojis.json"
with open(path, "r", encoding="UTF-8") as file:
emojis: dict = json.load(file)
emoji_aliases = []
emoji_group = None
for dict_name, group in emojis.items():
for k, v in group.items():
if v == value:
emoji_group = dict_name
if k not in emoji_aliases:
emoji_aliases.append(k)
return cls(name=value, animated=False, id=None, group=emoji_group, aliases=emoji_aliases)

View file

@ -1,9 +1,9 @@
{ {
"author": [ "author": [
"SeaswimmerTheFsh (seasw.)" "cswimr"
], ],
"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 ).", "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 ).",
"name": "SeaCogs", "index_name": "sea-cogs",
"short": "Various cogs for Red, by SeaswimmerTheFsh (seasw.)", "short": "Various cogs for Red, by cswimr",
"description": "Various cogs for Red, by SeaswimmerTheFsh (seasw.)" "description": "Various cogs for Red, by cswimr"
} }

View file

@ -1,12 +1,12 @@
site_name: SeaCogs Documentation site_name: SeaCogs Documentation
site_url: !ENV [SITE_URL, 'https://seacogs.coastalcommits.com'] site_url: !ENV [SITE_URL, 'https://seacogs.coastalcommits.com']
repo_name: CoastalCommits repo_name: CoastalCommits
repo_url: https://coastalcommits.com/SeaswimmerTheFsh/SeaCogs repo_url: https://coastalcommits.com/cswimr/SeaCogs
edit_uri: !ENV [EDIT_URI, 'src/branch/main/.docs'] edit_uri: !ENV [EDIT_URI, 'src/branch/main/.docs']
copyright: Copyright &copy; 2023-2024, SeaswimmerTheFsh copyright: Copyright &copy; 2023-2024, cswimr
docs_dir: .docs docs_dir: .docs
site_author: SeaswimmerTheFsh site_author: cswimr
site_description: Documentation for my Red-DiscordBot Cogs. site_description: Documentation for my Red-DiscordBot Cogs.
nav: nav:
@ -18,6 +18,7 @@ nav:
- Configuration: aurora/configuration.md - Configuration: aurora/configuration.md
- Bible: bible.md - Bible: bible.md
- Backup: backup.md - Backup: backup.md
- EmojiInfo: emojiinfo.md
- Nerdify: nerdify.md - Nerdify: nerdify.md
- Pterodactyl: - Pterodactyl:
- pterodactyl/index.md - pterodactyl/index.md
@ -29,7 +30,7 @@ nav:
plugins: plugins:
- git-authors - git-authors
- search - search
#- social - social
- git-revision-date-localized: - git-revision-date-localized:
enable_creation_date: true enable_creation_date: true
type: timeago type: timeago
@ -112,3 +113,5 @@ watch:
- ./bible - ./bible
- ./nerdify - ./nerdify
- ./pterodactyl - ./pterodactyl
- ./emojiinfo
- ./antipolls

View file

@ -1,6 +1,6 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "author" : ["cswimr"],
"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.", "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.",
"name" : "Nerdify", "name" : "Nerdify",
"short" : "Nerdify your text!", "short" : "Nerdify your text!",
"description" : "Nerdify your text!", "description" : "Nerdify your text!",

View file

@ -12,13 +12,15 @@ from typing import Any, Optional, Union
import discord import discord
from redbot.core import commands from redbot.core import commands
from redbot.core.utils import chat_formatting, common_filters from redbot.core.utils import chat_formatting, common_filters
from redbot.core.utils.chat_formatting import bold, humanize_list
class Nerdify(commands.Cog): class Nerdify(commands.Cog):
"""Nerdify your text.""" """Nerdify your text."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__version__ = "1.3.4" __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "1.3.5"
__documentation__ = "https://seacogs.coastalcommits.com/nerdify/" __documentation__ = "https://seacogs.coastalcommits.com/nerdify/"
def __init__(self, bot): def __init__(self, bot):
@ -29,12 +31,13 @@ class Nerdify(commands.Cog):
n = "\n" if "\n\n" not in pre_processed else "" n = "\n" if "\n\n" not in pre_processed else ""
text = [ text = [
f"{pre_processed}{n}", f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**", f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"Author: {chat_formatting.humanize_list(self.__author__)}", f"{bold('Author:')} {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}" f"{bold('Documentation:')} {self.__documentation__}",
] ]
return "\n".join(text) return "\n".join(text)
@commands.command(aliases=["nerd"]) @commands.command(aliases=["nerd"])
async def nerdify( async def nerdify(
self, ctx: commands.Context, *, text: Optional[str] = None self, ctx: commands.Context, *, text: Optional[str] = None

2037
poetry.lock generated

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

View file

@ -1,6 +1,6 @@
{ {
"author" : ["SeaswimmerTheFsh (seasw.)"], "author" : ["cswimr"],
"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 ).", "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 ).",
"name" : "Pterodactyl", "name" : "Pterodactyl",
"short" : "Interface with Pterodactyl through websockets.", "short" : "Interface with Pterodactyl through websockets.",
"description" : "Interface with Pterodactyl through websockets.", "description" : "Interface with Pterodactyl through websockets.",
@ -9,7 +9,7 @@
"disabled": false, "disabled": false,
"min_bot_version": "3.5.0", "min_bot_version": "3.5.0",
"min_python_version": [3, 8, 0], "min_python_version": [3, 8, 0],
"requirements": ["git+https://github.com/SeaswimmerTheFsh/pydactyl", "websockets"], "requirements": ["git+https://github.com/cswimr/pydactyl", "websockets"],
"tags": [ "tags": [
"pterodactyl", "pterodactyl",
"minecraft", "minecraft",

View file

@ -9,7 +9,7 @@ from pydactyl import PterodactylClient
from redbot.core import app_commands, commands from redbot.core import app_commands, commands
from redbot.core.app_commands import Choice from redbot.core.app_commands import Choice
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import box, error, humanize_list from redbot.core.utils.chat_formatting import bold, box, error, humanize_list
from redbot.core.utils.views import ConfirmView from redbot.core.utils.views import ConfirmView
from pterodactyl import mcsrvstatus from pterodactyl import mcsrvstatus
@ -20,8 +20,9 @@ from pterodactyl.logger import logger
class Pterodactyl(commands.Cog): class Pterodactyl(commands.Cog):
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord.""" """Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
__author__ = ["SeaswimmerTheFsh"] __author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__version__ = "2.0.0" __git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "2.0.4"
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/" __documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
def __init__(self, bot: Red): def __init__(self, bot: Red):
@ -39,12 +40,29 @@ class Pterodactyl(commands.Cog):
n = "\n" if "\n\n" not in pre_processed else "" n = "\n" if "\n\n" not in pre_processed else ""
text = [ text = [
f"{pre_processed}{n}", f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**", f"{bold('Cog Version:')} [{self.__version__}]({self.__git__})",
f"Author: {humanize_list(self.__author__)}", f"{bold('Author:')} {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}", f"{bold('Documentation:')} {self.__documentation__}",
] ]
return "\n".join(text) 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: async def cog_unload(self) -> None:
self.update_topic.cancel() self.update_topic.cancel()
self.task.cancel() self.task.cancel()
@ -175,76 +193,47 @@ class Pterodactyl(commands.Cog):
async def power(self, ctx: Union[discord.Interaction, commands.Context], action: str, action_ing: str, warning: str = '') -> None: async def power(self, ctx: Union[discord.Interaction, commands.Context], action: str, action_ing: str, warning: str = '') -> None:
if isinstance(ctx, discord.Interaction): if isinstance(ctx, discord.Interaction):
author = ctx.user ctx = await self.bot.get_context(ctx)
else:
author = ctx.author
current_status = await config.current_status() current_status = await config.current_status()
if current_status == action_ing: if current_status == action_ing:
if isinstance(ctx, discord.Interaction): return await ctx.send(f"Server is already {action_ing}.", ephemeral=True)
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": if current_status in ["starting", "stopping"] and action != "kill":
if isinstance(ctx, discord.Interaction): return await ctx.send("Another power action is already in progress.", ephemeral=True)
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(author, disable_buttons=True) view = ConfirmView(ctx.author, disable_buttons=True)
if isinstance(ctx, discord.Interaction): message = await ctx.send(f"{warning}Are you sure you want to {action} the server?", view=view)
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() await view.wait()
if view.result is True: if view.result is True:
if isinstance(ctx, discord.Interaction): await message.edit(content=f"Sending websocket command to {action} server...", view=None)
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 self.websocket.send(json.dumps({"event": "set state", "args": [action]}))
if isinstance(ctx, discord.Interaction): await message.edit(content=f"Server {action_ing}", view=None)
await ctx.edit_original_response(content=f"Server {action_ing}", view=None)
else:
await message.edit(content=f"Server {action_ing}", view=None)
else: else:
if isinstance(ctx, discord.Interaction): await message.edit(content="Cancelled.", view=None)
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): async def send_command(self, ctx: Union[discord.Interaction, commands.Context], command: str):
channel = self.bot.get_channel(await config.console_channel()) channel = self.bot.get_channel(await config.console_channel())
if isinstance(ctx, discord.Interaction): if isinstance(ctx, discord.Interaction):
if channel: ctx = await self.bot.get_context(ctx)
await channel.send(f"Received console command from {ctx.user.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none()) if channel:
try: await channel.send(f"Received console command from {ctx.author.id}: {command[:1900]}", allowed_mentions=discord.AllowedMentions.none())
await self.websocket.send(json.dumps({"event": "send command", "args": [command]})) try:
await ctx.response.send_message(f"Command sent to server. {box(command, 'json')}", ephemeral=True) await self.websocket.send(json.dumps({"event": "send command", "args": [command]}))
except websockets.exceptions.ConnectionClosed as e: await ctx.send(f"Command sent to server. {box(command, 'json')}")
logger.error("WebSocket connection closed: %s", e) except websockets.exceptions.ConnectionClosed as e:
await ctx.response.send_message(error("WebSocket connection closed.")) logger.error("WebSocket connection closed: %s", e)
self.task.cancel() await ctx.send(error("WebSocket connection closed."))
self.retry_counter = 0 self.task.cancel()
self.task = self.get_task() self.retry_counter = 0
else: self.task = self.get_task()
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() @commands.Cog.listener()
async def on_red_api_tokens_update(self, service_name: str, api_tokens: Mapping[str,str]): # pylint: disable=unused-argument async def on_red_api_tokens_update(self, service_name: str, api_tokens: Mapping[str,str]): # pylint: disable=unused-argument

View file

@ -1,12 +1,14 @@
# pylint: disable=cyclic-import # pylint: disable=cyclic-import
import json import json
import re import re
from typing import Optional, Union from pathlib import Path
from typing import Optional, Tuple, Union
import aiohttp import aiohttp
import discord import discord
import websockets import websockets
from pydactyl import PterodactylClient from pydactyl import PterodactylClient
from redbot.core.data_manager import bundled_data_path
from redbot.core.utils.chat_formatting import bold, pagify from redbot.core.utils.chat_formatting import bold, pagify
from pterodactyl.config import config from pterodactyl.config import config
@ -78,7 +80,12 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
if join_message: if join_message:
if chat_channel is not None: if chat_channel is not None:
if coginstance.bot.embed_requested(chat_channel): if coginstance.bot.embed_requested(chat_channel):
await chat_channel.send(embed=await generate_join_leave_embed(join_message, True)) 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)
else:
await chat_channel.send(embed=embed)
else: 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())
@ -86,7 +93,12 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
if leave_message: if leave_message:
if chat_channel is not None: if chat_channel is not None:
if coginstance.bot.embed_requested(chat_channel): if coginstance.bot.embed_requested(chat_channel):
await chat_channel.send(embed=await generate_join_leave_embed(leave_message, False)) 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)
else:
await chat_channel.send(embed=embed)
else: 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())
@ -94,7 +106,7 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
if achievement_message: if achievement_message:
if chat_channel is not None: if chat_channel is not None:
if coginstance.bot.embed_requested(chat_channel): 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'])) await chat_channel.send(embed=await generate_achievement_embed(coginstance, achievement_message['username'], achievement_message['achievement'], achievement_message['challenge']))
else: else:
await chat_channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}") await chat_channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}")
@ -153,7 +165,7 @@ async def check_if_server_message(text: str) -> Union[bool, str]:
regex = await config.server_regex() regex = await config.server_regex()
match: Optional[re.Match[str]] = re.match(regex, text) match: Optional[re.Match[str]] = re.match(regex, text)
if match: if match:
logger.debug("Message is a server message") logger.trace("Message is a server message")
return match.group(1) return match.group(1)
return False return False
@ -162,7 +174,7 @@ async def check_if_chat_message(text: str) -> Union[bool, dict]:
match: Optional[re.Match[str]] = re.match(regex, text) match: Optional[re.Match[str]] = re.match(regex, text)
if match: if match:
groups = {"username": match.group(1), "message": match.group(2)} groups = {"username": match.group(1), "message": match.group(2)}
logger.debug("Message is a chat message\n%s", json.dumps(groups)) logger.trace("Message is a chat message\n%s", json.dumps(groups))
return groups return groups
return False return False
@ -170,7 +182,7 @@ async def check_if_join_message(text: str) -> Union[bool, str]:
regex = await config.join_regex() regex = await config.join_regex()
match: Optional[re.Match[str]] = re.match(regex, text) match: Optional[re.Match[str]] = re.match(regex, text)
if match: if match:
logger.debug("Message is a join message") logger.trace("Message is a join message")
return match.group(1) return match.group(1)
return False return False
@ -178,7 +190,7 @@ async def check_if_leave_message(text: str) -> Union[bool, str]:
regex = await config.leave_regex() regex = await config.leave_regex()
match: Optional[re.Match[str]] = re.match(regex, text) match: Optional[re.Match[str]] = re.match(regex, text)
if match: if match:
logger.debug("Message is a leave message") logger.trace("Message is a leave message")
return match.group(1) return match.group(1)
return False return False
@ -191,23 +203,23 @@ async def check_if_achievement_message(text: str) -> Union[bool, dict]:
groups["challenge"] = True groups["challenge"] = True
else: else:
groups["challenge"] = False groups["challenge"] = False
logger.debug("Message is an achievement message") logger.trace("Message is an achievement message")
return groups return groups
return False return False
async def get_info(username: str) -> Optional[dict]: async def get_info(username: str) -> Optional[dict]:
logger.debug("Retrieving player info for %s", username) logger.verbose("Retrieving player info for %s", username)
endpoint = await config.api_endpoint() endpoint = await config.api_endpoint()
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.get(f"https://playerdb.co/api/player/{endpoint}/{username}") as response: async with session.get(f"https://playerdb.co/api/player/{endpoint}/{username}") as response:
if response.status == 200: if response.status == 200:
logger.debug("Player info retrieved for %s", username) logger.verbose("Player info retrieved for %s", username)
return await response.json() return await response.json()
logger.error("Failed to retrieve player info for %s: %s", username, response.status) logger.warning("Failed to retrieve player info for %s: %s", username, response.status)
return None return None
async def send_chat_discord(coginstance: Pterodactyl, username: str, message: str, avatar_url: str) -> None: async def send_chat_discord(coginstance: Pterodactyl, username: str, message: str, avatar_url: str) -> None:
logger.debug("Sending chat message to Discord") logger.trace("Sending chat message to Discord")
channel = coginstance.bot.get_channel(await config.chat_channel()) channel = coginstance.bot.get_channel(await config.chat_channel())
if channel is not None: if channel is not None:
webhooks = await channel.webhooks() webhooks = await channel.webhooks()
@ -215,33 +227,37 @@ async def send_chat_discord(coginstance: Pterodactyl, username: str, message: st
if webhook is None: if webhook is None:
webhook = await channel.create_webhook(name="Pterodactyl Chat") 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)) await webhook.send(content=message, username=username, avatar_url=avatar_url, allowed_mentions=discord.AllowedMentions(everyone=False, roles=False, users=True))
logger.debug("Chat message sent to Discord") logger.trace("Chat message sent to Discord")
else: else:
logger.warning("Chat channel not set. Skipping sending chat message to Discord") logger.warning("Chat channel not set. Skipping sending chat message to Discord")
async def generate_join_leave_embed(username: str, join: bool) -> discord.Embed: async def generate_join_leave_embed(coginstance: Pterodactyl, username: str, join: bool) -> Tuple[discord.Embed, Optional[Union[str, Path]]]:
embed = discord.Embed() embed = discord.Embed()
embed.color = discord.Color.green() if join else discord.Color.red() embed.color = discord.Color.green() if join else discord.Color.red()
embed.description = await config.join_msg() if join else await config.leave_msg() embed.description = await config.join_msg() if join else await config.leave_msg()
info = await get_info(username) info = await get_info(username)
if info: if info:
img = None
embed.set_author(name=username, icon_url=info['data']['player']['avatar']) embed.set_author(name=username, icon_url=info['data']['player']['avatar'])
else: else:
embed.set_author(name=username, icon_url='https://seafsh.cc/u/j3AzqQ.png') img = bundled_data_path(coginstance) / "unknown.png"
embed.set_author(name=username, icon_url='attachment://unknown.png')
embed.timestamp = discord.utils.utcnow() embed.timestamp = discord.utils.utcnow()
return embed return embed, img
async def generate_achievement_embed(username: str, achievement: str, challenge: bool) -> discord.Embed: async def generate_achievement_embed(coginstance: Pterodactyl, username: str, achievement: str, challenge: bool) -> Tuple[discord.Embed, Optional[Union[str, Path]]]:
embed = discord.Embed() embed = discord.Embed()
embed.color = discord.Color.from_str('#a800a7') if challenge else discord.Color.from_str('#54fb54') 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)}" embed.description = f"{bold(username)} has {'completed the challenge' if challenge else 'made the advancement'} {bold(achievement)}"
info = await get_info(username) info = await get_info(username)
if info: if info:
img = None
embed.set_author(name=username, icon_url=info['data']['player']['avatar']) embed.set_author(name=username, icon_url=info['data']['player']['avatar'])
else: else:
embed.set_author(name=username, icon_url='https://seafsh.cc/u/j3AzqQ.png') img = bundled_data_path(coginstance) / "unknown.png"
embed.set_author(name=username, icon_url='attachment://unknown.png')
embed.timestamp = discord.utils.utcnow() embed.timestamp = discord.utils.utcnow()
return embed return embed, img
def mask_ip(string: str) -> str: def mask_ip(string: str) -> str:
def check(match: re.Match[str]): def check(match: re.Match[str]):

View file

@ -2,7 +2,7 @@
name = "seacogs" name = "seacogs"
version = "0.1.0" version = "0.1.0"
description = "My assorted cogs for Red-DiscordBot." description = "My assorted cogs for Red-DiscordBot."
authors = ["SeaswimmerTheFsh"] authors = ["cswimr"]
license = "MPL 2" license = "MPL 2"
readme = "README.md" readme = "README.md"
package-mode = false package-mode = false
@ -14,6 +14,9 @@ py-dactyl = "^2.0.4"
websockets = "^12.0" websockets = "^12.0"
pillow = "^10.3.0" pillow = "^10.3.0"
numpy = "^1.26.4" numpy = "^1.26.4"
colorthief = "^0.2.1"
beautifulsoup4 = "^4.12.3"
markdownify = "^0.12.1"
py-lav = {extras = ["all"], version = ">=1.14.3,<1.15"} py-lav = {extras = ["all"], version = ">=1.14.3,<1.15"}
[tool.poetry.group.dev] [tool.poetry.group.dev]
@ -22,6 +25,7 @@ optional = true
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
ruff = "^0.3.1" ruff = "^0.3.1"
pylint = "^3.1.0" pylint = "^3.1.0"
sqlite-web = "^0.6.4"
[tool.poetry.group.docs] [tool.poetry.group.docs]
optional = true optional = true

5
seautils/__init__.py Normal file
View file

@ -0,0 +1,5 @@
from .seautils import SeaUtils
async def setup(bot):
await bot.add_cog(SeaUtils(bot))

13
seautils/info.json Normal file
View file

@ -0,0 +1,13 @@
{
"author" : ["cswimr"],
"install_msg" : "Thank you for installing SeaUtils!\nYou can find the source code of this cog [here](https://coastalcommits.com/cswimr/SeaCogs).",
"name" : "SeaUtils",
"short" : "A collection of useful utilities.",
"description" : "A collection of useful utilities.",
"end_user_data_statement" : "This cog does not store end user data.",
"hidden": true,
"disabled": false,
"min_bot_version": "3.5.0",
"min_python_version": [3, 8, 0],
"requirements": ["beautifulsoup4", "markdownify"]
}

254
seautils/seautils.py Normal file
View file

@ -0,0 +1,254 @@
# _____ _
# / ____| (_)
# | (___ ___ __ _ _____ ___ _ __ ___ _ __ ___ ___ _ __
# \___ \ / _ \/ _` / __\ \ /\ / / | '_ ` _ \| '_ ` _ \ / _ \ '__|
# ____) | __/ (_| \__ \\ V V /| | | | | | | | | | | | __/ |
# |_____/ \___|\__,_|___/ \_/\_/ |_|_| |_| |_|_| |_| |_|\___|_|
import asyncio
import inspect
import operator
import re
from asyncio.subprocess import Process
from functools import partial, partialmethod
from typing import Any
import aiohttp
import yaml
from bs4 import BeautifulSoup
from discord import Color, Embed, app_commands
from discord.utils import CachedSlotProperty, cached_property
from markdownify import MarkdownConverter
from redbot.core import commands
from redbot.core.bot import Red
from redbot.core.dev_commands import cleanup_code
from redbot.core.utils import chat_formatting as cf
from redbot.core.utils.views import SimpleMenu
def md(soup: BeautifulSoup, **options) -> Any | str:
return MarkdownConverter(**options).convert_soup(soup=soup)
def format_rfc_text(text: str, number: int) -> str:
one: str = re.sub(r"\(\.\/rfc(\d+)", r"(https://www.rfc-editor.org/rfc/rfc\1.html", text)
two: str = re.sub(r"\((#(?:section|page)-\d+(?:.\d+)?)\)", f"(https://www.rfc-editor.org/rfc/rfc{number}.html\1)", one)
three: str = re.sub(r"\n{3,}", "\n\n", two)
return three
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/"
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 ""
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__}",
]
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"""
obj = inspect.unwrap(func=obj)
src: Any = getattr(obj, "__func__", obj)
if isinstance(obj, (commands.Command, app_commands.Command)):
src = obj.callback
elif isinstance(obj, (partial, partialmethod)):
src = obj.func
elif isinstance(obj, property):
src = obj.fget
elif isinstance(obj, (cached_property, CachedSlotProperty)):
src = obj.function
return inspect.getsource(object=src)
@commands.command(aliases=["source", "src", "code", "showsource"])
@commands.is_owner()
async def showcode(self, ctx: commands.Context, *, object: str) -> None: # pylint: disable=redefined-builtin
"""Show the code for a particular object."""
try:
if object.startswith("/") and (obj := ctx.bot.tree.get_command(object[1:])):
text = self.format_src(obj)
elif obj := ctx.bot.get_cog(object):
text = self.format_src(type(obj))
elif obj := ctx.bot.get_command(object):
text = self.format_src(obj)
else:
raise AttributeError
temp_content = cf.pagify(
text=cleanup_code(text),
escape_mass_mentions=True,
page_length = 1977
)
content = []
max_i = operator.length_hint(temp_content)
i = 1
for page in temp_content:
content.append(f"**Page {i}/{max_i}**\n{cf.box(page, lang='py')}")
i += 1
await SimpleMenu(pages=content, disable_after_timeout=True, timeout=180).start(ctx)
except (OSError, AttributeError, UnboundLocalError):
if ctx.embed_requested():
embed = Embed(title="Object not found!", color=await ctx.embed_color())
await ctx.send(embed=embed, reference=ctx.message.to_reference(fail_if_not_exists=False))
else:
await ctx.send(content="Object not found!", reference=ctx.message.to_reference(fail_if_not_exists=False))
@commands.command(name='dig', aliases=['dnslookup', 'nslookup'])
@commands.is_owner()
async def dig(self, ctx: commands.Context, name: str, record_type: str | None = None, server: str | None = None, port: int = 53) -> None:
"""Retrieve DNS information for a domain.
Uses `dig` to perform a DNS query. Will fall back to `nslookup` if `dig` is not installed on the system.
`nslookup` does not provide as much information as `dig`, so only the `name` parameter will be used if `nslookup` is used.
Will return the A, AAAA, and CNAME records for a domain by default. You can specify a different record type with the `type` parameter."""
command_opts: list[str | int] = ['dig']
query_types: list[str] = [record_type] if record_type else ['A', 'AAAA', 'CNAME']
if server:
command_opts.extend(['@', server])
for query_type in query_types:
command_opts.extend([name, query_type])
command_opts.extend(['-p', str(port), '+yaml'])
try:
process: Process = await asyncio.create_subprocess_exec(*command_opts, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
stdout, stderr = await process.communicate()
if stderr:
await ctx.maybe_send_embed(message="An error was encountered!\n" + cf.box(text=stderr.decode()))
else:
data = yaml.safe_load(stdout.decode())
message_data: dict = data[0]['message']
response_data: dict = message_data['response_message_data']
if ctx.embed_requested():
embed = Embed(
title="DNS Query Result",
color=await ctx.embed_color(),
timestamp=message_data['response_time']
)
embed.add_field(name="Response Address", value=message_data['response_address'], inline=True)
embed.add_field(name="Response Port", value=message_data['response_port'], inline=True)
embed.add_field(name="Query Address", value=message_data['query_address'], inline=True)
embed.add_field(name="Query Port", value=message_data['query_port'], inline=True)
embed.add_field(name="Status", value=response_data['status'], inline=True)
embed.add_field(name="Flags", value=response_data['flags'], inline=True)
if response_data.get('status') != 'NOERROR':
embed.colour = Color.red()
embed.description = cf.error("Dig query did not return `NOERROR` status.")
questions = []
answers = []
authorities = []
for m in data:
response = m['message']['response_message_data']
if 'QUESTION_SECTION' in response:
for question in response['QUESTION_SECTION']:
if question not in questions:
questions.append(question)
if 'ANSWER_SECTION' in response:
for answer in response['ANSWER_SECTION']:
if answer not in answers:
answers.append(answer)
if 'AUTHORITY_SECTION' in response:
for authority in response['AUTHORITY_SECTION']:
if authority not in authorities:
authorities.append(authority)
if questions:
question_section = "\n".join(questions)
embed.add_field(name="Question Section", value=f"{cf.box(text=question_section, lang='prolog')}", inline=False)
if answers:
answer_section = "\n".join(answers)
if len(answer_section) > 1024:
embed.description = cf.warning("Answer section is too long to fit within embed field, falling back to description.") + cf.box(answer_section)
else:
embed.add_field(name="Answer Section", value=f"{cf.box(text=answer_section, lang='prolog')}", inline=False)
if authorities:
authority_section = "\n".join(authorities)
embed.add_field(name="Authority Section", value=f"{cf.box(text=authority_section, lang='prolog')}", inline=False)
await ctx.send(embed=embed)
else:
await ctx.send(content=cf.box(text=stdout, lang='yaml'))
except (FileNotFoundError):
try:
ns_process = await asyncio.create_subprocess_exec('nslookup', name, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
ns_stdout, ns_stderr = await ns_process.communicate()
if ns_stderr:
await ctx.maybe_send_embed(message="An error was encountered!\n" + cf.box(text=ns_stderr.decode()))
else:
warning = cf.warning("`dig` is not installed! Defaulting to `nslookup`.\nThis command provides more information when `dig` is installed on the system.\n")
if await ctx.embed_requested():
embed = Embed(
title="DNS Query Result",
color=await ctx.embed_color(),
timestamp=ctx.message.created_at
)
embed.description = warning + cf.box(text=ns_stdout.decode())
await ctx.send(embed=embed)
else:
await ctx.send(content = warning + cf.box(text=ns_stdout.decode()))
except (FileNotFoundError):
await ctx.maybe_send_embed(message=cf.error("Neither `dig` nor `nslookup` are installed on the system. Unable to resolve DNS query."))
@commands.command()
async def rfc(self, ctx: commands.Context, number: int) -> None:
"""Retrieve the text of an RFC document.
This command uses the [RFC Editor website](https://www.rfc-editor.org/) to fetch the text of an RFC document.
A [Request for Comments (RFC)](https://en.wikipedia.org/wiki/Request_for_Comments) is a publication in a series from the principal technical development and standards-setting bodies for the [Internet](https://en.wikipedia.org/wiki/Internet), most prominently the [Internet Engineering Task Force](https://en.wikipedia.org/wiki/Internet_Engineering_Task_Force). An RFC is authored by individuals or groups of engineers and [computer scientists](https://en.wikipedia.org/wiki/Computer_scientist) in the form of a [memorandum](https://en.wikipedia.org/wiki/Memorandum) describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems. It is submitted either for [peer review](https://en.wikipedia.org/wiki/Peer_review) or to convey new concepts, information, or, occasionally, engineering humor.""" # noqa: E501
url = f"https://www.rfc-editor.org/rfc/rfc{number}.html"
datatracker_url = f"https://datatracker.ietf.org/doc/rfc{number}"
async with aiohttp.ClientSession() as session:
async with session.get(url=url) as response:
if response.status == 200:
html = await response.text()
soup = BeautifulSoup(html, 'html.parser')
pre_tags = soup.find_all('pre')
content: list[Embed | str] = []
for pre_tag in pre_tags:
text = format_rfc_text(md(pre_tag), number)
if len(text) > 4096:
pagified_text = cf.pagify(text, delims=["\n\n"], page_length=4096)
for page in pagified_text:
if await ctx.embed_requested():
embed = Embed(
title=f"RFC Document {number}",
url=datatracker_url,
description=page,
color=await ctx.embed_color()
)
content.append(embed)
else:
content.append(page)
else:
if await ctx.embed_requested():
embed = Embed(
title=f"RFC Document {number}",
url=datatracker_url,
description=text,
color=await ctx.embed_color()
)
content.append(embed)
else:
content.append(text)
if await ctx.embed_requested():
for embed in content:
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}."))