Telegram robot that helps you check your express delivery and automatically tracks the latest status of your express delivery! The finished product can be stamped:
@bennyblog_bot( This robot is maintained by me for a long time )
This robot can not only chat and check express delivery! Believe it or not, you can also send a voice message to it! You can also search for American and Japanese dramas! For detailed information, please see Functions and TODO
Due to the sudden surge in robot usage recently, using the polling mode can easily lead to the usage of Express 100's free API exceeding 2,000 times per day, resulting in the IP being blocked, so we are currently planning to change the API. For the time being, I have only found this one better option:
Anyone who is capable is welcome to submit PR or other express API suggestions! Thank you very much. There is still a problem with SF Express’s query. I don’t know which API can be used.
start - enter the courier number to query
help - help
list - View my query history
delete - Delete a certain number query record
quickdel - Reply to a query message to quickly delete the tracking number query record
query - Query American TV series and movies
yyets - Query download link
weather - Query the recent weather forecast for a specified city
Add a robot and directly send the waybill number to query (and add it to the tracking); If your order number contains letters, please use /start danhao123
; If you need to track multiple order numbers at one time, please use /start 123,123
English half-width comma separated (of course, it will be miserable if updated)
Just send a message directly or send a voice (Chinese Mandarin)
/query 蝙蝠侠
/yyets 神盾局
, then click the button to operateIt needs to be deployed on a server that can access the Telegram API (or set up a proxy). It supports both Python 2 and Python 3. Python 3 is recommended and has been tested on the following platforms:
Windows 10: Python 2.7.13 32bit Python 3.6.3 32bit
Ubuntu 16.04/14.04, CentOS 7, Debian 9: Python 2.7
The one-click script will run better under systemd. The one-click script is only tested on Ubuntu 16.04: First switch to the root user:
wget -N --no-check-certificate https://raw.githubusercontent.com/BennyThink/ExpressBot/master/install.sh && bash install.sh
Then follow the prompts. Systems that support systemd will be installed as systemd services at the same time. Other systems can use the corresponding init to manually configure or use supervisor
shortcut operation.
# 启动服务
bash install.sh start
# 停止服务
bash install.sh stop
Note: If you are prompted wget: command not found
under CentOS, please install wget yum install wget
If the one-click script fails, you can try manual configuration
git clone https://github.com/BennyThink/ExpressBot
cd ExpressBot
pacman -S python python-pip python-certifi python-chardet python-future python-idna python-requests python-six python-urllib3
然后从 AUR 安装 python-pytelegrambotapi .
sudo apt install python3 python3-pip git
sudo pip3 install -r requirements.txt
Python3 please use pip3
instead of pip
pip install setuptools
pip install -r requirements.txt
Download and install Python from the Python official website, switch to the project directory, if it is Python 2:
pip install -r requirements.txt
If it is Python 3, execute the following command:
pip3 install -r requirements.txt
ffmpeg is to support audio recognition (using ffmpe for transcoding of audio files).
If you are on Windows, download the binary exe file of ffmpeg from here (all three are required) and put it in PATH; if you are on Linux distribution, you can install it directly with the package manager (you can also compile or download the binary). Debian system can use sudo apt install ffmpeg
, RHEL can use yum install ffmpeg
Modify config.py
for configuration. TOKEN is the API of Bot. If TURING_KEY is not configured, the robot function will not be enabled.
TOKEN = 'Your TOKEN'
TURING_KEY = 'Your Key'
Create unit file: vim /lib/systemd/system/expressbot.service
Replace yourself and enter the following information
[Unit]
Description=A Telegram Bot for querying expresses
After=network.target network-online.target nss-lookup.target
[Service]
Restart=on-failure
Type=simple
ExecStart=/usr/bin/python /home/ExpressBot/expressbot/main.py
[Install]
WantedBy=multi-user.target
Reload daemon, self-start, start
systemctl daemon-reload
systemctl enable expressbot.service
systemctl start expressbot.service
I used restart=on-failure
parameter, and it will restart after exiting on failure. If set to always
, it means that no matter what the reason is, as long as the process is gone, systemd will help us restart it immediately. See the systemd.service
manual for details.
For testing purposes, run main.py
with nohub or screen. For Python 3, please replace python3
with python
cd /home/ExpressBot/expressbot
nohup python main.py
# 或者
cd /ExpressBot/expressbot
screen -S tgbot
python main.py
If you need to track updates and push them, then we need to poll regularly.
The timer currently used is apscheduler, and INTERVAL
in config.py
can be used to set the interval.
# 查看运行状态
sudo systemctl status expressbot.service
# 启动
sudo systemctl start expressbot.service
# 停止
sudo systemctl stop expressbot.service
# 重启
sudo systemctl restart expressbot.service
supervisor
Docker is currently supported, but has not been tested in detail.
docker pull bennythink/expressbot:latest
docker run -d --restart=always -e TOKEN= " TOKEN " -e TURING= " KEY " expressbot:v1
If you want to build it yourself, then download the Dockerfile back and then
docker build -t expressbot:v1 .
First of all, please allow me to give you a strong warning that all messages sent to this bot may be logged. But in fact, this robot is quite conscientious. By default, it will only record the following information in the database after the query is successful. You can see it by using the /list
command:
If you send a voice, the voice file will be placed in the /tmp
directory I don't guarantee that I will have the moral integrity not to check the database, but I guarantee that I will properly protect the database and prevent it from being leaked.
So, if you don’t want to use it, don’t use it; or you can delete it after checking it.
There is a file called msg.py
For debugging and other needs, you can set LOGGER
to True in config.py
Of course, you cannot set Turing API in the group (even the function of querying express delivery should be abolished) To prevent the robot from talking nonsense). In addition, the privacy mode of the robot needs to be turned on in the group.
Hmm, maybe the interface of Express 100 is fried; try again later.
It may be that the order number has just been generated, and there is no data for Express 100 yet.
Currently, no reliable REST API for SF Express query interface has been found.
Currently we are planning to change the express API. It seems that Express Bird is a better choice (supports push), but it requires real-name authentication...
yyets
is used to obtain the correct download link by clicking the InlineKeyboardButton, but the prerequisite is that there can only be one search result (only the first one is returned for multiple results); query
is used to retrieve all information. For example, if I want to download Nolan's The Dark Knight Rises, I can find the unique name through query
, and then use /yyets 《蝙蝠侠:黑暗骑士崛起》(The Dark Knight Rises)
to get the unique result.
Sort by completion status and priority
/start 123,123
English half-width comma InsecureRequestWarning
is currently disabled GPL v2