egnchen / pyqqrobot Goto Github PK
View Code? Open in Web Editor NEW基于Python3与WebQQ协议的QQ机器人框架 A QQ robot framework based on WebQQ and Python3.
基于Python3与WebQQ协议的QQ机器人框架 A QQ robot framework based on WebQQ and Python3.
怎么终止listening... 我想加一个自动重启功能
我首先将qqhttp_gevent.py
里的mHTTPClient_gevent._gevent_req()
中
f = self.opener.open(r)
改成了
f = self.opener.open(r, timeout=5)
这样就能够每隔五秒钟检测一下“停止”标记是否设置,而不是一直堵塞;
接下来,我将qqrobot.py
中listen()
里面创建线程的代码改了下,大概是这样:
class l(threading.Thread):
def __init__(self, qcli, poll_headers):
threading.Thread.__init__(self)
self.poll_headers = poll_headers
self.qcli = qcli
self._running = True
def run(self):
log.i('listener', 'Listener thread started.')
while self._running:
log.i('listener', 'Still running, start of loop.')
print(str(threading.enumerate()))
# 上面这行列出所有线程以便debug
r = self.qcli.http_client.req(
url_poll2, data=d, headers=self.poll_headers)
self.qcli._callback_receive(
r, {'url': url_poll2,
'data': d, 'headers': self.poll_headers})
log.i('listener', 'Still running, end of loop.')
log.i('listener', 'Listener thread stopped.')
def cancel(self):
# C中的线程结束是cancel,我就直接用这个命名了,虽然感觉用terminate命名会更好
log.i('STOP', 'going to stop')
self._running = False
self.join()
self.t = l(self, self.poll_headers)
self.t.start()
if join:
self.t.join()
(作为一个新手,我也不知道是不是有问题...)
然后在listen()
的下面添加了一个极其简单的listen_stop()
def listen_stop(self):
self.t.cancel()
这就算是改造完成了。然而,调用listen_stop
会出现一些很玄学的情况,就是线程显示已经退出,但实际上还在运行... 有时间再来补充,再去debug一会
File "/home/wtm/Working/QQRobot/qqrobot.py", line 344, in get_self_info
headers=self.default_header)
AttributeError: 'QQClient' object has no attribute 'default_header'
^在qqrobot.py里的344行,default_headers
被打成了default_header
找到你的bug了哈哈哈哈哈哈哈哈哈哈(雾
更新之后特别慢,从veri文件里读入完Username之后就卡很长时间才登录,登录之后获取消息延迟特别大,如果直接扫码登录的话也是特别慢。是代码问题吗?
I just wonder what is the JS file in the dir dev/. We just need the python codes from src/, right?
我这边已经把代码写好了,可惜太忙,没时间整理上传(我本地的代码与上传到GitHub的代码会略有不同,所以需要整理)。这个issue放在这里,等我弄好了,发个PR,就close。
你没告诉我们怎么处理群和讨论组啊,难道让我自己翻代码?
(好像也不是不可以,但是你至少加个API手册吧)
收不到消息,用别人的帐号也是这样
之前sendMessage可以给好友发消息的,现在不可以了,提示KeyError。
另外,sendGroupMessage我试了几次也没能成功发送消息。
只能获取uin,而且还是被webQQ魔改过的,完全不友好啊。求获取姓名/昵称的方法
at example code in readme.md:
<-- /bin/usr/env
--> /usr/bin/env
初步判断是QQClient.listen(join=False)
或者QQClient.listen()
,但是貌似这样listen之后没法发送信息,显示The following error occurred when sending last message:
,但是冒号后面就什么也没有了...
求解。
难道我需要自己开一个线程单独listen(join=True)
?
^这好像是可行方法。
发送消息的时候尖括号疑似编码后未进行解码,变成>和<了。
RT.
出现retcode 1202,log显示发送成功,但是接收者未收到信息。
而且,这个号用webQQ也无法发送消息了,请问有人知道为啥吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.