Improve typing annotations
This commit is contained in:
parent
c6503b91af
commit
16e3182d52
16
ahtcg_bot.py
16
ahtcg_bot.py
@ -15,7 +15,7 @@ class ArkhamDBUpdater(commands.Bot):
|
|||||||
channel_list: set[int]
|
channel_list: set[int]
|
||||||
arkhamdb_client: ArkhamDBClient
|
arkhamdb_client: ArkhamDBClient
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
# TODO: should really be a database
|
# TODO: should really be a database
|
||||||
@ -29,9 +29,9 @@ class ArkhamDBUpdater(commands.Bot):
|
|||||||
await self.arkhamdb_client.close()
|
await self.arkhamdb_client.close()
|
||||||
await super().close()
|
await super().close()
|
||||||
|
|
||||||
def setup_commands(self):
|
def setup_commands(self) -> None:
|
||||||
@self.command(name='monitor')
|
@self.command(name='monitor')
|
||||||
async def monitor(ctx: commands.Context):
|
async def monitor(ctx: commands.Context) -> None:
|
||||||
"""Watch this channel for deck links and link to latest versions."""
|
"""Watch this channel for deck links and link to latest versions."""
|
||||||
await ctx.message.reply('Now monitoring this channel for deck IDs', mention_author=True)
|
await ctx.message.reply('Now monitoring this channel for deck IDs', mention_author=True)
|
||||||
self.channel_list.add(ctx.message.channel.id)
|
self.channel_list.add(ctx.message.channel.id)
|
||||||
@ -39,14 +39,14 @@ class ArkhamDBUpdater(commands.Bot):
|
|||||||
json.dump(list(self.channel_list), f)
|
json.dump(list(self.channel_list), f)
|
||||||
|
|
||||||
@self.command(name='forget')
|
@self.command(name='forget')
|
||||||
async def forget(ctx: commands.Context):
|
async def forget(ctx: commands.Context) -> None:
|
||||||
"""Remove this channel from the monitor list"""
|
"""Remove this channel from the monitor list"""
|
||||||
await ctx.message.reply('No longer monitoring this channel for deck IDs', mention_author=True)
|
await ctx.message.reply('No longer monitoring this channel for deck IDs', mention_author=True)
|
||||||
self.channel_list.discard(ctx.message.channel.id)
|
self.channel_list.discard(ctx.message.channel.id)
|
||||||
with open('channel_list.json', 'w') as f:
|
with open('channel_list.json', 'w') as f:
|
||||||
json.dump(list(self.channel_list), f)
|
json.dump(list(self.channel_list), f)
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self) -> None:
|
||||||
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
||||||
print('Enabled on servers:')
|
print('Enabled on servers:')
|
||||||
async for guild in self.fetch_guilds(limit=150):
|
async for guild in self.fetch_guilds(limit=150):
|
||||||
@ -118,14 +118,14 @@ class ArkhamDBUpdater(commands.Bot):
|
|||||||
message.channel.id in self.channel_list:
|
message.channel.id in self.channel_list:
|
||||||
await self.update_channel_latest_decks(message.channel)
|
await self.update_channel_latest_decks(message.channel)
|
||||||
|
|
||||||
async def on_message(self, message: discord.Message):
|
async def on_message(self, message: discord.Message) -> None:
|
||||||
await self.process_commands(message)
|
await self.process_commands(message)
|
||||||
await self.maybe_update_channel_for_message(message)
|
await self.maybe_update_channel_for_message(message)
|
||||||
|
|
||||||
async def on_message_edit(self, before: discord.Message, after: discord.Message):
|
async def on_message_edit(self, before: discord.Message, after: discord.Message) -> None:
|
||||||
await self.maybe_update_channel_for_message(after)
|
await self.maybe_update_channel_for_message(after)
|
||||||
|
|
||||||
async def on_message_delete(self, message: discord.Message):
|
async def on_message_delete(self, message: discord.Message) -> None:
|
||||||
await self.maybe_update_channel_for_message(message)
|
await self.maybe_update_channel_for_message(message)
|
||||||
|
|
||||||
@tasks.loop(hours=1)
|
@tasks.loop(hours=1)
|
||||||
|
@ -34,11 +34,11 @@ class ArkhamDBClient:
|
|||||||
|
|
||||||
origin: str
|
origin: str
|
||||||
|
|
||||||
def __init__(self, arkhamdb_origin: str = ARKHAMDB_ORIGIN):
|
def __init__(self, arkhamdb_origin: str = ARKHAMDB_ORIGIN) -> None:
|
||||||
self._session = aiohttp.ClientSession()
|
self._session = aiohttp.ClientSession()
|
||||||
self.origin = arkhamdb_origin
|
self.origin = arkhamdb_origin
|
||||||
|
|
||||||
async def close(self):
|
async def close(self) -> None:
|
||||||
await self._session.close()
|
await self._session.close()
|
||||||
|
|
||||||
async def get_latest_deck(self, deck_id: int) -> ArkhamDBDeck:
|
async def get_latest_deck(self, deck_id: int) -> ArkhamDBDeck:
|
||||||
|
Loading…
Reference in New Issue
Block a user