JQ-Networks/UnifiedMessageRelay

tg 与 qq 无法互联

hsdchenliyang opened this issue · 44 comments

1 用的是docker 镜像安装coolq air 的方法 能收到qq消息(但不明白是不是作者所说的容器内部运行)
2 执行python3 daemon.py start 没有报错 但是在tg 发送 [show commands] 、 [show group id] 没有反应。
不知道会是哪里有问题呢

Z4HD commented

兄啊你是在宿主机运行的bot还是在容器内运行的bot?

(你是不是在noVNC的终端模拟器里运行的bot?)

在 tg 中发送[show group id]都没反应,意味着你的bot 配置有问题,请使用python3 daemon.py run前台执行查看输出

@Z4HD 我用的ubuntu 两个bot都在我自己电脑的终端运行的……

@jqqqqqqqqqq 请问python3 deamon.py 退出命令是什么? 我再试一下

Z4HD commented

@hsdchenliyang
先把bot的文件夹复制到Coolq数据文件夹,用下列命令进入coolq容器:

sudo docker exec -it coolq su

随后你就可以去/home/user/coolq 文件夹中找到bot并运行了。

退出是 python3 daemon.py stop,你随便输入错误命令或者不输入会提示的

@jqqqqqqqqqq
python3 daemon.py run输出 好像是tg的bot 连接不行 还是上面仁兄说的coolq的问题

Exception in thread updater:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/util/connection.py", line 83, in create_connection
raise err
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 617, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 360, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 857, in _validate_conn
super(HTTPSConnectionPool, self)._validate_conn(conn)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 289, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connection.py", line 284, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connection.py", line 146, in _new_conn
(self.host, self.timeout))
telegram.vendor.ptb_urllib3.urllib3.exceptions.ConnectTimeoutError: (<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0af6d4e080>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 189, in _request_wrapper
resp = self._con_pool.request(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 70, in request
**urlopen_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 148, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 244, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 695, in urlopen
**response_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 695, in urlopen
**response_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 695, in urlopen
**response_kw)
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 666, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.5/dist-packages/telegram/vendor/ptb_urllib3/urllib3/util/retry.py", line 376, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
telegram.vendor.ptb_urllib3.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot448519279:AAGc-Js2n_ufRfac502NTjJSoOp-p0DF1z0/setWebhook (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0af6d4e080>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 147, in _thread_wrapper
target(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 273, in _start_polling
self._bootstrap(bootstrap_retries, clean=clean, webhook_url='', allowed_updates=None)
File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 385, in _bootstrap
url=webhook_url, certificate=cert, allowed_updates=allowed_updates)
File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 57, in decorator
result = func(self, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 1653, in set_webhook
result = self.request.post(url, data, timeout=timeout)
File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 271, in post
**urlopen_kwargs)
File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 195, in _request_wrapper
raise NetworkError('urllib3 HTTPError {0}'.format(error))
telegram.error.NetworkError: urllib3 HTTPError HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot448519279:AAGc-Js2n_ufRfac502NTjJSoOp-p0DF1z0/setWebhook (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.connection.VerifiedHTTPSConnection object at 0x7f0af6d4e080>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)'))

你这不是没连上 bot,你这是没连上 telegram,你懂的

Z4HD commented

@hsdchenliyang 你怕是连不上Tg的API服务器,国内的话建议科学上网。

哦哦 谢谢两位 我再试试

用了终端代理proxychain [show commands] 、 [show group id] 可以了 消息还是不能互通 而且python3 daemon.py run输出的都是代理的东西 没有有用的信息了……

消息不能互通请检查cqsocketapi是否安装正常,多数情况是它导致的

这个安装了

安装后需要启用一下,是否启用过?

嗯 启用了 而且换你给的版本了……

好的,接下来看一下能不能看到coolq的日志里有client update一类的消息,如果没有的话意味着没有连接上

没有这类消息 我发现python3 daemon.py run的时候[show group id]有反应 python3 daemon.py start的时候[show group id]没反应 那应该还是网络问题吧

哦,start 的话会fork一个进程,可能机制不太一样,不确定能否用proxychain
如果解决不了你就用run配合nohup吧

谢谢 我去google一下nohup……

请问python3 daemon.py run 如果连上了 能实现消息互通吗

可以,run只是前台运行

实在找不到问题出在哪里了 你帮我看看配置有没有问题~

-- coding: utf-8 --

TOKEN = '448519279:AAGc-Js2n_ufRfa502NTjJSoOp-p0DF1z0'
QQ_BOT_ID = 293136420
FORWARD_LIST = [
{
'QQ': 293136420,
'TG': -26618350,
'Drive_mode': False,
'Pic_link': True
},
{
'QQ': 293216420,
'TG': -100112764868,
'Drive_mode': False,
'Pic_link': True
},
]
SERVER_PIC_URL = 'http://moulinroty.com:5050/image/'
CQ_ROOT = '/root/coolq-data'
CQ_PORT = 11235
JQ_MODE = False # if use Coolq Pro, set as True, otherwise False

配置应该没问题,你需要检查本地端口连没连上,如果没有client update说明本地127.0.0.1:11235 udp连不上

coolq启动的最后几行是这样的 这个5911端口是什么

[CQDaemon] Starting CoolQ ....
[CQDaemon] Started CoolQ .
localhost - - [15/Nov/2017 04:24:11] 127.0.0.1: Plain non-SSL (ws://) WebSocket connection
localhost - - [15/Nov/2017 04:24:11] connecting to: 127.0.0.1:5911

leon@leon-Lenovo-TianYi-100-14IBD:~$ telnet 127.0.0.1 11235
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

是这个原因吗

不是,它是udp,telnet 用的 tcp

你描述一下你的环境吧,比如coolq怎么跑的,有没有用 docker,有没有用proxy-chain
bot 怎么跑的,有没有在docker内运行,等等的

菜鸟一个 可能描述不清楚
docker上安装的coolq镜像 docker pull coolq/wine-coolq 没有进一步处理(刚刚接触docker 不知道算不算容器内运行)
运行指令是docker run --name=coolq --rm -p 8080:9000 -v /root/coolq-data:/home/user/coolq -e VNC_PASSWD=12345678 -e COOLQ_ACCOUNT=10000 coolq/wine-coolq

tg的bot是按照你给的教程安装的 用proxychains4 最后就是python3 daemon.py start 没反应 ,python3 daemon.py run [show group id]有反应 试了另一种代理方法 polipo 两个命令都没反应

难怪呢,你一个跑docker里一个跑docker外是连不上的,你需要把bot跑在docker内部

哦哦 那还是昨天那位兄弟讲的问题 我去研究一下docker……

嗯好,这个issue我close了,你只要跑 docker 内部就解决了应该

请教一下 docker需要安装python3.5 和python3-pip
是在coolq容器里面通过 Dockerfile 构建一个还是 通过python3.5镜像另外开一个容器(是否需要两个容器之间互联)

目前是非常 dirty 的操作,直接获取docker内的 shell 权限,直接装

等coolq-telegram-bot-docker出来之后会有所改善

那我应该是搞不定了……

并不麻烦,docker 内的 shell 用起来和 ubuntu 一样

这些基础的东西 docker不能用本机的吗 docker里有默认的python2.7.12

bot基于3.5实现的,与2.7不兼容

嗯 我知道 我想问的是宿主机装的python3.5 有没有办法被docker所利用

Z4HD commented

@hsdchenliyang
Docker和虚拟机类似,容器内是与宿主机隔离的。


推荐阅读《第一本Docker书

谢谢两位~

在docker参数里加上--net=host -p 127.0.0.1:11235:11235/udp 即可在docker内部转发11235 udp端口

这个操作可以,感谢

@milkice233 为什么我开了这个后容器内的coolq还是收不到容器外的消息呢。。。

底层api已更新,如果你更新了bot版本你需要按照教程装个新插件