Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ dependencies = [
"eiogram==2.0.1",
"hcloud==2.5.4",
"apscheduler>=3.11.0",
"aiohttp>=3.13.2",
]
12 changes: 10 additions & 2 deletions src/handlers/servers/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from src.lang import Dialogs
from src.keys import BotKB, BotCB, AreaType, TaskType
from src.utils.depends import GetHetzner, ClearState
from src.utils.euro import get_euro

router = Router()

Expand All @@ -28,8 +29,15 @@ async def servers_info(callback_query: CallbackQuery, callback_data: BotCB, hetz
price_hourly = "➖"
price_monthly = "➖"
if prices:
price_hourly = f"{float(prices[0]['price_hourly']['gross']):.4f}"
price_monthly = f"{float(prices[0]['price_monthly']['gross']):.2f}"
hourly = float(prices[0]["price_hourly"]["gross"])
monthly = float(prices[0]["price_monthly"]["gross"])
try:
euro_rate = await get_euro()
price_hourly = f"{hourly:.4f}€ [{hourly * euro_rate:,.0f}T]"
price_monthly = f"{monthly:.2f}€ [{monthly * euro_rate:,.0f}T]"
except Exception:
price_hourly = f"{hourly:.4f}€"
price_monthly = f"{monthly:.2f}€"

update = await callback_query.message.edit(
text=Dialogs.SERVERS_INFO.format(
Expand Down
4 changes: 2 additions & 2 deletions src/lang/_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Dialogs(StrEnum):
• Used: <code>{traffic_used_percent}% [Out/Included traffic]</code>
• Billable: <code>{traffic_billable} GB</code>
<b>💰 Price:</b>
• Hourly: <code>{price_hourly}</code>
• Monthly: <code>{price_monthly}</code>
• Hourly: <code>{price_hourly}</code>
• Monthly: <code>{price_monthly}</code>
<b>📅 Created:</b> <code>{created}</code> [<code>{created_day} days ago</code>]
"""
SERVERS_REBUILD_CONFIRM = "<b>⚠️ Are you sure you want to rebuild the server?</b>\n🧹 This action will erase all data on the server.\n🖼️ Please select an image to proceed."
Expand Down
9 changes: 9 additions & 0 deletions src/utils/euro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import aiohttp


async def get_euro() -> int:
async with aiohttp.ClientSession() as session:
async with session.get(url="https://sarfe.erfjab.com/api/prices") as res:
res.raise_for_status()
data = await res.json()
return int(data["eur1"])
Loading