This repository contains a Telegram bot for automatically querying recruitment tag combinations from the TenkafuMA! toolbox for the TenkafuMA! mobile game.
-
Clone the Repository
git clone https://github.com/gordon0907/tkfmRecruitment.git cd tkfmRecruitment
-
Install Required Modules
pip install -r requirements.txt
-
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"
-
-
Run the Script
python main.py
Note: You may need to install additional dependencies as per the module's instructions.
-
Clone the Repository
git clone https://github.com/gordon0907/tkfmRecruitment.git cd tkfmRecruitment
-
Build the Docker Image
sudo docker build --tag tkfm-recruitment .
-
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
-
Start the Existing Container
After the initial run, you can start the existing container without recreating it:
sudo docker start --attach tkfm-recruitment-container
-
Save the Docker Image
If you need to save the Docker image for future use:
sudo docker save --output tkfm-recruitment.tar tkfm-recruitment
- Start the Bot: Use the
/start
command in the Telegram chat to receive a welcome message. - 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.
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.
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.
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.
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.
This project is licensed under the MIT License - see the LICENSE file for details.
© 2024 gordon0907