Telegram:
QQ:
QQ & Telegram Relay Bot v3.1
QQ API based on CoolQ HTTP API,Telegram API based on python_telegram_bot
- Support Message Recalling(2-minute limitation)
- Edits will recall old messages(2-minute limitation)
- Support text forward between QQ and Telegram
- Images from QQ will be forwarded to Telegram, but Telegram images will be forwarded via links
- Telegram stickers will be converted to emojis, with link if enabled IMAGE_LINK_MODE
- Some QQ emojis will be converted to unicode emojis
- Support temporarily disable forwarding
- Support commands, use
!!show commands
or!!cmd
to list
- Support text forward between QQ and Telegram
- Images will be forwarded to opposite sides
- Some QQ emojis will be converted to unicode emojis
- Support commands, use
!!show commands
or!!cmd
to list
Docker is preferred, choose one from below if you want
- coolq/wine-coolq Official Coolq Docker
- richardchien/cqhttp richardchien's Coolq Docker, with Coolq http api
- coolq-telegram-bot-docker Based on richardchien's Coolq Docker, with Coolq Telegram Bot require manually
build
。
Please follow the instruction of the one you chose, and jump to Configuration part of this instruction
If you don't prefer Docker, follow this instruction (Please use Ubuntu, since bugs appear on Debian 9)
- Typical Coolq http api config (
app/io.github.richardchien.coolqhttpapi/config.cfg
)
[general]
host=0.0.0.0
port=5700
use_http=yes
ws_host=0.0.0.0
ws_port=5700
use_ws=no
post_url=http://127.0.0.1:8080
access_token=very
secret=long
post_message_format=array
serve_data_files=no
update_source=https://raw.githubusercontent.com/richardchien/coolq-http-api-release/master/
update_channel=stable
auto_check_update=no
auto_perform_update=no
thread_pool_size=4
server_thread_pool_size=1
Since Coolq Air doesn't support sending images, Telegram images will be sent via link. You need to expose these images for access.
Install nginx under Ubuntu
sudo apt-get install nginx
edit nginx/conf/nginx.conf,this config maps /home/coolq/coolq/data/image
to www.example.com:8080/image
server {
listen 8080;
server_name www.example.com;
location /image/ {
root /home/coolq/coolq/data;
}
}
pip3.6 install -r requirements.txt
Please rename bot_constant-sample.py
to bot_constant.py
before use.
Key | Value |
---|---|
TOKEN |
Telegram tot token |
QQ_BOT_ID |
QQ bot number |
FORWARD_LIST |
A list that defines forwards. Every dict in this list [QQ Group Number, Telegran Group ID,Default for DRIVE_MODE, Default for IMAGE_LINK_MODE] stands for a forward. Only one to one forward is supported. |
SERVER_PIC_URL |
Your server's domain(used for url access, if you are using Pro, you can set whatever you like since it is not used) |
CQ_ROOT_DIR |
Coolq's root directory |
API_ROOT |
'http://127.0.0.1:5700/' cq-http-api's api root |
ACCESS_TOKEN |
'access_token' cq-http-api's access_token, see cq-http-api's doc for further information |
SECRET |
'secret ' cq-http-api's secret, see cq-http-api's doc for further information |
HOST |
'127.0.0.1' cq-http-api's event report address |
PORT |
8080 cq-http-api's event report port |
DEBUG_MODE |
Debug mode. Set to True is encouraged. Since rotate log handler is used, it will take up no more than 3MB. |
Key - Value peer is the same as above
If you want to use JSON, please copy bot_constant-json.py
to bot_constant.py
if you want to load external settings file, use CTB_JSON_SETTINGS_PATH
Example:
$ export CTB_JSON_SETTINGS_PATH="/home/user/bot_constant.json"
tools/bot_constant-py2json.py
provides convertion from bot_constant.py
tp bot_constant.json
Attention: Python 3.6 is required due to variable type hinting is used
Make sure Coolq is started and logged in, bot_constant.py is configured
Use python3.6 daemon.py run
to start your bot. This will run your bot in foreground and enable DEBUG mode temporarily
If no ERROR occurs, please Ctrl C
and use python3.6 daemon.py start
There're other commands like stop
and restart
When updating bot, be aware of that restart
sometimes cause error. Please stop
and start
instead.
Send !!show commands
or !!cmd
to view all commands
Send !!alipay
of !!ali
,to acquire. This action will donate the author without costing your money
Send !!show group id
or !!id
in Telegram groups to view Telegram Group ID
Send !!update namelist
or !!name
to update qq name list manually
Enable: Send !!pic link on
or !!lnkon
Disable: Send !!pic link off
or !!lnkoff
Telegram images and stickers will forward to QQ via links after enabled this
Enable:Send !!drive mode on
or !!drive
Disable:Send !!drive mode off
or !!park
Forward function will be disabled temporarily after enabled this
Reply !!recall
or !!del
in Telegram to any message you want to recall in QQ.
Message must be sent by bot in QQ side.
** If the message exceed 2 minutes, recall will fail**
Currently QQ group invites and accept invites is available via private chat.
You can find out the usage by reading plugins/_00x_xxxxx.py
- Check if you are using Python 3.6+
- Check if requirements.txt is installed correctly
- Check if cq-http-api is enabled in Coolq
- Descriptions about the issue
- Logs of python3 daemon.py run (Desensitization)
- Whether you are using Docker
- Which branch you are on (Dev of Master)