Files
isp-tycoon/main.py
2026-02-23 15:41:59 +07:00

53 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from aiogram import Bot, Dispatcher, types
from aiogram.enums import ParseMode
from aiogram import Router
import asyncio
import logging
from config import BOT_TOKEN
from database import init_db
from handlers.start import router as start_router
from handlers.build import router as build_router
from handlers.channel import router as channel_router
from handlers.stats import router as stats_router
from handlers.map import router as map_router
from handlers.events import router as events_router
router = Router()
dp = Dispatcher()
dp.include_router(start_router)
dp.include_router(build_router)
dp.include_router(channel_router)
dp.include_router(stats_router)
dp.include_router(map_router)
dp.include_router(events_router)
@dp.message()
async def echo(message: types.Message): # ← теперь types.Message — валидно
if message.text == "/check":
from database import get_player
from economy import calculate_effective_bandwidth, handle_outage, sync_power
player = get_player(message.from_user.id)
if not player:
await message.answer("❌ Игрок не найден")
return
player = handle_outage(player)
player = sync_power(player)
await message.answer(
f"⚡ Состояние проверено!\n"
f"Канал: {player['channel_capacity']}{calculate_effective_bandwidth(player)} Мбит/с\n"
f"Лимит: {player['power_usage']:.1f}/{player['power_capacity']} кВт"
)
async def main():
init_db()
bot = Bot(token=BOT_TOKEN, parse_mode=ParseMode.HTML)
print("🤖 ISP Tycoon bot started...")
await dp.start_polling(bot)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())