mirror of
https://github.com/Redume/Shirino.git
synced 2025-04-01 18:37:35 +03:00
Compare commits
5 commits
c0680d38d5
...
d47a1afb84
Author | SHA1 | Date | |
---|---|---|---|
d47a1afb84 | |||
ecdb072773 | |||
f57dfd4762 | |||
cc916c172a | |||
655cb35260 |
5 changed files with 19 additions and 17 deletions
|
@ -1,8 +1,8 @@
|
|||
services:
|
||||
shirino:
|
||||
build: .
|
||||
image: ghcr.io/shirino/shirino:latest
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- './config.yaml:/config.yaml'
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
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
|
||||
|
||||
from utils.format_number import format_number
|
||||
|
||||
config = yaml.safe_load(open('config.yaml', 'r', encoding='utf-8'))
|
||||
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
|
||||
|
||||
class Converter:
|
||||
def __init__(self):
|
||||
|
@ -25,23 +24,28 @@ 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:
|
||||
async with session.get(
|
||||
f'{config['kekkai_instance']}/api/metadata'
|
||||
f"{config['kekkai_instance']}/api/metadata"
|
||||
) as res:
|
||||
|
||||
if not HTTPStatus(res.status).is_success:
|
||||
return 'UTC'
|
||||
return (
|
||||
datetime.now() - timedelta(1)
|
||||
).strftime('%Y-%m-%d')
|
||||
|
||||
data = await res.json()
|
||||
return data.get('timezone', 'UTC')
|
||||
|
||||
return data.get(
|
||||
'last_date',
|
||||
(datetime.now() - timedelta(1)).strftime('%Y-%m-%d')
|
||||
)
|
||||
|
||||
async def kekkai(self) -> bool:
|
||||
timezone = pytz.timezone(await self.get_timezone())
|
||||
date = datetime.now(timezone).strftime('%Y-%m-%d')
|
||||
date = await self.get_lastdate()
|
||||
|
||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
||||
async with session.get(f'{config['kekkai_instance']}/api/getRate/', params={
|
||||
|
@ -58,7 +62,6 @@ class Converter:
|
|||
|
||||
return True
|
||||
|
||||
|
||||
async def ddg(self) -> None:
|
||||
async with aiohttp.ClientSession(
|
||||
timeout=aiohttp.ClientTimeout(total=3)
|
||||
|
|
|
@ -3,7 +3,7 @@ from http import HTTPStatus
|
|||
import yaml
|
||||
import aiohttp
|
||||
|
||||
config = yaml.safe_load(open('config.yaml', 'r', encoding='utf-8'))
|
||||
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
|
||||
|
||||
async def create_chart(from_currency: str, conv_currency: str) -> (dict, None):
|
||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
||||
|
|
2
main.py
2
main.py
|
@ -14,7 +14,7 @@ from functions.create_chart import create_chart
|
|||
from utils.format_number import format_number
|
||||
from utils.inline_query import reply
|
||||
|
||||
config = yaml.safe_load(open('config.yaml', 'r', encoding='utf-8'))
|
||||
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
|
||||
bot = Bot(
|
||||
token=config['telegram_token'],
|
||||
default=DefaultBotProperties(parse_mode=ParseMode.HTML)
|
||||
|
|
|
@ -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