Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
/ eaimty_bot Public archive

个人用 Telegram Bot

License

Notifications You must be signed in to change notification settings

EAimTY/eaimty_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eaimty_bot

个人用 Telegram Bot

功能

  • /about - 关于
  • /connectfour - 玩四子棋
  • /dart - 掷一枚飞标
  • /dice - 掷一枚骰子
  • /minesweeper [棋盘高] [棋盘宽] [地雷数] - 玩扫雷
  • /ocr - 识别图片中文字
  • /reversi - 玩黑白棋
  • /slot - 转一次老虎机
  • /tictactoe - 玩 Tic-Tac-Toe
  • /help - 帮助信息

...

游戏抽象均来自 EAimTY/gamie

依赖

Leptonica、Tesseract、Tesseract 语言包(eng、jpn、chi_sim、chi_tra)

使用

USAGE:
    eaimty_bot [OPTIONS] --token <TOKEN>

FLAGS:
    -h, --help       打印帮助信息
    -V, --version    打印版本信息

OPTIONS:
    -p, --proxy <PROXY>    设置代理(支持:http、https、socks5)
    -t, --token <TOKEN>    设置 Telegram Bot HTTP API Token
    -w, --webhook <PORT>   以 webhook 模式运行,后接监听端口号

本 bot 支持 longpoll 与 webhook 两种运行方式,默认使用 longpoll

以 webhook 模式运行时,由于 Telegram 限制,webhook 地址必须为 HTTPS 协议,所以需要使用任意 web server 作为中继,以 Nginx 为例:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # webhook callback URL 域名
    server_name DOMAIN;

    # SSL 证书设置
    ssl_certificate      /PATH/TO/cert.pem;
    ssl_certificate_key  /PATH/TO/key.pem;
    ssl_protocols        TLSv1.1 TLSv1.2 TLSv1.3;

    # webhook callback URL 路径
    location /PATH {
        proxy_redirect off;

        # bot 监听地址与端口
        proxy_pass http://127.0.0.1:PORT;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
    }
}

编译

git clone https://github.com/EAimTY/eaimty_bot.git
cd eaimty_bot

编译

cargo build --release

开源许可

The GNU General Public License v3.0