Files
2018-04-19 13:26:14 +03:00

2.5 KiB

The PvP chess bot for the Telegram

Overview

A simple PvP chess game based on editing a reply markup of a chess board. The board built with callback buttons of an inline-keyboard. Bot uses the node-chess package, which is driven by the algebraic notation of moves.

Features:

  • The chess board based on inline keyboard buttons and editing of reply markup.
  • PvP - play with friends.
  • All moves stored in the DB, so you can play a few games simultaneously.

Usage

Demo (WIP version).

Commands

  • /start - shows a list of available for join games and the Create new game button. It is the default state.

Each list item contains id's of players and completed moves count. The first id is always for a white player. If it is your id, then there will be YOU word, instead of id. Your turn marker will be shown if the game needs your attention (your turn now).

Select the game you need now:

All buttons are clickable and boards will be updated right after you or your opponent had made a turn. The star near a player's id means it is a turn of a side where it placed now.

Buttons:

  • Back - return to the list of games
  • Reverse - NOT IMPLEMENTED YET
  • Index - NOT IMPLEMENTED YET

Install and run own bot instance

First clone this repository and install dependencies. Run in the terminal:

git clone git@github.com:Piterden/chessbot.git
cd chessbot
npm i

Then you need to create and fill up a new .env file:

cp .env.example .env
editor .env

Next migrate the DB:

node_modules/.bin/knex migrate:latest

Then run the dev mode:

npm run dev

Built With

  • Telegraf.js - Telegram bot framework for Node.js.
  • Node-Chess - A simple node.js library for parsing and validating chess board position with an algebraic move parser.
  • Knex - A query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details