Giter Club home page Giter Club logo

weixinbot's Introduction

WeixinBot star this repo fork this repo python

网页版微信API,包含终端版微信及微信机器人

Contents

为了确保能正常运行示例脚本,请安装所需的第三方包。

pip install -r requirements.txt

注:下面演示的图片与功能可能不是最新的,具体请看源码。

按照操作指示在手机微信上扫描二维码然后登录,你可以选择是否开启自动回复模式。

2

开启自动回复模式后,如果接收到的是文字消息就会自动回复,包括群消息。

3

名片,链接,动画表情和地址位置消息。

4

5

网页版上有的功能目前基本上都能支持。

       +--------------+     +---------------+   +---------------+
       |              |     |               |   |               |
       |   Get UUID   |     |  Get Contact  |   | Status Notify |
       |              |     |               |   |               |
       +-------+------+     +-------^-------+   +-------^-------+
               |                    |                   |
               |                    +-------+  +--------+
               |                            |  |
       +-------v------+               +-----+--+------+      +--------------+
       |              |               |               |      |              |
       |  Get QRCode  |               |  Weixin Init  +------>  Sync Check  <----+
       |              |               |               |      |              |    |
       +-------+------+               +-------^-------+      +-------+------+    |
               |                              |                      |           |
               |                              |                      +-----------+
               |                              |                      |
       +-------v------+               +-------+--------+     +-------v-------+
       |              | Confirm Login |                |     |               |
+------>    Login     +---------------> New Login Page |     |  Weixin Sync  |
|      |              |               |                |     |               |
|      +------+-------+               +----------------+     +---------------+
|             |
|QRCode Scaned|
+-------------+

登录

API 获取 UUID
url https://login.weixin.qq.com/jslogin
method POST
data URL Encode
params appid: 应用ID
fun: new 应用类型
lang: zh_CN 语言
_: 时间戳

返回数据(String):

window.QRLogin.code = 200; window.QRLogin.uuid = "xxx"

注:这里的appid就是在微信开放平台注册的应用的AppID。网页版微信有两个AppID,早期的是wx782c26e4c19acffb,在微信客户端上显示为应用名称为Web微信;现在用的是wxeb7ec651dd0aefa9,显示名称为微信网页版


API 绑定登陆(webwxpushloginurl)
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxpushloginurl
method GET
params uin: xxx

返回数据(String):

{'msg': 'all ok', 'uuid': 'xxx', 'ret': '0'}

通过这种方式可以省掉扫二维码这步操作,更加方便

API 生成二维码
url https://login.weixin.qq.com/l/ uuid
method GET

API 二维码扫描登录
url https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login
method GET
params tip: 1 未扫描 0 已扫描
uuid: xxx
_: 时间戳

返回数据(String):

window.code=xxx;

xxx:
	408 登陆超时
	201 扫描成功
	200 确认登录

当返回200时,还会有
window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";

API webwxnewloginpage
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage
method GET
params ticket: xxx
uuid: xxx
lang: zh_CN 语言
scan: xxx
fun: new

返回数据(XML):

<error>
	<ret>0</ret>
	<message>OK</message>
	<skey>xxx</skey>
	<wxsid>xxx</wxsid>
	<wxuin>xxx</wxuin>
	<pass_ticket>xxx</pass_ticket>
	<isgrayscale>1</isgrayscale>
</error>

微信初始化

API webwxinit
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?pass_ticket=xxx&skey=xxx&r=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: {
         Uin: xxx,
         Sid: xxx,
         Skey: xxx,
         DeviceID: xxx,
     }
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	"Count": 11,
	"ContactList": [...],
	"SyncKey": {
		"Count": 4,
		"List": [
			{
				"Key": 1,
				"Val": 635705559
			},
			...
		]
	},
	"User": {
		"Uin": xxx,
		"UserName": xxx,
		"NickName": xxx,
		"HeadImgUrl": xxx,
		"RemarkName": "",
		"PYInitial": "",
		"PYQuanPin": "",
		"RemarkPYInitial": "",
		"RemarkPYQuanPin": "",
		"HideInputBarFlag": 0,
		"StarFriend": 0,
		"Sex": 1,
		"Signature": "Apt-get install B",
		"AppAccountFlag": 0,
		"VerifyFlag": 0,
		"ContactFlag": 0,
		"WebWxPluginSwitch": 0,
		"HeadImgFlag": 1,
		"SnsFlag": 17
	},
	"ChatSet": xxx,
	"SKey": xxx,
	"ClientVersion": 369297683,
	"SystemTime": 1453124908,
	"GrayScale": 1,
	"InviteStartCount": 40,
	"MPSubscribeMsgCount": 2,
	"MPSubscribeMsgList": [...],
	"ClickReportInterval": 600000
}

API webwxstatusnotify
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?lang=zh_CN&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Code: 3,
     FromUserName: 自己ID,
     ToUserName: 自己ID,
     ClientMsgId: 时间戳
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	...
}

获取联系人信息

API webwxgetcontact
url https://wx.qq.com/cgi-bin/mmwebwx-bin//webwxgetcontact?pass_ticket=xxx&skey=xxx&r=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	"MemberCount": 334,
	"MemberList": [
		{
			"Uin": 0,
			"UserName": xxx,
			"NickName": "Urinx",
			"HeadImgUrl": xxx,
			"ContactFlag": 3,
			"MemberCount": 0,
			"MemberList": [],
			"RemarkName": "",
			"HideInputBarFlag": 0,
			"Sex": 0,
			"Signature": "你好,我们是地球三体组织。在这里,你将感受到不一样的思维模式,以及颠覆常规的世界观。而我们的目标,就是以三体人的智慧,引领人类未来科学技术500年。",
			"VerifyFlag": 8,
			"OwnerUin": 0,
			"PYInitial": "URINX",
			"PYQuanPin": "Urinx",
			"RemarkPYInitial": "",
			"RemarkPYQuanPin": "",
			"StarFriend": 0,
			"AppAccountFlag": 0,
			"Statues": 0,
			"AttrStatus": 0,
			"Province": "",
			"City": "",
			"Alias": "Urinxs",
			"SnsFlag": 0,
			"UniFriend": 0,
			"DisplayName": "",
			"ChatRoomId": 0,
			"KeyWord": "gh_",
			"EncryChatRoomId": ""
		},
		...
	],
	"Seq": 0
}

API webwxbatchgetcontact
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r=xxx&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Count: 群数量,
     List: [
         { UserName: 群ID, EncryChatRoomId: "" },
         ...
     ],
}

返回数据(JSON)同上

同步刷新

API synccheck
protocol https
host webpush.weixin.qq.com
webpush.wx2.qq.com
webpush.wx8.qq.com
webpush.wx.qq.com
webpush.web2.wechat.com
webpush.web.wechat.com
path /cgi-bin/mmwebwx-bin/synccheck
method GET
data URL Encode
params r: 时间戳
sid: xxx
uin: xxx
skey: xxx
deviceid: xxx
synckey: xxx
_: 时间戳

返回数据(String):

window.synccheck={retcode:"xxx",selector:"xxx"}

retcode:
	0 正常
	1100 失败/登出微信
selector:
	0 正常
	2 新的消息
	7 进入/离开聊天界面

API webwxsync
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=xxx&skey=xxx&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     SyncKey: xxx,
     rr: 时间戳取反
}

返回数据(JSON):

{
	'BaseResponse': {'ErrMsg': '', 'Ret': 0},
	'SyncKey': {
		'Count': 7,
		'List': [
			{'Val': 636214192, 'Key': 1},
			...
		]
	},
	'ContinueFlag': 0,
	'AddMsgCount': 1,
	'AddMsgList': [
		{
			'FromUserName': '',
			'PlayLength': 0,
			'RecommendInfo': {...},
			'Content': "", 
			'StatusNotifyUserName': '',
			'StatusNotifyCode': 5,
			'Status': 3,
			'VoiceLength': 0,
			'ToUserName': '',
			'ForwardFlag': 0,
			'AppMsgType': 0,
			'AppInfo': {'Type': 0, 'AppID': ''},
			'Url': '',
			'ImgStatus': 1,
			'MsgType': 51,
			'ImgHeight': 0,
			'MediaId': '', 
			'FileName': '',
			'FileSize': '',
			...
		},
		...
	],
	'ModChatRoomMemberCount': 0,
	'ModContactList': [],
	'DelContactList': [],
	'ModChatRoomMemberList': [],
	'DelContactCount': 0,
	...
}

消息接口

API webwxsendmsg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Msg: {
         Type: 1 文字消息,
         Content: 要发送的消息,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	},
	...
}
API webwxrevokemsg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxrevokemsg
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     SvrMsgId: msg_id,
     ToUserName: user_id,
     ClientMsgId: local_msg_id
}

返回数据(JSON):

{
	"BaseResponse": {
		"Ret": 0,
		"ErrMsg": ""
	}
}

发送表情

API webwxsendmsgemotion
url https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendemoticon?fun=sys&f=json&pass_ticket=xxx
method POST
data JSON
header ContentType: application/json; charset=UTF-8
params {
     BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
     Msg: {
         Type: 47 emoji消息,
         EmojiFlag: 2,
         MediaId: 表情上传后的媒体ID,
         FromUserName: 自己ID,
         ToUserName: 好友ID,
         LocalID: 与clientMsgId相同,
         ClientMsgId: 时间戳左移4位随后补上4位随机数
     }
}

图片接口

API webwxgeticon
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgeticon
method GET
params seq: 数字,可为空
username: ID
skey: xxx

API webwxgetheadimg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetheadimg
method GET
params seq: 数字,可为空
username: 群ID
skey: xxx

API webwxgetmsgimg
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmsgimg
method GET
params MsgID: 消息ID
type: slave 略缩图 or 为空时加载原图
skey: xxx

多媒体接口

API webwxgetvideo
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvideo
method GET
params msgid: 消息ID
skey: xxx

API webwxgetvoice
url https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetvoice
method GET
params msgid: 消息ID
skey: xxx

账号类型

类型 说明
个人账号 @开头,例如:@xxx
群聊 @@开头,例如:@@xxx
公众号/服务号 @开头,但其VerifyFlag & 8 != 0

VerifyFlag:
         一般个人公众号/服务号:8
         一般企业的服务号:24
         微信官方账号微信团队:56
特殊账号 像文件传输助手之类的账号,有特殊的ID,目前已知的有:
filehelper, newsapp, fmessage, weibo, qqmail, tmessage, qmessage, qqsync, floatbottle, lbsapp, shakeapp, medianote, qqfriend, readerapp, blogapp, facebookapp, masssendapp, meishiapp, feedsapp, voip, blogappweixin, weixin, brandsessionholder, weixinreminder, officialaccounts, notification_messages, wxitil, userexperience_alarm, notification_messages

消息类型

消息一般格式:

{
	"FromUserName": "",
	"ToUserName": "",
	"Content": "",
	"StatusNotifyUserName": "",
	"ImgWidth": 0,
	"PlayLength": 0,
	"RecommendInfo": {...},
	"StatusNotifyCode": 4,
	"NewMsgId": "",
	"Status": 3,
	"VoiceLength": 0,
	"ForwardFlag": 0,
	"AppMsgType": 0,
	"Ticket": "",
	"AppInfo": {...},
	"Url": "",
	"ImgStatus": 1,
	"MsgType": 1,
	"ImgHeight": 0,
	"MediaId": "",
	"MsgId": "",
	"FileName": "",
	"HasProductId": 0,
	"FileSize": "",
	"CreateTime": 1454602196,
	"SubMsgType": 0
}

MsgType 说明
1 文本消息
3 图片消息
34 语音消息
37 好友确认消息
40 POSSIBLEFRIEND_MSG
42 共享名片
43 视频消息
47 动画表情
48 位置消息
49 分享链接
50 VOIPMSG
51 微信初始化消息
52 VOIPNOTIFY
53 VOIPINVITE
62 小视频
9999 SYSNOTICE
10000 系统消息
10002 撤回消息

微信初始化消息

MsgType: 51
FromUserName: 自己ID
ToUserName: 自己ID
StatusNotifyUserName: 最近联系的联系人ID
Content:
	<msg>
	    <op id='4'>
	        <username>
	        	// 最近联系的联系人
	            filehelper,xxx@chatroom,wxid_xxx,xxx,...
	        </username>
	        <unreadchatlist>
	            <chat>
	                <username>
	                	// 朋友圈
	                    MomentsUnreadMsgStatus
	                </username>
	                <lastreadtime>
	                    1454502365
	                </lastreadtime>
	            </chat>
	        </unreadchatlist>
	        <unreadfunctionlist>
	        	// 未读的功能账号消息,群发助手,漂流瓶等
	        </unreadfunctionlist>
	    </op>
	</msg>

文本消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: 消息内容

图片消息

MsgType: 3
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取图片
Content:
	<msg>
		<img length="6503" hdlength="0" />
		<commenturl></commenturl>
	</msg>

小视频消息

MsgType: 62
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取小视频
Content:
	<msg>
		<img length="6503" hdlength="0" />
		<commenturl></commenturl>
	</msg>

地理位置消息

MsgType: 1
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: http://weixin.qq.com/cgi-bin/redirectforward?args=xxx
// 属于文本消息,只不过内容是一个跳转到地图的链接

名片消息

MsgType: 42
FromUserName: 发送方ID
ToUserName: 接收方ID
Content:
	<?xml version="1.0"?>
	<msg bigheadimgurl="" smallheadimgurl="" username="" nickname=""  shortpy="" alias="" imagestatus="3" scene="17" province="" city="" sign="" sex="1" certflag="0" certinfo="" brandIconUrl="" brandHomeUrl="" brandSubscriptConfigUrl="" brandFlags="0" regionCode="" />

RecommendInfo:
	{
		"UserName": "xxx", // ID
		"Province": "xxx", 
		"City": "xxx", 
		"Scene": 17, 
		"QQNum": 0, 
		"Content": "", 
		"Alias": "xxx", // 微信号
		"OpCode": 0, 
		"Signature": "", 
		"Ticket": "", 
		"Sex": 0, // 1:男, 2:女
		"NickName": "xxx", // 昵称
		"AttrStatus": 4293221, 
		"VerifyFlag": 0
	}

语音消息

MsgType: 34
FromUserName: 发送方ID
ToUserName: 接收方ID
MsgId: 用于获取语音
Content:
	<msg>
		<voicemsg endflag="1" cancelflag="0" forwardflag="0" voiceformat="4" voicelength="1580" length="2026" bufid="216825389722501519" clientmsgid="49efec63a9774a65a932a4e5fcd4e923filehelper174_1454602489" fromusername="" />
	</msg>

动画表情

MsgType: 47
FromUserName: 发送方ID
ToUserName: 接收方ID
Content:
	<msg>
		<emoji fromusername = "" tousername = "" type="2" idbuffer="media:0_0" md5="e68363487d8f0519c4e1047de403b2e7" len = "86235" productid="com.tencent.xin.emoticon.bilibili" androidmd5="e68363487d8f0519c4e1047de403b2e7" androidlen="86235" s60v3md5 = "e68363487d8f0519c4e1047de403b2e7" s60v3len="86235" s60v5md5 = "e68363487d8f0519c4e1047de403b2e7" s60v5len="86235" cdnurl = "http://emoji.qpic.cn/wx_emoji/eFygWtxcoMF8M0oCCsksMA0gplXAFQNpiaqsmOicbXl1OC4Tyx18SGsQ/" designerid = "" thumburl = "http://mmbiz.qpic.cn/mmemoticon/dx4Y70y9XctRJf6tKsy7FwWosxd4DAtItSfhKS0Czr56A70p8U5O8g/0" encrypturl = "http://emoji.qpic.cn/wx_emoji/UyYVK8GMlq5VnJ56a4GkKHAiaC266Y0me0KtW6JN2FAZcXiaFKccRevA/" aeskey= "a911cc2ec96ddb781b5ca85d24143642" ></emoji> 
		<gameext type="0" content="0" ></gameext>
	</msg>

普通链接或应用分享消息

MsgType: 49
AppMsgType: 5
FromUserName: 发送方ID
ToUserName: 接收方ID
Url: 链接地址
FileName: 链接标题
Content:
	<msg>
		<appmsg appid=""  sdkver="0">
			<title></title>
			<des></des>
			<type>5</type>
			<content></content>
			<url></url>
			<thumburl></thumburl>
			...
		</appmsg>
		<appinfo>
			<version></version>
			<appname></appname>
		</appinfo>
	</msg>

音乐链接消息

MsgType: 49
AppMsgType: 3
FromUserName: 发送方ID
ToUserName: 接收方ID
Url: 链接地址
FileName: 音乐名

AppInfo: // 分享链接的应用
	{
		Type: 0, 
		AppID: wx485a97c844086dc9
	}

Content:
	<msg>
		<appmsg appid="wx485a97c844086dc9"  sdkver="0">
			<title></title>
			<des></des>
			<action></action>
			<type>3</type>
			<showtype>0</showtype>
			<mediatagname></mediatagname>
			<messageext></messageext>
			<messageaction></messageaction>
			<content></content>
			<contentattr>0</contentattr>
			<url></url>
			<lowurl></lowurl>
			<dataurl>
				http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&amp;guid=ffffffffc104ea2964a111cf3ff3edaf&amp;fromtag=46
			</dataurl>
			<lowdataurl>
				http://ws.stream.qqmusic.qq.com/C100003i9hMt1bgui0.m4a?vkey=6867EF99F3684&amp;guid=ffffffffc104ea2964a111cf3ff3edaf&amp;fromtag=46
			</lowdataurl>
			<appattach>
				<totallen>0</totallen>
				<attachid></attachid>
				<emoticonmd5></emoticonmd5>
				<fileext></fileext>
			</appattach>
			<extinfo></extinfo>
			<sourceusername></sourceusername>
			<sourcedisplayname></sourcedisplayname>
			<commenturl></commenturl>
			<thumburl>
				http://imgcache.qq.com/music/photo/album/63/180_albumpic_143163_0.jpg
			</thumburl>
			<md5></md5>
		</appmsg>
		<fromusername></fromusername>
		<scene>0</scene>
		<appinfo>
			<version>29</version>
			<appname>摇一摇搜歌</appname>
		</appinfo>
		<commenturl></commenturl>
	</msg>

群消息

MsgType: 1
FromUserName: @@xxx
ToUserName: @xxx
Content:
	@xxx:<br/>xxx

红包消息

MsgType: 49
AppMsgType: 2001
FromUserName: 发送方ID
ToUserName: 接收方ID
Content: 未知

注:根据网页版的代码可以看到未来可能支持查看红包消息,但目前走的是系统消息,见下。

系统消息

MsgType: 10000
FromUserName: 发送方ID
ToUserName: 自己ID
Content:
	"你已添加了 xxx ,现在可以开始聊天了。"
	"如果陌生人主动添加你为朋友,请谨慎核实对方身份。"
	"收到红包,请在手机上查看"

如果你希望和 WeixinBot 的其他开发者交流,或者有什么问题和建议,欢迎大家加入微信群【Youth fed the dog】一起讨论。扫描下面的二维码添加机器人为好友,并回复【Aidog】获取入群链接。

join us

注:这个不是群的二维码,是机器人拉你入群,记得回复机器人【Aidog】哦~ (secret code: Aidog)

  • association_login 目前网页版微信已经可以脱离扫码,但是依然需要在客户端进行确认登录。

weixinbot's People

Contributors

1398491991 avatar airimos avatar billbillbillbill avatar bitq2019 avatar chentest2013 avatar cxgreat2014 avatar flyingtimeice avatar fmnisme avatar haskely avatar jseagull avatar lbbniu avatar lijiarui avatar liushuchun avatar mtunique avatar samueldeng avatar sanmuhe avatar sbilly avatar sharpdeep avatar tonghuaroot avatar urinx avatar yaphone avatar zhoubofsy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

weixinbot's Issues

主动给群聊发消息我已搞定

业余爱好者,读了大神的代码,将就着把代码加了进去

def getGroupID(self, name):
    id = '@@000'
    for member in self.GroupList:
        if member['NickName'] == name:
            id = member['UserName']
    if id == '@@000':
        # 现有群里面查不到
        GroupList = self.getNameById(id)
        for group in GroupList:
            self.GroupList.append(group)
            if group['NickName'] == name:
                id = group['UserName']
                MemberList = group['MemberList']
                for member in MemberList:
                    self.GroupMemeberList.append(member)
    return id

在start的while True里面加上:
elif text[:3] == 'g->':
[name, word] = text[3:].split(':')
id = self.getGroupID(name)
self.webwxsendmsg(word, id)

就可以用 "g->[群名字]:[内容]" 来发消息给群了

一个奇怪的提示

[] 收到疑似红包消息 152 次
[
] 收到疑似红包消息 153 次
[] 收到疑似红包消息 154 次
[
] 收到疑似红包消息 155 次
[] 收到疑似红包消息 156 次
[
] 收到疑似红包消息 157 次
[] 收到疑似红包消息 158 次
[
] 收到疑似红包消息 159 次
[] 收到疑似红包消息 160 次
[
] 收到疑似红包消息 161 次
[] 收到疑似红包消息 162 次
[
] 收到疑似红包消息 163 次
[] 收到疑似红包消息 164 次
[
] 收到疑似红包消息 165 次
[] 收到疑似红包消息 166 次
[
] 收到疑似红包消息 167 次
[] 收到疑似红包消息 168 次
[
] 收到疑似红包消息 169 次
[] 收到疑似红包消息 170 次
[
] 收到疑似红包消息 171 次
[] 收到疑似红包消息 172 次
[
] 收到疑似红包消息 173 次
[] 收到疑似红包消息 174 次
[
] 收到疑似红包消息 175 次
[*] 收到疑似红包消息 176 次
……………………一直刷
某次登录后一直刷这个消息,强制结束进程后,重新登陆正常了,这个提示没有了

关于图片上传问题

我是wxBot的使用者,目前状况是无法发送图片,表情等,好像是都不执行文件上传,您如果不忙的话可以看看这个问题,谢谢,小弟刚接触py,大神可以建一个群共同研究下

请问windows能跑吗?

我在windows下,用pip install requests,中途就失败了,

adthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading requests-2.10.0-py2.py3-none-any.whl (506kB) 8% |██▋ | 40kB 6.1kB/s eta 0:01:17Exception: Traceback (most recent call last): File "c:\python\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\python\lib\site-packages\pip\commands\install.py", line 310, in run wb.build(autobuilding=True) File "c:\python\lib\site-packages\pip\wheel.py", line 750, in build self.requirement_set.prepare_files(self.finder) File "c:\python\lib\site-packages\pip\req\req_set.py", line 370, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "c:\python\lib\site-packages\pip\req\req_set.py", line 587, in _prepare_file session=self.session, hashes=hashes) File "c:\python\lib\site-packages\pip\download.py", line 810, in unpack_url hashes=hashes File "c:\python\lib\site-packages\pip\download.py", line 649, in unpack_http_url hashes) File "c:\python\lib\site-packages\pip\download.py", line 871, in _download_http_url _download_url(resp, link, content_file, hashes) File "c:\python\lib\site-packages\pip\download.py", line 595, in _download_url hashes.check_against_chunks(downloaded_chunks) File "c:\python\lib\site-packages\pip\utils\hashes.py", line 46, in check_against_chunks for chunk in chunks:

请问如果要实现去掉session的红点功能,该怎么做呢?

如您所知,有些群不想看又太方便退,即使不提醒,留一堆红点儿在那儿也很麻烦的。
微信PC客户端点击一点的话,手机端的红点也会同步消失。
但我找了一下咱们库上应该没有实现这个,不知道有没有办法捏?
谢谢!

关于图片上传media_id返回一直空问题

你好,在网上看到你的作品后非常膜拜,我刚接受的新任务和你写的类似要求用python实现发送微信图片,但是苦于抓瞎,看了你的代码一顿研究,我菜鸟一个,如果你能看到这里,请帮助下,目前WeiXinBot中发送文件 图片总失败,media_id返回一直空,这对我工作造成很大困扰,我自己重新做困难重重,求大腿希望您从白忙之中抽出空修改下,建个群我们可以共同研究。

scripts stoped serval times while message response failed

Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "weixin.py", line 785, in listenMsgMode
self.handleMsg(r)
File "weixin.py", line 687, in handleMsg
if self.webwxsendmsg(ans, msg['FromUserName']):
File "weixin.py", line 390, in webwxsendmsg
r = requests.post(url, data=data, headers=headers)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 109, in post
return request('post', url, data=data, json=json, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, *_send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, *_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 415, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))

# about line 67x
                    while True:
                        try:
                            self.webwxsendmsg(ans, msg['FromUserName'])
                            print '自动回复: ' + ans
                            logging.info('自动回复: ' + ans)
                            break
                        except Exception:
                            logging.info('自动回复失败')
                            time.sleep(2)

I thought this is not valid way to slove it,but should try third times at least.

msgType为43时候可能为小视频。

发小视频的时候msgType为43,然后不能保存。我把43和62放一起来保存小视频,但另一个问题是会保存撤回消息,把10002那条处理语句放在62和43就可以了。

43还有可能是什么消息?目前运行来看没遇到其他类型消息。

网不太好时候,urllib2.urlopen会报错并终止

可能是网络的原因,urllib2.urlopen有时候会报错并终止程序,得重启程序比较麻烦,建议在urllib2.urlopen(request)的时候加个异常处理:

while(True):
            try:
                response = urllib2.urlopen(request)
                break
            except Exception, e:
                time.sleep(10)

syncCheck总是1100

retcode: 1100, selector: 0

是只有我有这个问题么,还是api有变。我再研究研究。

遇到了问题pickle.PicklingError: Can't pickle <type 'thread.lock'>: it's not found as thread.lock

我遇到了这个问题

D:\pythoncode\WeixinBot-master>python weixin.py
[] 微信网页版 ... 开动
�[32m2016-04-26 18:37:55�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[
] 寰俊缃戦
〉鐗?... 寮€鍔?[0m
[] 正在获取 uuid ... 成功
�[32m2016-04-26 18:37:56�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[
] 姝e湪鑾峰
彇 uuid ... ... 鎴愬姛�[0m
[] 正在获取二维码 ... 成功
�[32m2016-04-26 18:37:56�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[
] 寰俊缃戦
〉鐗?... 寮€鍔?[0m
�[32m2016-04-26 18:37:56�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32mSaved file: D:
\pythoncode\WeixinBot-master\saved\qrcodes\qrcode.jpg�[0m
[] 请使用微信扫描二维码以登录 ...
�[32m2016-04-26 18:38:19�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32mhttps://login.
weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=1&uuid=gZk_oobn_A==&
=1461667077�[0m
�[32m2016-04-26 18:38:24�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32mhttps://login.
weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=0&uuid=gZk_oobn_A==&=1461667099�[0m
[
] 正在登录 ... �[32m2016-04-26 18:38:24�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[
32mhttps://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AQaDOYZ8rqoj9G5rbLvDeDKr@qrticket_0
&uuid=gZk_oobn_A==&lang=zh_CN&scan=1461667105&fun=new�[0m
成功
�[32m2016-04-26 18:38:24�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[] 姝e湪鐧诲
綍 ... ... 鎴愬姛�[0m
[
] 微信初始化 ... 成功
�[32m2016-04-26 18:38:25�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[] 寰俊鍒濆
鍖?... ... 鎴愬姛�[0m
[
] 开启状态通知 ... 成功
�[32m2016-04-26 18:38:25�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[] 寮€鍚姸
鎬侀€氱煡 ... ... 鎴愬姛�[0m
[
] 获取联系人 ... https://wx.qq.com/cgi-bin/mmwebwx-bin
成功
�[32m2016-04-26 18:38:27�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[] 鑾峰彇鑱旂
郴浜?... ... 鎴愬姛�[0m
[
] 应有 415 个联系人,读取到联系人 415 个
[] 共有 6 个群 | 171 个直接联系人 | 0 个特殊账号 | 237 公众号或服务号
[
] 获取群 ... 成功
�[32m2016-04-26 18:38:27�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[] 鑾峰彇缇?.
.. ... 鎴愬姛�[0m
�[32m2016-04-26 18:38:27�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[
] 寰俊缃戦
〉鐗?... 寮€鍔?[0m

�[32m2016-04-26 18:38:27�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m==============

[#] Web Weixin
[#] Debug Mode: False
[#] Uuid: gZk_oobn_A==
[#] Uin: 1583421542
[#] Sid: VbGA+vSkmv+FM+dR
[#] Skey: @crypt_927e477f_ef7c0a891a77b236dc3c5b8f7c8450f1
[#] DeviceId: e834504991840841
[#] PassTicket: WbDwR0GtAYVoQNH15Ue14oBsClOPSeGCG09xtzTzp85IdW76er5OyegSP9gtbLpI
=========================�[0m
[] 自动回复模式 ... 关闭
�[32m2016-04-26 18:38:27�[0m �[35mGunshoot�[0m �[34mroot[3628]�[0m �[30mDEBUG�[0m �[32m[
] 鑷姩鍥炲
妯″紡 ... 鍏抽棴�[0m
Traceback (most recent call last):
File "weixin.py", line 1046, in
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\multiprocessing\forking.py", line 347, in main
wself = load(from_parent)
ebwx.start()
File "C:\Python27\lib\pickle.py", line 1378, in load
File "weixin.py", line 30, in wrapper
return fn(*args)
File "weixin.py", line 887, in start
return Unpickler(file).load()
File "C:\Python27\lib\pickle.py", line 858, in load
listenProcess.start()
File "C:\Python27\lib\multiprocessing\process.py", line 104, in start
dispatchkey
s File "C:\Python27\lib\pickle.py", line 880, in load_eof
elf._popen = Popen(self)
File "C:\Python27\lib\multiprocessing\forking.py", line 244, in init
dump(process_obj, to_child, HIGHEST_PROTOCOL)
raise EOFError
File "C:\Python27\lib\multiprocessing\forking.py", line 167, in dump
EOFError
ForkingPickler(file, protocol).dump(obj)
File "C:\Python27\lib\pickle.py", line 224, in dump
self.save(obj)
File "C:\Python27\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\multiprocessing\forking.py", line 40, in dispatcher
self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 401, in save_reduce
save(args)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 548, in save_tuple
save(element)
File "C:\Python27\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 725, in save_inst
save(stuff)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\lib\pickle.py", line 396, in save_reduce
save(cls)
File "C:\Python27\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\lib\pickle.py", line 748, in save_global
(obj, module, name))
pickle.PicklingError: Can't pickle <type 'thread.lock'>: it's not found as thread.lock

请问webwxstatusnotify或synccheck返回1101怎么解决呢?

运行问题

点击weixin.py,一闪而过,装好了qrcode以后,也是一样的

消息为群组消息时的问题

line 261:

elif msg['ToUserName'][:2] == '@@':
    [people, content] = content.split(':<br/>')
    print '|'+name+'| '+people+':\n'+content.replace('<br/>','\n')

这里应该是FromUserName吧。来自群组的消息,content是'id':<br/>'content'的格式。不知道ToUserName为群组的情况是啥样的。

装不了qrcode,,,

报错

Could not find a version that satisfies the requirement qrcode (from versions: )
No matching distribution found for qrcode

todo

不知道接下来要写哪些地方呢?建议把要改进的列个todo list,大家可以一起贡献代码

———— 20160614 ————
by sbilly: 用下管理权,close 封贴。以后发帖同学还请每个需求单独开贴。

发生图片后一直报retcode: 0, selector: 2

正常情况下,retcode: 0, selector: 2 一般是表示当前还有新的消息没有同步。而再执行一次synccheck,就可以变成 retcode: 0, selector: 0

很可惜在使用我们的发送图片功能后,系统会一直返回retcode: 0, selector: 2,从而会一直去synccheck,这种动作很可能被腾讯来黑,导致微信部分功能不能用,如建多人群。

这种状态一直要等到真的有人给这个系统发一个消息,系统再synccheck一次后才能回复正常(retcode: 0, selector: 0)

麻烦作者尽快处理掉这个bug,减少被腾讯拉黑的概率

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.