mirror of
https://github.com/Redume/Shirino.git
synced 2025-04-01 18:37:35 +03:00
chore: Rewrote the date retrieval function if there is no data
This commit is contained in:
parent
c0680d38d5
commit
655cb35260
2 changed files with 6 additions and 9 deletions
|
@ -1,10 +1,9 @@
|
|||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from http import HTTPStatus
|
||||
|
||||
import pytz
|
||||
import aiohttp
|
||||
import yaml
|
||||
|
||||
|
@ -25,7 +24,7 @@ class Converter:
|
|||
|
||||
self.conv_amount = format_number(Decimal(self.conv_amount))
|
||||
|
||||
async def get_timezone(self) -> str:
|
||||
async def get_lastdate(self) -> str:
|
||||
async with aiohttp.ClientSession(
|
||||
timeout=aiohttp.ClientTimeout(total=3)
|
||||
) as session:
|
||||
|
@ -37,11 +36,11 @@ class Converter:
|
|||
return 'UTC'
|
||||
|
||||
data = await res.json()
|
||||
return data.get('timezone', 'UTC')
|
||||
|
||||
return data.get('last_date', datetime.now() - timedelta(1))
|
||||
|
||||
async def kekkai(self) -> bool:
|
||||
timezone = pytz.timezone(await self.get_timezone())
|
||||
date = datetime.now(timezone).strftime('%Y-%m-%d')
|
||||
date = datetime.strftime(await self.get_lastdate(), '%Y-%m-%d')
|
||||
|
||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
||||
async with session.get(f'{config['kekkai_instance']}/api/getRate/', params={
|
||||
|
@ -58,7 +57,6 @@ class Converter:
|
|||
|
||||
return True
|
||||
|
||||
|
||||
async def ddg(self) -> None:
|
||||
async with aiohttp.ClientSession(
|
||||
timeout=aiohttp.ClientTimeout(total=3)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
aiohttp~=3.9.5
|
||||
PyYAML~=6.0.1
|
||||
aiogram~=3.15.0
|
||||
pytz~=2025.2
|
||||
aiogram~=3.15.0
|
Loading…
Add table
Add a link
Reference in a new issue