Generate VPN plans text dynamically with multiplier and real tg username

Agent-Logs-Url: https://github.com/kr0sh512/tt-simple/sessions/bc21e448-4bad-4522-8609-1b248a8dc082

Co-authored-by: kr0sh512 <46405586+kr0sh512@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-21 14:38:16 +00:00
committed by GitHub
co-authored by kr0sh512
parent 3a632e16ed
commit a924f57227
+11 -6
View File
@@ -305,16 +305,21 @@ class VpnBot:
) )
async def cmd_start(self, message: Message) -> None: async def cmd_start(self, message: Message) -> None:
username = f"tg{message.from_user.id}"
current = await self.marzban.get_user(username)
multiplier = self._extract_price_multiplier((current or {}).get("note"))
kb = InlineKeyboardBuilder() kb = InlineKeyboardBuilder()
for months, stars in PLANS.items(): plan_lines: list[str] = []
kb.button(text=f"{months} month — ⭐️{stars}", callback_data=f"buy:{months}") for months, base_stars in PLANS.items():
month_label = "month" if months == 1 else "months"
stars = self._stars_with_multiplier(base_stars, multiplier)
kb.button(text=f"{months} {month_label} — ⭐️{stars}", callback_data=f"buy:{months}")
plan_lines.append(f"{months} {month_label}{stars} stars")
kb.adjust(1) kb.adjust(1)
await message.answer( await message.answer(
"VPN subscription plans:\n" "VPN subscription plans:\n"
"• 1 month — 100 stars\n" + "\n".join(plan_lines)
"• 3 months — 270 stars\n" + f"\n\nUsername in VPN panel: <code>{username}</code>",
"• 6 months — 500 stars\n\n"
"Username in VPN panel: <code>tg{your_telegram_id}</code>",
reply_markup=kb.as_markup(), reply_markup=kb.as_markup(),
) )