Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BillLi
ItChat
提交
5add6dbb
I
ItChat
项目概览
BillLi
/
ItChat
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
ItChat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5add6dbb
编写于
12月 15, 2016
作者:
L
LittleCoder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new params of sending messages
上级
85044108
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
28 deletion
+31
-28
itchat/components/messages.py
itchat/components/messages.py
+30
-27
itchat/config.py
itchat/config.py
+1
-1
未找到文件。
itchat/components/messages.py
浏览文件 @
5add6dbb
...
...
@@ -74,7 +74,7 @@ def produce_msg(core, msgList):
'%s/webwxgetvoice'
%
core
.
loginInfo
[
'url'
],
m
[
'NewMsgId'
])
msg
=
{
'Type'
:
'Recording'
,
'FileName'
:
'%s.mp
4
'
%
time
.
strftime
(
'%y%m%d-%H%M%S'
,
time
.
localtime
()),
'FileName'
:
'%s.mp
3
'
%
time
.
strftime
(
'%y%m%d-%H%M%S'
,
time
.
localtime
()),
'Text'
:
download_fn
,}
elif
m
[
'MsgType'
]
==
37
:
# friends
msg
=
{
...
...
@@ -88,6 +88,27 @@ def produce_msg(core, msgList):
msg
=
{
'Type'
:
'Card'
,
'Text'
:
m
[
'RecommendInfo'
],
}
elif
m
[
'MsgType'
]
in
(
43
,
62
):
# tiny video
msgId
=
m
[
'MsgId'
]
def
download_video
(
videoDir
=
None
):
url
=
'%s/webwxgetvideo'
%
core
.
loginInfo
[
'url'
]
params
=
{
'msgid'
:
msgId
,
'skey'
:
core
.
loginInfo
[
'skey'
],}
headers
=
{
'Range'
:
'bytes=0-'
,
'User-Agent'
:
config
.
USER_AGENT
}
r
=
core
.
s
.
get
(
url
,
params
=
params
,
headers
=
headers
,
stream
=
True
)
tempStorage
=
io
.
BytesIO
()
for
block
in
r
.
iter_content
(
1024
):
tempStorage
.
write
(
block
)
if
videoDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
videoDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'Successfully downloaded'
,
'Ret'
:
0
,
}})
msg
=
{
'Type'
:
'Video'
,
'FileName'
:
'%s.mp4'
%
time
.
strftime
(
'%y%m%d-%H%M%S'
,
time
.
localtime
()),
'Text'
:
download_video
,
}
elif
m
[
'MsgType'
]
==
49
:
# sharing
if
m
[
'AppMsgType'
]
==
6
:
rawMsg
=
m
...
...
@@ -142,27 +163,6 @@ def produce_msg(core, msgList):
'Text'
:
m
[
'FileName'
],
}
elif
m
[
'MsgType'
]
==
51
:
# phone init
msg
=
update_local_uin
(
core
,
m
)
elif
m
[
'MsgType'
]
==
62
:
# tiny video
msgId
=
m
[
'MsgId'
]
def
download_video
(
videoDir
=
None
):
url
=
'%s/webwxgetvideo'
%
core
.
loginInfo
[
'url'
]
params
=
{
'msgid'
:
msgId
,
'skey'
:
core
.
loginInfo
[
'skey'
],}
headers
=
{
'Range'
:
'bytes=0-'
,
'User-Agent'
:
config
.
USER_AGENT
}
r
=
core
.
s
.
get
(
url
,
params
=
params
,
headers
=
headers
,
stream
=
True
)
tempStorage
=
io
.
BytesIO
()
for
block
in
r
.
iter_content
(
1024
):
tempStorage
.
write
(
block
)
if
videoDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
videoDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'Successfully downloaded'
,
'Ret'
:
0
,
}})
msg
=
{
'Type'
:
'Video'
,
'FileName'
:
'%s.mp4'
%
time
.
strftime
(
'%y%m%d-%H%M%S'
,
time
.
localtime
()),
'Text'
:
download_video
,
}
elif
m
[
'MsgType'
]
==
10000
:
msg
=
{
'Type'
:
'Note'
,
...
...
@@ -214,7 +214,7 @@ def produce_group_chat(core, msg):
def
send_raw_msg
(
self
,
msgType
,
content
,
toUserName
):
url
=
'%s/webwxsendmsg'
%
self
.
loginInfo
[
'url'
]
payloads
=
{
data
=
{
'BaseRequest'
:
self
.
loginInfo
[
'BaseRequest'
],
'Msg'
:
{
'Type'
:
msgType
,
...
...
@@ -223,11 +223,12 @@ def send_raw_msg(self, msgType, content, toUserName):
'ToUserName'
:
(
toUserName
if
toUserName
else
self
.
storageClass
.
userName
),
'LocalID'
:
self
.
loginInfo
[
'msgid'
],
'ClientMsgId'
:
self
.
loginInfo
[
'msgid'
],
},
}
},
'Scene'
:
0
,
}
self
.
loginInfo
[
'msgid'
]
+=
1
headers
=
{
'ContentType'
:
'application/json; charset=UTF-8'
,
'User-Agent'
:
config
.
USER_AGENT
}
r
=
self
.
s
.
post
(
url
,
headers
=
headers
,
data
=
json
.
dumps
(
payloads
,
ensure_ascii
=
False
).
encode
(
'utf8'
))
data
=
json
.
dumps
(
data
,
ensure_ascii
=
False
).
encode
(
'utf8'
))
return
ReturnValue
(
rawResponse
=
r
)
def
send_msg
(
self
,
msg
=
'Test Message'
,
toUserName
=
None
):
...
...
@@ -311,7 +312,8 @@ def send_file(self, fileDir, toUserName=None, mediaId=None):
'FromUserName'
:
self
.
storageClass
.
userName
,
'ToUserName'
:
toUserName
,
'LocalID'
:
self
.
loginInfo
[
'msgid'
],
'ClientMsgId'
:
self
.
loginInfo
[
'msgid'
],
},
}
'ClientMsgId'
:
self
.
loginInfo
[
'msgid'
],
},
'Scene'
:
0
,
}
self
.
loginInfo
[
'msgid'
]
+=
1
headers
=
{
'User-Agent'
:
config
.
USER_AGENT
,
...
...
@@ -339,7 +341,8 @@ def send_image(self, fileDir, toUserName=None, mediaId=None):
'FromUserName'
:
self
.
storageClass
.
userName
,
'ToUserName'
:
toUserName
,
'LocalID'
:
self
.
loginInfo
[
'msgid'
],
'ClientMsgId'
:
self
.
loginInfo
[
'msgid'
],
},
}
'ClientMsgId'
:
self
.
loginInfo
[
'msgid'
],
},
'Scene'
:
0
,
}
self
.
loginInfo
[
'msgid'
]
+=
1
if
fileDir
[
-
4
:]
==
'.gif'
:
url
=
'%s/webwxsendemoticon?fun=sys'
%
self
.
loginInfo
[
'url'
]
...
...
itchat/config.py
浏览文件 @
5add6dbb
import
os
,
platform
VERSION
=
'1.2.1
2
'
VERSION
=
'1.2.1
3
'
BASE_URL
=
'https://login.weixin.qq.com'
OS
=
platform
.
system
()
#Windows, Linux, Darwin
DIR
=
os
.
getcwd
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录