This is a simple Telegram inline bot providing Chinese word segmentation powered by the Jieba algorithm.
The official instance is @jiebabot.
Requries rustc 1.39+ for async/await.
# debug build
cargo build
# or, optimized build
cargo build --release
Configurations including bot token is provided at runtime via environment variables.
BOT_TOKEN
: required. This is what you get from botfather when you create a bot.RUST_LOG
: controls the logging behavior, for example:info
,debug
,jieba_bot=debug
,tbot
, etc. See the log crate.HTTPS_PROXY
: in the form ofhttp[s]://host:port
. Currently only http and https proxy is supported.
RUST_LOG=info BOT_TOKEN=xxxxxx cargo run --release
Alternatively, you can use systemd to manage the service. A demo systemd
service and an EnvironmentFile are included. Place the service file in
/etc/systemd/system
, put the executable at /usr/local/bin/jieba-bot
,
put jieba-bot.conf
in /etc
, and issue a systemctl daemon-reload
.
Then you can start and enable the jieba-bot
service using normal systemd
commands.
Q: Why not write this in Python?
A: Because I'm afraid of programming in dynamically-typed languages :)
This bot records nothing at all. All messages are discarded once processed.
This work is released under the WTFPL license. A copy of the license is provided in the LICENSE file.