fixes
This commit is contained in:
		
							parent
							
								
									0794a9392d
								
							
						
					
					
						commit
						4bf043d140
					
				| @ -49,8 +49,10 @@ def main(): | ||||
|     try: | ||||
|         loop.run_until_complete(task) | ||||
|     except (KeyboardInterrupt, InterruptedError, RuntimeError): | ||||
|         close(bot, loop) | ||||
|         loop.run_until_complete(task) | ||||
|         try: | ||||
|             close(bot, loop) | ||||
|         finally: | ||||
|             loop.run_until_complete(task) | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|  | ||||
| @ -6,8 +6,6 @@ from typing import Any | ||||
| 
 | ||||
| import aiosqlite | ||||
| 
 | ||||
| from starbot.db import AbstractDbManager | ||||
| 
 | ||||
| from .db import AbstractConnection, AbstractDbFactory, AbstractDbManager | ||||
| 
 | ||||
| 
 | ||||
| @ -42,7 +40,7 @@ class Adapter(AbstractConnection): | ||||
| async def manager(path: Path): | ||||
|     async with aiosqlite.connect(path) as connection: | ||||
|         db: dict[Hashable, Any] = {} | ||||
|         await connection.execute("CREATE TABLE IF NOT EXISTS kv(key, value)") | ||||
|         await connection.execute("CREATE TABLE IF NOT EXISTS kv(key PRIMARY KEY, value)") | ||||
|         for key, value in await connection.execute_fetchall("SELECT key, value FROM kv"): | ||||
|             db[_load_key(json.loads(key))] = json.loads(value) | ||||
|         yield Adapter(connection, db) | ||||
|  | ||||
| @ -8,10 +8,9 @@ from typing import AsyncContextManager, Callable, Generic, Hashable, Type, TypeV | ||||
| import discord | ||||
| from discord.ext import commands | ||||
| 
 | ||||
| from starbot.instrumentation import Instrumentation | ||||
| 
 | ||||
| from .bot import Reservations, StarBot, StarState | ||||
| from .db import AbstractConnection | ||||
| from .instrumentation import Instrumentation | ||||
| 
 | ||||
| T = TypeVar("T") | ||||
| 
 | ||||
| @ -91,7 +90,7 @@ class MessageState: | ||||
| 
 | ||||
|         return inner() | ||||
| 
 | ||||
|     async def __aexit__(self, et, ev, tb, /): | ||||
|     async def __aexit__(self, et, _ev, _tb, /): | ||||
|         return et and issubclass(et, EventuallyConsistent) | ||||
| 
 | ||||
| 
 | ||||
| @ -199,10 +198,11 @@ class ReactionCtx: | ||||
|     async def on(self) -> None: | ||||
|         if self.name != "⭐": | ||||
|             return | ||||
|         assignment: dict[str, int] | None = self.connection.get(("assign", self.guild_id), None) | ||||
|         if assignment is None: | ||||
|             return | ||||
|         star_channel_id, count = assignment["channel"], assignment["count"] | ||||
|         match self.connection.get(("assign", self.guild_id), None): | ||||
|             case {"channel": int() as star_channel_id, "count": int() as count}: | ||||
|                 pass | ||||
|             case _: | ||||
|                 return | ||||
|         if self.channel_id == star_channel_id: | ||||
|             return | ||||
|         await StarEventCtx(self, star_channel_id, count).on() | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user