Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added temp/wxqr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 8 additions & 25 deletions wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,30 +595,8 @@ def proc_msg(self):
break
elif retcode == '1101': # 从其它设备上登了网页微信
break
elif retcode == '0':
if selector == '2': # 有新消息
r = self.sync()
if r is not None:
self.handle_msg(r)
elif selector == '3': # 未知
r = self.sync()
if r is not None:
self.handle_msg(r)
elif selector == '6': # 可能是红包
r = self.sync()
if r is not None:
self.handle_msg(r)
elif selector == '7': # 在手机上操作了微信
r = self.sync()
if r is not None:
self.handle_msg(r)
elif selector == '0': # 无事件
pass
else:
print '[DEBUG] sync_check:', retcode, selector
r = self.sync()
if r is not None:
self.handle_msg(r)
elif retcode != -1:
self.sync_and_handle()
else:
print '[DEBUG] sync_check:', retcode, selector
self.schedule()
Expand All @@ -629,6 +607,11 @@ def proc_msg(self):
if check_time < 0.8:
time.sleep(1 - check_time)

def sync_and_handle(self):
r = self.sync()
if r is not None:
self.handle_msg(r)

def send_msg_by_uid(self, word, dst='filehelper'):
url = self.base_uri + '/webwxsendmsg?pass_ticket=%s' % self.pass_ticket
msg_id = str(int(time.time() * 1000)) + str(random.random())[:5].replace('.', '')
Expand Down Expand Up @@ -977,7 +960,7 @@ def status_notify(self):
return dic['BaseResponse']['Ret'] == 0

def test_sync_check(self):
for host in ['webpush', 'webpush2']:
for host in ['webpush']:
self.sync_host = host
retcode = self.sync_check()[0]
if retcode == '0':
Expand Down