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

SyncCheck url 有时会切换到其他地址 #139

Open
wants to merge 42 commits into
base: master-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
db7881f
add tuling123 news response content
xyzsss May 11, 2016
619e0d0
Merge pull request #59 from xyzsss/master
liuwons May 12, 2016
3aba6a5
增加链接重试, 增加从群名称中查找id
May 13, 2016
cd4f757
Merge pull request #62 from liuyang007/master
liuwons May 13, 2016
656e5dc
optimize some code
May 13, 2016
ddc795f
Merge pull request #63 from liuyang007/master
liuwons May 13, 2016
41fd44f
really optimize the code
xmcp May 14, 2016
ebae801
Merge pull request #64 from xmcp/master
liuwons May 14, 2016
6e7cb58
add __init__让外部引用模块
May 16, 2016
b72e48f
add exception print
May 16, 2016
4542daf
Merge pull request #65 from liuyang007/master
liuwons May 16, 2016
1c28e44
fix #66
May 17, 2016
efb24cb
add msg type 49 content
May 17, 2016
7d3af03
没注意大小写- -
May 17, 2016
051288b
Merge pull request #68 from liuyang007/master
liuwons May 17, 2016
ac09292
获取图片用文件保存方式通用性不大,一般都是获取到数据解耦到另外一个程序执行,所以把这个加到消息体中,因为只有带session的cookie…
May 17, 2016
9141ed5
Merge pull request #70 from liuyang007/master
liuwons May 17, 2016
f237ef9
update README
liuwons May 18, 2016
a845385
update README
liuwons May 18, 2016
9c218fa
indent fix and optimus code
May 31, 2016
f37776a
增加发送图片和文件的接口
liuwons Jul 30, 2016
8007109
update README
liuwons Jul 30, 2016
02ed127
修改生成的文件to本目录下的temp目录
vivre90 Aug 5, 2016
87d418c
Merge pull request #94 from vivre90/patch-1
liuwons Aug 7, 2016
2d012d6
fix a bug when get group member name, params order is wrong
bitQ2019 Aug 10, 2016
8782959
Merge pull request #98 from Menq/master
liuwons Aug 10, 2016
bb066c2
设置联系人的备注名
thriteen Aug 15, 2016
ec7e0d3
Update wxbot.py
thriteen Aug 15, 2016
8fff2d6
add QQ group
Aug 17, 2016
d635c8d
Merge pull request #101 from thriteen/master
liuwons Aug 17, 2016
0dc2d77
请求加好友
thriteen Aug 17, 2016
134ae98
Merge pull request #104 from thriteen/master
liuwons Aug 17, 2016
a95b4d0
reformat code
Aug 17, 2016
88c815f
fix null pointer
Aug 17, 2016
addc616
自动响应好友请求
vivre90 Aug 26, 2016
aea3551
Merge pull request #107 from vivre90/patch-2
liuwons Aug 26, 2016
ea1bda0
change url of upload_media
Aug 26, 2016
fae4cf1
change path for send file and img msg
Aug 26, 2016
faf1a30
exception fix
Aug 27, 2016
d7f99d1
新增3个群管接口
vivre90 Aug 27, 2016
ef6b3bd
Merge pull request #109 from vivre90/patch-3
liuwons Aug 27, 2016
9e9c7a7
Fix sync_check url bug when use alternative weixin server.
SolessChong Oct 12, 2016
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
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
- [ ] 红包
- [ ] 转账

- [x] 消息发送
- [x] 文本
- [x] 图片
- [x] 文件



Web微信协议参考资料:
Expand Down Expand Up @@ -58,7 +63,7 @@ pip install Pillow

### 2.1 代码

以下的代码对所有来自好友的文本消息回复 *hi* , 并不断向好友 *tb* 发送 *schedule* 。
以下的代码对所有来自好友的文本消息回复文本消息 *hi* 、图片消息 *1.png* 以及文件消息 *1.png* , 并不断向好友 *tb* 发送文本 *schedule* 。

`handle_msg_all` 函数用于处理收到的每条消息,而 `schedule` 函数可以做一些任务性的工作(例如不断向好友推送信息或者一些定时任务)。

Expand All @@ -73,6 +78,8 @@ class MyWXBot(WXBot):
def handle_msg_all(self, msg):
if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
self.send_msg_by_uid(u'hi', msg['user']['id'])
self.send_img_msg_by_uid("img/1.png", msg['user']['id'])
self.send_file_msg_by_uid("img/1.png", msg['user']['id'])

def schedule(self):
self.send_msg(u'tb', u'schedule')
Expand Down Expand Up @@ -195,6 +202,9 @@ python test.py
| `get_voice(msgid)` | 获取语音消息并保存到本地文件 ***voice_[msgid].mp3*** , `msgid` 为消息id(Web微信数据) |
| `get_contact_name(uid)` | 获取微信id对应的名称,返回一个可能包含 `remark_name` (备注名), `nickname` (昵称), `display_name` (群名称)的字典|
| `send_msg_by_uid(word, dst)` | 向好友发送消息,`word` 为消息字符串,`dst` 为好友用户id(Web微信数据) |
| `send_img_msg_by_uid(fpath, dst)` | 向好友发送图片消息,`fpath` 为本地图片文件路径,`dst` 为好友用户id(Web微信数据) |
| `send_file_msg_by_uid(fpath, dst)` | 向好友发送文件消息,`fpath` 为本地文件路径,`dst` 为好友用户id(Web微信数据) |
| `send_msg_by_uid(word, dst)` | 向好友发送消息,`word` 为消息字符串,`dst` 为好友用户id(Web微信数据) |
| `send_msg(name, word, isfile)` | 向好友发送消息,`name` 为好友的备注名或者好友微信号, `isfile`为 `False` 时 `word` 为消息,`isfile` 为 `True` 时 `word` 为文件路径(此时向好友发送文件里的每一行),此方法在有重名好友时会有问题,因此更推荐使用 `send_msg_by_uid(word, dst)` |
| `is_contact(uid)` | 判断id为 `uid` 的账号是否是本帐号的好友,返回 `True` (是)或 `False` (不是) |
| `is_public(uid)` | 判断id为 `uid` 的账号是否是本帐号所关注的公众号,返回 `True` (是)或 `False` (不是) |
Expand Down Expand Up @@ -245,6 +255,18 @@ python test.py
python bot.py
```

## 6 帮助项目
## 6 类似项目

[feit/Weixinbot](https://github.com/feit/Weixinbot) Nodejs 封装网页版微信的接口,可编程控制微信消息

[littlecodersh/ItChat](https://github.com/littlecodersh/ItChat) 微信个人号接口、微信机器人及命令行微信,Command line talks through Wechat

[Urinx/WeixinBot](https://github.com/Urinx/WeixinBot) 网页版微信API,包含终端版微信及微信机器人

[zixia/wechaty](https://github.com/zixia/wechaty) Wechaty is wechat for bot in Javascript(ES6). It's a Personal Account Robot Framework/Library.

## 7 交流讨论

问题可以直接开 **issue**

欢迎对本项目提意见、贡献代码,参考: [如何帮助项目](https://github.com/liuwons/wxBot/wiki/How-to-contribute)
**QQ** 交流群: **429134510**
Empty file added __init__.py
Empty file.
4 changes: 4 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ def tuling_auto_reply(self, uid, msg):
result = respond['text'].replace('<br>', ' ')
elif respond['code'] == 200000:
result = respond['url']
elif respond['code'] == 302000:
for k in respond['list']:
result = result + u"【" + k['source'] + u"】 " +\
k['article'] + "\t" + k['detailurl'] + "\n"
else:
result = respond['text'].replace('<br>', ' ')

Expand Down
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class MyWXBot(WXBot):
def handle_msg_all(self, msg):
if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
self.send_msg_by_uid(u'hi', msg['user']['id'])
#self.send_img_msg_by_uid("img/1.png", msg['user']['id'])
#self.send_file_msg_by_uid("img/1.png", msg['user']['id'])
'''
def schedule(self):
self.send_msg(u'张三', u'测试')
Expand Down
Loading