Skip to content

A Telegram bot for querying TKFM recruitment tags, easily deployable with Docker.

License

Notifications You must be signed in to change notification settings

gordon0907/tkfmRecruitment

Repository files navigation

tkfmRecruitment

Python Docker License

This repository contains a Telegram bot for automatically querying recruitment tag combinations from the TenkafuMA! toolbox for the TenkafuMA! mobile game.

Table of Contents

Demo

Demo 1 Demo 2

Installation

Python Environment

  1. Clone the Repository

    git clone https://github.com/gordon0907/tkfmRecruitment.git
    cd tkfmRecruitment
  2. Install Required Modules

    pip install -r requirements.txt
  3. Define Telegram Bot Token

    If you don't already have a Telegram bot token, you can obtain one from BotFather.

    • Unix

      # Replace `your-telegram-bot-token` with your actual Telegram bot token
      export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
    • Windows (PowerShell)

      # Replace `your-telegram-bot-token` with your actual Telegram bot token
      $env:TELEGRAM_BOT_TOKEN = "your-telegram-bot-token"
  4. Run the Script

    python main.py

    Note: You may need to install additional dependencies as per the module's instructions.

Docker Container

  1. Clone the Repository

    git clone https://github.com/gordon0907/tkfmRecruitment.git
    cd tkfmRecruitment
  2. Build the Docker Image

    sudo docker build --tag tkfm-recruitment .
  3. Run the Docker Image in a Container

    If you don't already have a Telegram bot token, you can obtain one from BotFather.

    # Replace `your-telegram-bot-token` with your actual Telegram bot token
    # Replace `/path/to/local/data` with the path to your local data directory
    sudo docker run --name tkfm-recruitment-container --env TELEGRAM_BOT_TOKEN="your-telegram-bot-token" --volume /path/to/local/data:/app/data tkfm-recruitment
  4. Start the Existing Container

    After the initial run, you can start the existing container without recreating it:

    sudo docker start --attach tkfm-recruitment-container
  5. Save the Docker Image

    If you need to save the Docker image for future use:

    sudo docker save --output tkfm-recruitment.tar tkfm-recruitment

Usage

  1. Start the Bot: Use the /start command in the Telegram chat to receive a welcome message.
  2. Send a Screenshot: Send a screenshot of the Recruitment page in TKFM to the bot via Telegram as a photo (not as a file). The bot will reply with the query result in PDF format in the chat.

Configuration

User-defined OCR Word Replacement

To handle OCR misreading similar words, you can add word mappings for replacement in ./data/word_mappings.yaml. This file is generated after the first run and supports hot-editing, meaning you can edit word_mappings.yaml anytime without restarting the bot.

Additional Information

Enable GPU

By default, the OCR process does not utilize the GPU. To enable CUDA or MPS, you must install torch and torchvision before installing easyocr. For the installation command, please refer to the official PyTorch page.

For Docker users, you may need to modify the Dockerfile accordingly.

Refer to EasyOCR for more details on enabling GPU for the OCR process.

Cannot Read Text from the Screenshot

If the OCR fails to read text from the image, it is likely due to low image quality. In this case, try cropping the tags section and sending it to the bot. Ensure the word 招募條件 is included in the image, as it is used as a reference point during the tags filtering process.

For iOS users, do not use the Drag-and-Drop screenshot function, as it significantly reduces image quality.

Multi-language Support

Currently, there are no plans to support other languages for the game interface. However, you can manually change the language settings by editing image_ocr.py and tkfmtools.py. You can also modify main.py to support other languages for the Telegram bot.

Credit

TenkafuMA! toolbox

License

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

© 2024 gordon0907

About

A Telegram bot for querying TKFM recruitment tags, easily deployable with Docker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published