From dfdf1217d23989aad5d906c31ae5eef3ed144124 Mon Sep 17 00:00:00 2001 From: timofey Date: Sat, 30 Mar 2024 15:15:10 +0000 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=20starts=20=E2=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- starbot/starbot/bot.py | 2 +- starbot/starbot/db_aiosqlite.py | 4 ++-- starbot/starbot/instrumentation.py | 4 ++-- starbot/starbot/stars.py | 25 +++++++++++++------------ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/starbot/starbot/bot.py b/starbot/starbot/bot.py index e53e9b0..ceb1bbe 100644 --- a/starbot/starbot/bot.py +++ b/starbot/starbot/bot.py @@ -48,7 +48,7 @@ class Reservation: def __enter__(self) -> Reserved: container = self.__container() if container is None: - raise RuntimeError("can't reserve in a non-existent container") + raise RuntimeError("⭐ can't reserve in a non-existent container ⭐") if self.__rc is None: other = container.get(self.__key) if other is not None: diff --git a/starbot/starbot/db_aiosqlite.py b/starbot/starbot/db_aiosqlite.py index c9b6c53..660eec7 100644 --- a/starbot/starbot/db_aiosqlite.py +++ b/starbot/starbot/db_aiosqlite.py @@ -10,7 +10,7 @@ from .db import AbstractConnection, AbstractDbFactory, AbstractDbManager def _load_key(key: Any, /) -> Hashable: - """note: unstable signature.""" + """⭐ note: unstable signature. ⭐""" match key: case Hashable(): return key @@ -19,7 +19,7 @@ def _load_key(key: Any, /) -> Hashable: case dict(): return tuple((_load_key(k), _load_key(v)) for k, v in key.items()) case _: - raise TypeError("unknown json key type, cannot convert to hashable") + raise TypeError("⭐ unknown json key type, cannot convert to hashable ⭐") class Adapter(AbstractConnection): diff --git a/starbot/starbot/instrumentation.py b/starbot/starbot/instrumentation.py index 261458a..1bfd519 100644 --- a/starbot/starbot/instrumentation.py +++ b/starbot/starbot/instrumentation.py @@ -14,9 +14,9 @@ class Instrumentation: def __init__(self, target, methodname: str): if not isinstance(methodname, str): - raise TypeError("methodname must be str") + raise TypeError("⭐ methodname must be str ⭐") if not callable(getattr(target, methodname)): - raise TypeError("target.methodname must be callable") + raise TypeError("⭐ target.methodname must be callable ⭐") self.target = target self.methodname = methodname diff --git a/starbot/starbot/stars.py b/starbot/starbot/stars.py index 913cb16..0fd912a 100644 --- a/starbot/starbot/stars.py +++ b/starbot/starbot/stars.py @@ -35,7 +35,7 @@ class TypedReservations(Generic[T]): with self.reservations.reserve(key, factory) as reserved: if not isinstance(reserved.value, self.type): if factory_called: - raise TypeError("factory seems to have returned a value of incorrect type") + raise TypeError("⭐ factory seems to have returned a value of incorrect type ⭐") else: yield reserved.value break @@ -215,39 +215,39 @@ class Stars(commands.Cog): @commands.hybrid_command() async def ping(self, ctx: commands.Context): - print("ping pong") + print("⭐ ping pong ⭐") await ctx.reply("pong", mention_author=False) @commands.hybrid_command() @commands.is_owner() async def reload(self, ctx: commands.Context): - print("reload") + print("⭐ reload ⭐") bot: commands.Bot = ctx.bot try: await bot.reload_extension("starbot.stars") except commands.ExtensionNotLoaded: - await ctx.reply("not loaded") - print("reloaded") - await ctx.reply("reloaded") + await ctx.reply("⭐ not loaded ⭐") + print("⭐ reloaded ⭐") + await ctx.reply("⭐ reloaded ⭐") @commands.hybrid_command() @commands.is_owner() async def sync(self, ctx: commands.Context): await ctx.bot.tree.sync() - print("synced") - await ctx.reply("synced") + print("⭐ synced ⭐") + await ctx.reply("⭐ synced ⭐") @commands.hybrid_command() @commands.has_permissions(administrator=True) async def assign(self, ctx: commands.Context, count: int): await AdminCtx(ctx).assign(count) - await ctx.reply("assigned") + await ctx.reply("⭐ assigned ⭐") @commands.hybrid_command() @commands.has_permissions(administrator=True) async def unassign(self, ctx: commands.Context): await AdminCtx(ctx).unassign() - await ctx.reply("unassigned") + await ctx.reply("⭐ unassigned ⭐") @commands.Cog.listener() async def on_raw_reaction_add(self, event: discord.RawReactionActionEvent): @@ -265,7 +265,7 @@ class Stars(commands.Cog): async def throttle(self, ctx: commands.Context, duration: float, delay: float): with Cooldown(StarEventCtx, "_on", delay): await asyncio.sleep(duration) - await ctx.reply(f"done") + await ctx.reply(f"⭐ done ⭐") class Cooldown(Instrumentation): @@ -293,10 +293,11 @@ async def setup(bot: StarBot): global cog cog = Stars(bot) await bot.add_cog(cog) + print("⭐ set up ⭐") async def teardown(bot: StarBot): global cog await bot.remove_cog(cog.qualified_name) del cog - print("torn down") + print("⭐ torn down ⭐")