Compare commits

...

4 Commits

Author SHA1 Message Date
a47a508ecf Update dependency pylint to v3.3.3
All checks were successful
Analysis / SonarCloud (pull_request) Successful in 34s
Tests / Build and Test (3.10) (pull_request) Successful in 1m2s
Tests / Build and Test (3.11) (pull_request) Successful in 1m1s
Tests / Build and Test (3.12) (pull_request) Successful in 1m14s
Tests / Build and Test (3.9) (pull_request) Successful in 1m3s
Analysis / SonarCloud (push) Successful in 39s
2024-12-24 05:27:30 +02:00
bdd649bdbe Update dependency types-aiofiles to v24.1.0.20241221
All checks were successful
Analysis / SonarCloud (pull_request) Successful in 38s
Tests / Build and Test (3.10) (pull_request) Successful in 1m4s
Tests / Build and Test (3.11) (pull_request) Successful in 1m2s
Tests / Build and Test (3.12) (pull_request) Successful in 1m9s
Tests / Build and Test (3.9) (pull_request) Successful in 1m6s
Analysis / SonarCloud (push) Successful in 44s
2024-12-21 05:18:48 +02:00
e6d9beec81 Update dependency mypy to v1.14.0
All checks were successful
Analysis / SonarCloud (pull_request) Successful in 35s
Tests / Build and Test (3.10) (pull_request) Successful in 3m26s
Tests / Build and Test (3.11) (pull_request) Successful in 1m15s
Tests / Build and Test (3.12) (pull_request) Successful in 1m7s
Tests / Build and Test (3.9) (pull_request) Successful in 1m5s
Analysis / SonarCloud (push) Successful in 46s
2024-12-20 17:47:59 +02:00
kku
5e479ddc79 Closes #161
All checks were successful
Analysis / SonarCloud (push) Successful in 48s
2024-12-18 13:53:09 +01:00
3 changed files with 24 additions and 6 deletions

View File

@@ -1,11 +1,11 @@
black==24.10.0
build==1.2.2.post1
isort==5.13.2
mypy==1.13.0
pylint==3.3.2
mypy==1.14.0
pylint==3.3.3
pytest-asyncio==0.25.0
pytest-cov==6.0.0
pytest==8.3.4
tox==4.23.2
types-aiofiles==24.1.0.20240626
types-aiofiles==24.1.0.20241221
types-ujson==5.10.0.20240515

View File

@@ -59,3 +59,15 @@ class PycordBot(Bot):
self.in_every_locale = self.bot_locale.in_every_locale
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
async def start(self, token: str, reconnect: bool = True, scheduler_start: bool = True) -> None:
if self.scheduler is not None and scheduler_start:
self.scheduler.start()
await super().start(token, reconnect=reconnect)
async def close(self, scheduler_shutdown: bool = True, scheduler_wait: bool = True) -> None:
if self.scheduler is not None and scheduler_shutdown:
self.scheduler.shutdown(scheduler_wait)
await super().close()

View File

@@ -125,7 +125,7 @@ class PyroClient(Client):
self.i18n_bot_info: bool = i18n_bot_info
async def start(self, register_commands: bool = True) -> None:
async def start(self, register_commands: bool = True, scheduler_start: bool = True) -> None:
await super().start()
self.start_time = time()
@@ -209,9 +209,12 @@ class PyroClient(Client):
kwargs={"command_sets": await self.collect_commands()},
)
self.scheduler.start()
if scheduler_start:
self.scheduler.start()
async def stop(self, exit_completely: bool = True) -> None:
async def stop(
self, exit_completely: bool = True, scheduler_shutdown: bool = True, scheduler_wait: bool = True
) -> None:
try:
await self.send_message(
chat_id=self.owner
@@ -223,6 +226,9 @@ class PyroClient(Client):
except BadRequest:
logger.warning("Unable to send message to report chat.")
if self.scheduler is not None and scheduler_shutdown:
self.scheduler.shutdown(scheduler_wait)
await super().stop()
logger.warning("Bot stopped with PID %s.", getpid())