12 Commits

5 changed files with 18 additions and 10 deletions

View File

@@ -19,11 +19,11 @@ logger = logging.getLogger(__name__)
class PyroClient(LibPyroClient): class PyroClient(LibPyroClient):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.__version__ = (0, 1, 2) self.__version__ = (0, 1, 3)
super().__init__(**kwargs) super().__init__(**kwargs)
self.updater = Updater(ClientSession()) self.updater = Updater()
self.contexts = [] self.contexts = []
if self.scheduler is not None: if self.scheduler is not None:

View File

@@ -1,5 +1,5 @@
import logging import logging
from typing import Any, Dict, Tuple from typing import Any, Dict, Tuple, Union
from aiohttp import ClientSession from aiohttp import ClientSession
@@ -7,12 +7,15 @@ logger = logging.getLogger(__name__)
class Updater: class Updater:
def __init__(self, client_session: ClientSession) -> None: def __init__(self, client_session: Union[ClientSession, None] = None) -> None:
self.client_session: ClientSession = client_session self.client_session: Union[ClientSession, None] = client_session
async def check_updates( async def check_updates(
self, version_current: Tuple[int, int, int], api_url: str self, version_current: Tuple[int, int, int], api_url: str
) -> bool: ) -> bool:
if not self.client_session:
self.client_session = ClientSession()
response = await self.client_session.get(api_url) response = await self.client_session.get(api_url)
if response.status != 200: if response.status != 200:
@@ -30,6 +33,9 @@ class Updater:
) )
async def get_latest_release(self, api_url: str) -> Dict[str, Any]: async def get_latest_release(self, api_url: str) -> Dict[str, Any]:
if not self.client_session:
self.client_session = ClientSession()
response = await self.client_session.get(api_url) response = await self.client_session.get(api_url)
if response.status != 200: if response.status != 200:

View File

@@ -4,6 +4,7 @@ from argparse import ArgumentParser
from os import getpid from os import getpid
from pathlib import Path from pathlib import Path
from aiohttp import ClientSession
from convopyro import Conversation from convopyro import Conversation
from libbot import sync from libbot import sync
@@ -41,7 +42,8 @@ def main():
exit() exit()
client = PyroClient( client = PyroClient(
scheduler=scheduler, commands_source=sync.json_read(Path("commands.json")) scheduler=scheduler,
commands_source=sync.json_read(Path("commands.json")),
) )
Conversation(client) Conversation(client)

View File

@@ -13,7 +13,7 @@ async def command_toggle(app: PyroClient, message: Message):
await user.update_state(not user.enabled) await user.update_state(not user.enabled)
if user.enabled: if not user.enabled:
await message.reply_text( await message.reply_text(
app._("toggle_disabled", "messages", locale=user.locale) app._("toggle_disabled", "messages", locale=user.locale)
) )

View File

@@ -1,12 +1,12 @@
aiohttp~=3.10.0 aiohttp~=3.10.2
apscheduler~=3.10.4 apscheduler~=3.10.4
async_pymongo==0.1.6 async_pymongo==0.1.9
convopyro==0.5 convopyro==0.5
mongodb-migrations==1.3.1 mongodb-migrations==1.3.1
pytz>=2024.1 pytz>=2024.1
tgcrypto==1.2.5 tgcrypto==1.2.5
ujson>=5.0.0 ujson>=5.0.0
uvloop==0.19.0 uvloop==0.20.0
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple --extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
libbot[speed,pyrogram]==3.2.3 libbot[speed,pyrogram]==3.2.3
pykeyboard==0.1.7 pykeyboard==0.1.7