Skip to content
MilesdenPublic

About

πŸƒ Telegram Durak (card game) bot built with Python + aiogram, featuring async gameplay and a modular architectur

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸƒ Durak Bot β€” Telegram Card Game

Python aiogram Platform

Chat preview

πŸ“Œ Description

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.

πŸš€ Features

  • πŸƒ 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

πŸ›  Technologies Used

  • Python 3
  • aiogram 2.x β€” async Telegram Bot framework
  • python-dotenv β€” environment variable loading

β–Ά How to Run

  1. Install Python 3
  2. Clone the repo:
    git clone https://github.com/Milesden/durak_bot.git
    cd durak_bot
  3. Install dependencies:
    pip install -r requirements.txt
  4. Set up your bot token:
    cp .env.example .env
    Then open .env and replace your_token_here with a real token from @BotFather.
  5. Run the bot:
    python main.py
  6. Open your bot in Telegram and send /start.

πŸ“š Concepts Used

  • Async/await (asyncio, aiogram handlers)
  • State management per user
  • Functions & modules
  • Conditional statements
  • Environment variables / secrets handling

πŸ“ Project structure

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

⚠️ Known limitations

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.

πŸ” Security note

Never commit your real .env file β€” it's already gitignored. Only .env.example (with a placeholder value) belongs in version control.

About

πŸƒ Telegram Durak (card game) bot built with Python + aiogram, featuring async gameplay and a modular architectur

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages