A Telegram bot that lets you play Durak (ΠΡΡΠ°ΠΊ) β the classic Russian card game β straight from a chat. Built with Python and aiogram, it deals a real 36-card deck, tracks a trump suit, and plays a full hand against you: attack, defend, refill from the deck, repeat until someone runs out of cards.
- π Real 36-card deck with proper trump handling
- π€ Bot opponent that defends with the cheapest valid card, saving trumps for later
- π Automatic hand refill from the deck after every round (up to 6 cards each)
- β¨οΈ Reply-keyboard UI β pick cards by tapping, no typing needed
- π³οΈ Surrender option at any time
- π― Win detection once the deck runs dry and a hand empties out
- π§© Clean, modular codebase β game rules separated from Telegram wiring
- Python 3
- aiogram 2.x β async Telegram Bot framework
python-dotenvβ environment variable loading
- Install Python 3
- Clone the repo:
git clone https://github.com/Milesden/durak_bot.git cd durak_bot - Install dependencies:
pip install -r requirements.txt
- Set up your bot token:
Then open
cp .env.example .env
.envand replaceyour_token_herewith a real token from @BotFather. - Run the bot:
python main.py
- Open your bot in Telegram and send
/start.
- Async/await (asyncio, aiogram handlers)
- State management per user
- Functions & modules
- Conditional statements
- Environment variables / secrets handling
durak_bot/
βββ main.py # Entry point β creates the bot and starts polling
βββ bot/
β βββ __init__.py
β βββ config.py # Loads BOT_TOKEN from .env
β βββ deck.py # Deck creation and card-beats-card rules
β βββ game.py # Game state: dealing, refilling, win checks
β βββ keyboards.py # Reply keyboard builders
β βββ handlers.py # Telegram message handlers
βββ assets/
β βββ preview.svg # README chat preview
βββ requirements.txt
βββ Procfile # For Heroku-style worker deployment
βββ .env.example # Template β copy to .env and fill in your token
βββ .gitignore
This is a simplified single-attacker-card version of Durak β no "podkidnoy" (throwing in extra cards of matching rank during a round) yet. Contributions or forks that add it are welcome.
Never commit your real .env file β it's already gitignored. Only
.env.example (with a placeholder value) belongs in version control.