From 4e38e8a4ceab7c712b48efb54a60bdf3ef2b17d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aluerie=E2=9D=A4?= Date: Fri, 24 Nov 2023 01:28:29 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=ABThe=20chore:=20initial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/connector.py | 3 ++- scripts/be_management/be_mass_disenchant.py | 2 +- scripts/the_chore/chore.py | 27 +++++++++++++++++++++ scripts/utilities/combine_keys.py | 2 +- the_chore.bat | 3 +++ the_chore.py | 3 +++ 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 scripts/the_chore/chore.py create mode 100644 the_chore.bat create mode 100644 the_chore.py diff --git a/common/connector.py b/common/connector.py index c6ac7f4..82214e2 100644 --- a/common/connector.py +++ b/common/connector.py @@ -72,6 +72,7 @@ async def connect(self, _: Connection): else: try: self.console_text = await self.callback() + log.info(self.console_text) except Exception as exc: if isinstance(exc, CustomException): self.console_text = str(exc) @@ -85,7 +86,7 @@ async def connect(self, _: Connection): async def disconnect(self, _: Connection): log.info("Finished task. The LCU API client have been closed!") - async def callback(self) -> str: + async def callback(self: AluConnector) -> str: """This function will be called on @ready event It is supposed to be implemented by subclasses and do the script job. diff --git a/scripts/be_management/be_mass_disenchant.py b/scripts/be_management/be_mass_disenchant.py index aa5089e..9312750 100644 --- a/scripts/be_management/be_mass_disenchant.py +++ b/scripts/be_management/be_mass_disenchant.py @@ -40,7 +40,7 @@ class BEMassDisenchant(AluConnector): The script will show the list of shards to disenchant and then you will be able to confirm/deny the procedure. """ - async def callback(self) -> str: + async def callback(self: AluConnector) -> str: r_summoner = await self.get("/lol-summoner/v1/current-summoner") summoner_id: int = (await r_summoner.json())["summonerId"] diff --git a/scripts/the_chore/chore.py b/scripts/the_chore/chore.py new file mode 100644 index 0000000..0f0ec79 --- /dev/null +++ b/scripts/the_chore/chore.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +from common import AluConnector +from scripts.be_management import BEMassDisenchant +from scripts.utilities import CombineFragmentKeys + +import logging + +log = logging.getLogger(__name__) + + +class TheChore(AluConnector): + """ + This gathers all chores that I personally would love to do in just one click. + """ + + async def callback(self: AluConnector) -> str: + r1 = await BEMassDisenchant.callback(self) + log.info(r1) + r2 = await CombineFragmentKeys.callback(self) + log.info(r2) + + return "Chore is finished" + + +if __name__ == "__main__": + TheChore().start() diff --git a/scripts/utilities/combine_keys.py b/scripts/utilities/combine_keys.py index 2467d22..452fbe0 100644 --- a/scripts/utilities/combine_keys.py +++ b/scripts/utilities/combine_keys.py @@ -9,7 +9,7 @@ class CombineFragmentKeys(AluConnector): This script will try to combine all possible fragments, i.e. if you have 28 fragments - the script will combine 27 of those into 9 full keys. """ - async def callback(self) -> str: + async def callback(self: AluConnector) -> str: r_loot = await self.get("/lol-loot/v1/player-loot") loot = await r_loot.json() diff --git a/the_chore.bat b/the_chore.bat new file mode 100644 index 0000000..8e2553d --- /dev/null +++ b/the_chore.bat @@ -0,0 +1,3 @@ +CALL .\venv\Scripts\activate.bat +py the_chore.py +pause >nul \ No newline at end of file diff --git a/the_chore.py b/the_chore.py new file mode 100644 index 0000000..dbf3ce9 --- /dev/null +++ b/the_chore.py @@ -0,0 +1,3 @@ +from scripts.the_chore.chore import TheChore + +TheChore().start() \ No newline at end of file