The avtTicTacToeBot project
1. Introduction
The avtTicTacToeBot project is a Telegram's bot for playing Tic-Tac-Toe.
2. Requirements
The avtTicTacToeBot project requires the following components:
- Python 3.6.5 - Python is a programming language that lets you work quickly.
- python-telegram-bot 11.1.0 - This library provides a pure Python interface for the Telegram Bot API.
3. How to prepare and start using the avtTicTacToeBot project step by step
3.1 Fork, Clone or Download the project
3.2 Create and activate a new Python virtual environment
$ python3 -m venv ./venv
$ source ./venv/bin/activate
Use (venv) $ deactivate for deactivate and exit from Python virtual environment.
3.3 Install the requirements
You can install or upgrade python-telegram-bot library with:
$ pip3 install python-telegram-bot --upgrade
3.4 Create a new Telegram bot with BotFather and obtain an Access Token
BotFather is a special bot for creating and managing bots in Telegram. To create a new Telegram bot and generate an Access Token, you have to talk to @BotFather and follow a few simple steps (described here).
Note: Don't use avtTicTacToeBot name as the Username for your bot.
3.5 Replace '<your-TOKEN>' with your Bot's API token received from BotFather
# avt-tic-tac-toe-bot/bot.py
# ...
def main():
# Create the EventHandler and pass it your bot's token.
updater = Updater('<your-TOKEN>')
# Get the dispatcher to register handlers
dp = updater.dispatcher
# ...
3.6 Running the bot written with python-telegram-bot library
To run the bot from command line:
$ python3 bot.py
Note: Press Ctrl-C on the command line or send a signal to the process to stop the bot.
3.7 Start interacting with the bot
Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use
telegram.me/<bot_username>links or username search to find your bot.
For example, for avtTicTacToeBot, the link to start interacting with the bot will look like this: http://t.me/avtTicTacToeBot.
3.7.1 Commands to control the bot during the game
/start - start a new game.
/rules - get the game rules.
/cancel - cancel the game by user.
3.7.2 Using custom keyboards
For ease of interaction with the bot during the game, it is recommended to use the following special custom keyboards:
- to select a game letter (X or O)

- to perform the next move on the board (from 1 to 9)

- to answer the question of the completion or the beginning of a new game (yes or no)

4. Example of the Tic-Tac-Toe game session with avtTicTacToeBot
4.1 Used http://t.me/avtTicTacToeBot short link to start interacting with bot

4.2 Used /start command to start game session with avtTicToeBot


4.3 User choice 'X' for game (in this case). By random selection, the user is given the right of first move

4.4 The game loop, when the user and the bot perform moves in turn




4.5 The completion of the game in a draw and the proposal to play again

4.6 The game is over

4.7 Example of using /rules command


4.8 Example of using /cancel command

We wish victories in the Tic-Tac-Toe game with the avtTicTacToeBot!
― A.V.T. Software (Andrei Tolstikov, Vita Tolstikova)
Built With
- python-3.6.5
- python-telegram-bot-11.1.0

Log in or sign up for Devpost to join the conversation.