From b3aeae64e9ef6c7215b11385122d696a74da3f23 Mon Sep 17 00:00:00 2001 From: bvn13 Date: Thu, 11 Jul 2024 00:58:11 +0300 Subject: [PATCH] upd --- config/newsmaker.json | 24 ------------------------ src/bot/bot.py | 7 +++++++ src/settings/config.py | 4 ++++ version | 2 +- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/config/newsmaker.json b/config/newsmaker.json index f461791..1ccb3eb 100644 --- a/config/newsmaker.json +++ b/config/newsmaker.json @@ -1,17 +1,5 @@ { "onMessage": { - "-1001491510225": [ - { - "filter": { - "type": "contain", - "value": "Школьный" - }, - "action": { - "type": "forward", - "chatId": -1001699667908 - } - } - ], "-1002182676107": [ { "filter": { @@ -23,18 +11,6 @@ "chatId": -1002184916546 } } - ], - "-1001652154331": [ - { - "filter": { - "type": "contain", - "value": "Школьный" - }, - "action": { - "type": "forward", - "chatId": -1001699667908 - } - } ] } } \ No newline at end of file diff --git a/src/bot/bot.py b/src/bot/bot.py index 8084a67..7b5bc47 100644 --- a/src/bot/bot.py +++ b/src/bot/bot.py @@ -27,6 +27,13 @@ class Bot(): await self.__bot.send_read_acknowledge(event.chat_id, event.message) raise events.StopPropagation + @self.__bot.on(events.NewMessage(incoming=True, pattern="!config")) + async def onMessageReload(event): + self.__reload() + await event.reply("```\n{0}\n```".format(self.__config.read_as_text())) + await self.__bot.send_read_acknowledge(event.chat_id, event.message) + raise events.StopPropagation + @self.__bot.on(events.NewMessage(incoming=True, pattern="!reload")) async def onMessageReload(event): self.__reload() diff --git a/src/settings/config.py b/src/settings/config.py index f5c8c49..bf12935 100644 --- a/src/settings/config.py +++ b/src/settings/config.py @@ -16,6 +16,10 @@ class Config(): return on_message[chat_id_str] return None + def read_as_text(self) -> str: + with open(self.__filename, 'r') as f: + return ''.join(f.readlines()) + def __read(self) -> None: with open(self.__filename, 'r') as f: self.__config = json.load(f) diff --git a/version b/version index 6c6aa7c..6da28dd 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.1.0 \ No newline at end of file +0.1.1 \ No newline at end of file