GithubHelp home page GithubHelp logo

d-rickyy-b / python-blackjackbot Goto Github PK

View Code? Open in Web Editor NEW
75.0 8.0 36.0 617 KB

A Telegram bot written in Python to play the game BlackJack alone or with your friends

Home Page: https://telegram.me/BlackJackBot

License: GNU General Public License v3.0

Python 99.73% Dockerfile 0.27%
blackjack game bot chatbot telegram telegram-bot

python-blackjackbot's Introduction

Build Status Docker Image Version (latest semver) Coverage Status Codacy Badge

Python-BlackJackBot

This is the code for my Telegram Bot with which you can play the game Black Jack. You can find the hosted version of it here: https://telegram.me/BlackJackBot

Setup

This project is really easy to set up. No matter which of the following ways you'll use, you'll always need a config file. To create one, simply copy the existing config.sample.py file and name it config.py. Enter your bot token and make your changes accordingly.

Then you're left with several ways to run this bot.

1.) Cloning the repo

If you want to run this code from source, you can just git clone this repo. It's recommended to create a new virtual environment (python3 -m venv /path/to/venv). This bot uses the python-telegram-bot framework to make Telegram API calls. You can install it (and potential other requlrements) like that:

pip install -r requirements.txt

Afterwards just run python3 bot.py and if done right, you'll be left with a working bot.

2.) Docker

This project also contains a Dockerfile as well as a pre-built Docker image hosted on the official Docker Hub.

You will also find the docker-compose.yml file with which you can easily set up your own instance of the bot. Just specify the path to your config etc. in said docker-compose file.

python-blackjackbot's People

Contributors

d-rickyy-b avatar dependabot-preview[bot] avatar drblury avatar mxrk avatar poolitzer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-blackjackbot's Issues

Implement improved comment feature

The current comment feature is a bit buggy.

  1. check if a player is currently playing a game
  2. if yes: tell them that they can't send a comment at the moment & exit
    2.1 clear commenting state
  3. if no: request their comment + Inline cancel button + store message ID
  4. if game is started for that chat, edit message: "commenting during game is not possible" + remove keyboard + exit
    4.1 clear commenting state
  5. Wait for any kind of text and forward to the admins
    5.1 clear 'commenting' state

In-game money

  • Users can get money, if they play once per day
  • player class needs variable for the user's bet
  • in evaluation money needs to be given to the winners
  • new field in database

Automatic deploy to VPS

Some automated way to deploy the code to the VPS with travis should be used in order to keep stuff automated.

A script on the server side should be called to automatically switch user, git pull and systemctl restart bot.

I would need to implement a way to drain the bot, so that playing users are not kicked out of their current game, but instead get noticed, that the bot is going down for maintenance.


https://gist.github.com/jesgs/7815f791c98ea2f3e82c51f5c66b6ce1

Can't start new game

I started a new game, after few previous.In this new game i had 21 and Dealer had 25 from the start.
I can't stop the game I also can't start new game.
Look like a bug.

image

More feedback from bot

E.g. when trying to create a multiplayer game which cannot be established because of any reason, there should be a feedback from the bot to the user.

Other cases:

  • When trying to join a mp game
  • When trying to end/start games

Implement timer for multiplayer games to skip AFK players

In multiplayer games it can be frustrating when dealing with AFK players. To prevent that from happening, there should be a timer that skips players who are not participating. Default value of the timer: 30 seconds.

After the timer ends, the player will be skipped. It's basically the same as if they just chose to "stand".

Users are not getting a keyboard after starting a game via inline buttons

The bot uses selective keyboards so that not every player receives an annoying keyboard. When using inline buttons to join/start, the user won't receive a keyboard.

Steps to reproduce

  1. Start a new game in a group
  2. Have someone join the game via inline button

Expected result

Each player receives their keyboart to take part in the round

Actual result

The person starting/joining the game via inline button does not get a keyboard because there is no message to reply to

Multiplayer with strangers (without group)

  • Matching mechanism
  • Unique game-room IDs
  • Join a game-room via ID
  • Game room class with list of user IDs
  • Game rooms can be private
  • Normal blackjack class can be used, but chat ID must be replaced by game room id, so that messages can be sent to all the players via private message

Suggestions

  1. "Stop" button is a bit confusing. Sometimes people exchange it as the "No more card" button.

  2. Instead of a double /start command to play, maybe there should be a /new command for a new game and /start command to start the game.

  3. Replace the X in: "✖️Players who busted" with ❌.

Leave channels as soon as added

If the bot receives an update from a channel, it should leave it instantly.

Otherwise there will be an error happening at:

def game_commands(bot, update):
if update.message is None:
logger.warning("game_commands error happened again! Update: {}".format(update))
text = update.effective_message.text
chat_id = update.effective_message.chat_id
user = update.effective_user
user_id = user.id
first_name = user.first_name
last_name = user.last_name
username = user.username

Since channel updates don't have the user object.

Make inline keyboards game-bound

Inline keyboards from a previous message should not work for the current game.

Example: When you are mid game and there are "hit" and "stand" buttons, then you choose to /stop the game, you should not be able to use them for your current game again.

Implement timer for a freshly created game

When a multiplayer game is being created and there are not enough players after 5 minutes it should be stopped.
If there are enough players, the game will be started.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.