Skip to content

Commit

Permalink
Bump to v0.2.7 #patch
Browse files Browse the repository at this point in the history
This version finally fixes the blacklisting module showing up in public commands and implements a decent amount of QoL changes. For more info, please see the changelogs ~ Noelle
  • Loading branch information
No767 authored Sep 19, 2023
2 parents 249e54e + 95410fc commit 3fe1a6e
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 92 deletions.
2 changes: 1 addition & 1 deletion bot/cogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def __str__(self) -> str:


EXTENSIONS = [module.name for module in iter_modules(__path__, f"{__package__}.")]
VERSION: VersionInfo = VersionInfo(major=0, minor=2, micro=6, releaselevel="final")
VERSION: VersionInfo = VersionInfo(major=0, minor=2, micro=7, releaselevel="final")
69 changes: 24 additions & 45 deletions bot/cogs/blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
from libs.ui.blacklist import BlacklistPages
from libs.utils import get_or_fetch_full_blacklist

HANGOUT_GUILD_ID = 1145897416160194590
ID_DESCRIPTION = "User or Guild ID to add"
HANGOUT_GUILD_ID = discord.Object(id=1145897416160194590)
DONE_MSG = "Done."


class Blacklist(commands.GroupCog, name="blacklist"):
class Blacklist(commands.Cog):
"""Global blacklist management cog"""

def __init__(self, bot: Catherine) -> None:
self.bot = bot
self.pool = self.bot.pool
self.id_description = "User or Guild ID to add"
self.done_msg = "Done."
super().__init__()

blacklist = app_commands.Group(
name="blacklist",
description="Blacklisting module",
guild_ids=[HANGOUT_GUILD_ID],
)

@is_owner()
@app_commands.guild_only()
@app_commands.command(name="view")
@app_commands.guilds(HANGOUT_GUILD_ID)
@blacklist.command(name="view")
async def view(self, interaction: discord.Interaction):
"""View the global blacklist"""
blacklist = await get_or_fetch_full_blacklist(interaction.client, self.pool)
Expand All @@ -37,58 +39,35 @@ async def view(self, interaction: discord.Interaction):
await pages.start()

@is_owner()
@app_commands.guild_only()
@app_commands.command(name="add")
@app_commands.guilds(HANGOUT_GUILD_ID)
@blacklist.command(name="add")
@app_commands.describe(id=ID_DESCRIPTION)
async def add(self, interaction: discord.Interaction, id: str):
"""Add to global blacklist"""
d_obj = discord.Object(id=int(id))
"""Adds an ID to the global blacklist"""
obj = discord.Object(id=int(id))
query = """
INSERT INTO blacklist (id, blacklist_status)
VALUES ($1, $2) ON CONFLICT (id) DO NOTHING;
"""
await self.pool.execute(query, d_obj.id, True)
if d_obj.id not in self.bot.blacklist_cache:
self.bot.add_to_blacklist_cache(d_obj.id)
await interaction.response.send_message(self.done_msg, ephemeral=True)
await self.pool.execute(query, obj.id, True)
if obj.id not in self.bot.blacklist_cache:
self.bot.add_to_blacklist_cache(obj.id)
await interaction.response.send_message(DONE_MSG, ephemeral=True)

@is_owner()
@app_commands.guild_only()
@app_commands.command(name="remove")
@app_commands.guilds(HANGOUT_GUILD_ID)
@blacklist.command(name="remove")
@app_commands.describe(id=ID_DESCRIPTION)
async def remove(self, interaction: discord.Interaction, id: str):
"""Remove from global blacklist"""
di_obj = discord.Object(id=int(id))
"""Removes an ID from the global blacklist"""
obj = discord.Object(id=int(id))
query = """
DELETE FROM blacklist
WHERE id = $1;
"""
await self.pool.execute(query, di_obj.id)
if di_obj.id in self.bot.blacklist_cache:
self.bot.remove_from_blacklist_cache(di_obj.id)

await interaction.response.send_message(self.done_msg, ephemeral=True)

@is_owner()
@app_commands.guild_only()
@app_commands.command(name="status")
@app_commands.guilds(HANGOUT_GUILD_ID)
@app_commands.describe(id=ID_DESCRIPTION, status="New status")
async def status(self, interaction: discord.Interaction, id: int, status: bool):
"""Update from global blacklist"""
dis_obj = discord.Object(id=int(id))
query = """
UPDATE blacklist
SET status = $2
WHERE id = $1;
"""
await self.pool.execute(query, dis_obj.id, status)
if id in self.bot.blacklist_cache:
self.bot.update_blacklist_cache(dis_obj.id, status)
await self.pool.execute(query, obj.id)
if obj.id in self.bot.blacklist_cache:
self.bot.remove_from_blacklist_cache(obj.id)

await interaction.response.send_message(self.done_msg, ephemeral=True)
await interaction.response.send_message(DONE_MSG, ephemeral=True)


async def setup(bot: Catherine) -> None:
Expand Down
7 changes: 2 additions & 5 deletions bot/cogs/dev_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import discord
from catherinecore import Catherine
from cogs import EXTENSIONS
from discord import app_commands
from discord.ext import commands
from discord.ext.commands import Context, Greedy

Expand All @@ -22,8 +21,7 @@ def display_emoji(self) -> discord.PartialEmoji:

@commands.guild_only()
@commands.is_owner()
@commands.hybrid_command(name="sync", hidden=True)
@app_commands.guilds(HANGOUT_GUILD_ID)
@commands.command(name="sync", hidden=True)
async def sync(
self,
ctx: Context,
Expand Down Expand Up @@ -69,8 +67,7 @@ async def sync(

@commands.guild_only()
@commands.is_owner()
@commands.hybrid_command(name="reload-all", hidden=True)
@app_commands.guilds(HANGOUT_GUILD_ID)
@commands.command(name="reload-all", hidden=True)
async def reload_all(self, ctx: commands.Context) -> None:
"""Reloads all cogs. Used in production to not produce any downtime"""
for extension in EXTENSIONS:
Expand Down
27 changes: 20 additions & 7 deletions bot/cogs/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,27 @@ async def version(self, interaction: discord.Interaction) -> None:
async def about(self, interaction: discord.Interaction) -> None:
"""Shows some basic info about Catherine-Chan"""
total_members = 0
total_unique = len(self.bot.users)

for guild in self.bot.guilds:
total_members += guild.member_count or 0

# For Kumiko, it's done differently
# R. Danny's way of doing it is probably clos enough anyways
# R. Danny's way of doing it is probably close enough anyways
memory_usage = self.process.memory_full_info().uss / 1024**2
cpu_usage = self.process.cpu_percent() / psutil.cpu_count()

revisions = self.get_last_commits()
embed = Embed()
embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.display_avatar.url) # type: ignore
embed.title = "Bot Invite"
embed.url = "https://discord.com/oauth2/authorize?client_id=1142620675517984808&scope=bot+applications.commands"
embed.title = "Support Server Invite"
embed.url = "https://discord.gg/ns3e74frqn"
embed.description = f"Latest Changes (Stable):\n {revisions}"
embed.set_footer(
text=f"Made with discord.py v{discord.__version__}",
icon_url="https://cdn.discordapp.com/emojis/596577034537402378.png?size=128",
)
embed.add_field(name="Servers Count", value=len(self.bot.guilds))
embed.add_field(
name="User Count", value=f"{total_members} total\n{total_unique} unique"
)
embed.add_field(name="User Count", value=f"{total_members} total")
embed.add_field(
name="Process", value=f"{memory_usage:.2f} MiB\n{cpu_usage:.2f}% CPU"
)
Expand All @@ -106,6 +103,22 @@ async def invite(self, interaction: discord.Interaction) -> None:
f"Invite Catherine-Chan using this link: {invite_url}"
)

@app_commands.command(name="support")
async def support(self, interaction: discord.Interaction):
"""Ways you can support Catherine-Chan!"""
invite_url = oauth_url(client_id=self.bot.application.id) # type: ignore # By the time the bot is ready, the app id is already there
desc = f"""
**Upvoting on Top.gg**: [Insert coming top.gg link]
**Joining the support server**: https://discord.gg/ns3e74frqn
**Inviting Catherine-Chan to you server**: {invite_url}
And there are more ways you can show your support! Check out the [support page](https://github.com/No767/Catherine-Chan#support) on how you can support the developer!
"""
embed = Embed()
embed.title = "Ways you can support"
embed.description = desc
await interaction.response.send_message(embed=embed)


async def setup(bot: Catherine) -> None:
await bot.add_cog(Meta(bot))
4 changes: 2 additions & 2 deletions bot/cogs/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ async def pride_servers(self, interaction: discord.Interaction) -> None:
)
await interaction.response.send_message(embed=embed)

@app_commands.command(name="support")
@app_commands.command(name="pride-support")
@app_commands.describe(type="The type of support your are looking for")
async def support(
async def pride_support(
self,
interaction: discord.Interaction,
type: Literal["HRT", "Therapy", "Hotlines", "Coming Out"],
Expand Down
13 changes: 8 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# 🛠️ Catherine-Chan 0.2.6 🛠️
# 🛠️ Catherine-Chan 0.2.7 🛠️

More smaller bugfix to ensure that the blacklist and dev tools commands are not being synced globally.
Finally the blacklist and dev tool commands are not synced globally. This release aims to fix that and adds some QoL improvements.

## ✨ TD;LR

- Fixed blacklist and sync commands showing up in public commands
- Fixed blacklist commands showing up in public commands **for real this time**

## 🛠️ Changes

- Fixed blacklist and sync commands showing up in public commands
- Fixed blacklist and sync commands showing up in public commands **for real this time**
- Migrate the sync and reload commands to be exclusively prefixed commands. This is done at the recommendation of Umbra and Nanika
- Switched the `/about` title URL to the support server invite link
- Renamed `/support` to be `/pride-support`

## ✨ Additions

- Reload all extensions cmd. This allows for essentially 0 downtime when all needs to be done is to pull the changes, reload all extensions, and then sync as needed
- A small little `/support` command to show ways you can better support Catherine-Chan

## ➖ Removals

Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/dev/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Above shown in Figure 1, is the project structure. Some folders will need to hav
* ``cog_utils`` - All the utilities functions, coroutines, and others get placed here. This sub-package in turn contains sub-packages that each relate to a specific cog. For example, if I wanted to write utilities for the extension ``support.py``, then it would be placed under ``cog_utils/support``.
* ``ui`` - All of the `UI components <https://discordpy.readthedocs.io/en/latest/interactions/api.html#bot-ui-kit>`_ of all of the cogs get placed here. The way that this sub-package is structured is exactly the same as the structure for ``cog_utils``.
* ``utils`` - All of the utility functions, coroutines, and others that are not related to a specific cog get placed here.
* ``pages`` - Catherine-Chan's custom ``discord-ext-menu`` paginator and all utilities for that are located here. The paginator is a modified version of `RoboDanny's paginator <https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/utils/paginator.py#L30>`_ that is modified to work for interactions only.
* ``pages`` - Catherine-Chan's custom ``discord-ext-menu`` paginator and all utilities for that are located here. The paginator is a modified version of `RoboDanny's paginator <https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/utils/paginator.py#L30C1-L233C20>`_ that is modified to work for interactions only.
* ``docker`` - Contains the Dockerfiles that can be used to build Catherine-Chan.
* ``envs`` - ENV file templates
* ``tests`` - All unit tests go in here. These are separated by feature.
Expand Down
7 changes: 3 additions & 4 deletions docs/source/guides/dev/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Debian/Ubuntu

.. code-block:: bash
sudo apt-get install libffi-dev python3-dev libnacl-dev libopus-dev \
sudo apt-get install libffi-dev python3-dev libnacl-dev libopus-dev \
libssl-dev curl wget git make
Expand All @@ -32,9 +32,8 @@ Fedora

.. code-block:: bash
sudo dnf install make libffi-devel python3-libnacl \
python3.11-devel openssl-devel \
opus-devel curl wget git
sudo dnf install make libffi-devel python3-libnacl python3.11-devel \
openssl-devel opus-devel curl wget git
OpenSUSE
^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Catherine-Chan
:caption: Motivation

motivation

.. toctree::
:maxdepth: 2
:hidden:
:caption: Terms of Service

terms-of-service/tos.rst
terms-of-service/privacy-policy.rst


.. figure:: /_static/pride_smaller.png
:align: right
Expand Down
4 changes: 3 additions & 1 deletion docs/source/motivation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ Now on to the last part: comparing the both of them. Here's a table comparing th
+------------------------+----------------+----------+
| Database Driver | asyncpg | pymongo |
+------------------------+----------------+----------+
| Documented (code)? | Mostly | None |
| Documented (code)? | Somewhat | None |
+------------------------+----------------+----------+
| Documented (features)? | Mostly | Mostly |
+------------------------+----------------+----------+
| Unit Tests? | Yes (100%) | No (0%) |
+------------------------+----------------+----------+
| Uvloop accelerated? | Yes | No |
+------------------------+----------------+----------+
| Prefix | ``/`` | ``/`` |
Expand Down
8 changes: 8 additions & 0 deletions docs/source/terms-of-service/privacy-policy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Privacy Policy
==============

*Effective September 18, 2023*

In a nutshell... **Catherine-Chan stores no personal data**.

If you doubt my statement, go ahead and read all of the source code that is provided `here <https://github.com/No767/Catherine-Chan>`_
14 changes: 14 additions & 0 deletions docs/source/terms-of-service/tos.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Terms of Service
=================

By using the services provided by Catherine-Chan, you agree to follow these terms stated below.

1. Don't make any content that discriminates against others based on age, ability, gender, sexuality, race, ethnicity, nationality, creed or any other trait.
2. Keep the content informative and appropriate for all ages.
3. Features such as the Tonetags and pronouns suggestions **are not places to advertise any form of information**
4. Don't abuse this bot. **I will track you down and ban you from the support server and blacklist you globally from using the bot if you do this**


.. warning::

**If you violate any of the conditions stated above, you or your server will be placed within the global blacklist system, meaning that you or your server will not be able to use any commands that Catherine-Chan has at all**
Loading

0 comments on commit 3fe1a6e

Please sign in to comment.