The avtTicTacToeBot
project is a Telegram's bot for playing Tic-Tac-Toe.
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.
$ python3 -m venv ./venv
$ source ./venv/bin/activate
Use (venv) $ deactivate
for deactivate and exit from Python virtual environment.
You can install or upgrade python-telegram-bot library with:
$ pip3 install python-telegram-bot --upgrade
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.
# 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
# ...
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.
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.
/start
- start a new game.
/rules
- get the game rules.
/cancel
- cancel the game by user.
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.1 Used http://t.me/avtTicTacToeBot short link to start interacting with bot
4.3 User choice 'X' for game (in this case). By random selection, the user is given the right of first move
We wish victories in the Tic-Tac-Toe game with the avtTicTacToeBot
!
― A.V.T. Software (Andrei Tolstikov, Vita Tolstikova)