JQ-Networks / UnifiedMessageRelay

Group Message Forward Framework (supports QQ Telegram Line Discord)
MIT License
419 stars 59 forks source link

双边无法传输图片 #61

Closed 1715173329 closed 5 years ago

1715173329 commented 5 years ago

控制台输出

TG转发至QQ

coolq@hostname:~/coolq-telegram-bot$ python3 daemon.py run
[CTB.Main][DEBUG] (daemon.py:169): Now running in debug mode...
[telegram.ext.dispatcher][DEBUG] (dispatcher.py:131): Setting singleton dispatcher as <telegram.ext.dispatcher.Dispatcher object at 0x7f0f622089e8>
[JobQueue][DEBUG] (jobqueue.py:267): JobQueue thread started
[telegram.ext.updater][DEBUG] (updater.py:147): dispatcher - started
[telegram.ext.updater][DEBUG] (updater.py:147): updater - started
[telegram.ext.updater][DEBUG] (updater.py:264): Updater thread started (polling)
[telegram.ext.updater][DEBUG] (updater.py:308): Start network loop retry bootstrap del webhook
[telegram.bot][DEBUG] (bot.py:59): Entering: delete_webhook
[telegram.vendor.ptb_urllib3.urllib3.connectionpool][DEBUG] (connectionpool.py:835): Starting new HTTPS connection (1): api.telegram.org
[telegram.ext.dispatcher][DEBUG] (dispatcher.py:209): Dispatcher started
[CQHTTP][DEBUG] (__init__.py:157): Running on Host: 127.0.0.1, Port 8080, kwargs: {}
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.

[CTB.Main][INFO] (daemon.py:130): Coolq-http-api status: ok
[CTB.Main][INFO] (daemon.py:133): Coolq pro detected
[CTB.plugins.qq_namelist][DEBUG] (qq_namelist.py:13): plugins.qq_namelist loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: update namelist(update_namelist)
[CTB.main.command][DEBUG] (command.py:73): update namelist(update_namelist) added to global_vars
[CTB.plugins.qq_namelist][INFO] (qq_namelist.py:20): [qq_group_id]Try to update qq namelist
[CTB.plugins.qq_namelist][INFO] (qq_namelist.py:32): [qq_group_id]Successful update qq namelist
[CTB.plugins.show_group_id][DEBUG] (show_group_id.py:9): plugins.show_group_id loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: show group id(show_tg_group_id)
[CTB.main.command][DEBUG] (command.py:73): show group id(show_tg_group_id) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: show group id(show_qq_group_id)
[CTB.main.command][DEBUG] (command.py:73): show group id(show_qq_group_id) added to global_vars
[CTB.plugins.for_fun][DEBUG] (for_fun.py:9): plugins.for_fun loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: dice(dice)
[CTB.main.command][DEBUG] (command.py:73): dice(dice) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: rps(rps)
[CTB.main.command][DEBUG] (command.py:73): rps(rps) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: alipay(show_red_pack)
[CTB.main.command][DEBUG] (command.py:73): alipay(show_red_pack) added to global_vars
[CTB.plugins.recall][DEBUG] (recall.py:10): plugins.recall loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: recall(recall)
[CTB.main.command][DEBUG] (command.py:73): recall(recall) added to global_vars
[CTB.plugins._002_water_meter_control][DEBUG] (_002_water_meter_control.py:12): plugins._002_water_meter_control loading
[CTB.plugins._002_water_meter_control][DEBUG] (_002_water_meter_control.py:19): Begin loading water meter config
[CTB.plugins._002_water_meter_control][DEBUG] (_002_water_meter_control.py:178): plugins._002_water_meter_control loaded
[CTB.plugins._000_admins][DEBUG] (_000_admins.py:12): plugins._000_admins loading
[CTB.plugins._000_admins][DEBUG] (_000_admins.py:19): Begin loading admin list
[CTB.plugins._000_admins][DEBUG] (_000_admins.py:93): plugins._000_admins loaded
[CTB.plugins._001_group_invite][DEBUG] (_001_group_invite.py:13): plugins._001_group_invite loading
[CTB.plugins._1002_command][DEBUG] (_1002_command.py:12): plugins._1002_command loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: show commands(command_qq_cmd)
[CTB.main.command][DEBUG] (command.py:73): show commands(command_qq_cmd) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: show commands(command_tg_cmd)
[CTB.main.command][DEBUG] (command.py:73): show commands(command_tg_cmd) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: help(command_qq_h)
[CTB.main.command][DEBUG] (command.py:73): help(command_qq_h) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: help(command_tg_h)
[CTB.main.command][DEBUG] (command.py:73): help(command_tg_h) added to global_vars
[CTB.plugins._1001_filter_old_message][DEBUG] (_1001_filter_old_message.py:12): plugins._1001_filter_old_message loading
[CTB.plugins._1005_drive_mode][DEBUG] (_1005_drive_mode.py:14): plugins._1005_drive_mode loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: drive mode on(drive_mode_on)
[CTB.main.command][DEBUG] (command.py:73): drive mode on(drive_mode_on) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: drive mode off(drive_mode_off)
[CTB.main.command][DEBUG] (command.py:73): drive mode off(drive_mode_off) added to global_vars
[CTB.plugins._1006_water_meter_filter][DEBUG] (_1006_water_meter_filter.py:11): plugins._1006_water_meter_filter loading
[CTB.plugins._1100_text_forward][DEBUG] (_1100_text_forward.py:23): plugins._1100_text_forward loading
[CTB.main.command][DEBUG] (command.py:55): Registering new command: image link on(pic_link_on)
[CTB.main.command][DEBUG] (command.py:73): image link on(pic_link_on) added to global_vars
[CTB.main.command][DEBUG] (command.py:55): Registering new command: image link off(pic_link_off)
[CTB.main.command][DEBUG] (command.py:73): image link off(pic_link_off) added to global_vars
[CTB.plugins._1101_other_qq_group_events][DEBUG] (_1101_other_qq_group_events.py:9): plugins._1101_other_qq_group_events loading
[telegram.vendor.ptb_urllib3.urllib3.connectionpool][DEBUG] (connectionpool.py:412): https://api.telegram.org:443 "POST /bottg_bot_token/deleteWebhook HTTP/1.1" 200 68
[telegram.bot][DEBUG] (bot.py:61): True
[telegram.bot][DEBUG] (bot.py:62): Exiting: delete_webhook
[telegram.ext.updater][DEBUG] (updater.py:268): Bootstrap done
[telegram.ext.updater][DEBUG] (updater.py:308): Start network loop retry getting Updates
[telegram.bot][DEBUG] (bot.py:59): Entering: get_updates
[telegram.vendor.ptb_urllib3.urllib3.connectionpool][DEBUG] (connectionpool.py:412): https://api.telegram.org:443 "POST /bottg_bot_token/getUpdates HTTP/1.1" 200 545
[telegram.bot][DEBUG] (bot.py:1771): Getting updates: [539026705]
[telegram.bot][DEBUG] (bot.py:61): [<telegram.update.Update object at 0x7f0f5c1832b0>]
[telegram.bot][DEBUG] (bot.py:62): Exiting: get_updates
[telegram.ext.dispatcher][DEBUG] (dispatcher.py:227): Processing Update: {'update_id': 539026705, 'message': {'message_id': 149, 'date': 1550063465, 'chat': {'id': tg_group_id, 'type': 'supergroup', 'title': 'tg_group_name'}, 'entities': [], 'caption_entities': [], 'photo': [{'file_id': 'AgADBQAD_agxG9eJIFcq_zRBEZLumVfk3zIABOdvu4ukfpuH23QBAAEC', 'width': 85, 'height': 90, 'file_size': 1802}, {'file_id': 'AgADBQAD_agxG9eJIFcq_zRBEZLumVfk3zIABALUz8KqmJ2t2nQBAAEC', 'width': 112, 'height': 118, 'file_size': 4653}], 'new_chat_members': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'from': {'id': tg_user_id, 'first_name': '\u2060', 'is_bot': False, 'last_name': 'tg_user_name', 'username': 'tg_username', 'language_code': 'zh-hans'}}}
[telegram.ext.conversationhandler][DEBUG] (conversationhandler.py:257): selecting conversation (tg_group_id, tg_user_id) with state None
[CTB.main.utils][DEBUG] (utils.py:240): tg -> qq: [{'type': 'image', 'data': {'file': 'AgADBQAD_agxG9eJIFcq_zRBEZLumVfk3zIABALUz8KqmJ2t2nQBAAEC.jpg'}}]
[CTB.main.message_persistence][DEBUG] (message_persistence.py:39): append tg_msg_id:149, qq_msg_id:73, qq_num:0, time:1550063466 to _0
[telegram.bot][DEBUG] (bot.py:59): Entering: get_updates

QQ转发至TG

[CTB.main.utils][DEBUG] (utils.py:454): qq -> tg: [{'data': {'file': '621F6B932516F22B06C3448152E18A18.jpg', 'url': 'image_url'}, 'type': 'image'}]
Traceback (most recent call last):
  File "/home/coolq/.local/lib/python3.6/site-packages/bottle.py", line 862, in _handle
    return route.call(**args)
  File "/home/coolq/.local/lib/python3.6/site-packages/bottle.py", line 1740, in wrapper
    rv = callback(*a, **ka)
  File "/home/coolq/coolq-telegram-bot/cqhttp/__init__.py", line 147, in _handle
    result = handler(request.json)
  File "/home/coolq/coolq-telegram-bot/cqhttp/__init__.py", line 79, in wrapper
    return func(*args, **kwargs)
  File "/home/coolq/coolq-telegram-bot/plugins/_1100_text_forward.py", line 414, in handle_forward
    qq_user=context['user_id'])
  File "/home/coolq/coolq-telegram-bot/main/utils.py", line 479, in send_from_qq_to_tg
    result = cq_get_fileid(message_part)
  File "/home/coolq/coolq-telegram-bot/main/cq_utils.py", line 187, in cq_get_fileid
    file_id = global_vars.fdb.get_fileid_by_md5(parser['image']['md5'])
  File "/usr/lib/python3.6/configparser.py", line 959, in __getitem__
    raise KeyError(key)
KeyError: 'image'
127.0.0.1 - - [13/Feb/2019 20:49:44] "POST / HTTP/1.1" 500 741

部署方式

手动部署

配置文件

bot_constant.py

# -*- coding: utf-8 -*-

DEBUG_MODE = True  # log will not take up much place, but it is necessary when locating problems

BAIDU_API = 'asdasdaasd'

# cq-http-api server config
API_ROOT = 'http://127.0.0.1:5700/'  # should be the same as cq-http-api api address
ACCESS_TOKEN = 'token'  # should be the same as cq-http-api config
SECRET = 'secret'  # should be the same as cq-http-api config

# cq-http-api client config, should be the same as cq-http-api post config
HOST = '127.0.0.1'
PORT = 8080

TOKEN = 'tg_bot_token'
QQ_BOT_ID = 'qq_user_id'
FORWARD_LIST = [
    {'QQ': qq_group_id,
     'TG': tg_group_id,
     'DRIVE_MODE': False,
     'IMAGE_LINK': False}
]
USE_SHORT_URL = False
SERVER_PIC_URL = 'http://expample.com/image/'
CQ_ROOT = '/home/coolq/coolq-telegram-bot/cqp-data/'
JQ_MODE = True
CQ_ROOT_DIR = '/home/coolq/coolq/'
# if you need socks5 proxy, setup proxy_url as below
# PROXY_URL = 'socks5://127.0.0.1:1080/'
# if you don't need socks5 proxy, set an empty variable
PROXY_URL = ''

coolq_httpapi.json

{
    "host": "127.0.0.1",
    "port": 5700,
    "use_http": true,
    "ws_host": "127.0.0.1",
    "ws_port": 6700,
    "use_ws": false,
    "ws_reverse_url": "",
    "ws_reverse_api_url": "",
    "ws_reverse_event_url": "",
    "ws_reverse_reconnect_interval": 3000,
    "ws_reverse_reconnect_on_code_1000": true,
    "use_ws_reverse": false,
    "post_url": "http://127.0.0.1:8080",
    "access_token": "token",
    "secret": "secret",
    "post_message_format": "array",
    "serve_data_files": false,
    "update_source": "github",
    "update_channel": "stable",
    "auto_check_update": false,
    "auto_perform_update": false,
    "show_log_console": false,
    "log_level": "info"
}

问题

双边无法传输图片 TG的图片转发到QQ,从输出中找不到明显的报错,QQ这边直接显示TG的用户名和一个冒号,无图片 QQ的图片转发到TG,直接报错 从issues中找不到可以参考的(

1715173329 commented 5 years ago

将CQ_ROOT改为CoolQ所在目录即可解决此问题。 感谢两位大佬 @jqqqqqqqqqq @Z4HD1 。