Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BillLi
ItChat
提交
89f219c3
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 搜索 >>
提交
89f219c3
编写于
3月 17, 2017
作者:
L
LittleCoder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix image storage enhancement [ER#160: 6bigfire]
上级
dd47af06
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
11 deletion
+34
-11
itchat/components/contact.py
itchat/components/contact.py
+5
-2
itchat/components/messages.py
itchat/components/messages.py
+17
-8
itchat/utils.py
itchat/utils.py
+12
-1
未找到文件。
itchat/components/contact.py
浏览文件 @
89f219c3
...
...
@@ -413,10 +413,13 @@ def get_head_img(self, userName=None, chatroomUserName=None, picDir=None):
tempStorage
.
write
(
block
)
if
picDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
picDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
with
open
(
picDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
tempStorage
.
seek
(
0
)
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'Successfully downloaded'
,
'Ret'
:
0
,
}})
'Ret'
:
0
,
},
'PostFix'
:
utils
.
get_image_postfix
(
tempStorage
.
read
(
20
)),
})
def
create_chatroom
(
self
,
memberList
,
topic
=
''
):
url
=
'%s/webwxcreatechatroom?pass_ticket=%s&r=%s'
%
(
...
...
itchat/components/messages.py
浏览文件 @
89f219c3
...
...
@@ -31,11 +31,15 @@ def get_download_fn(core, url, msgId):
tempStorage
=
io
.
BytesIO
()
for
block
in
r
.
iter_content
(
1024
):
tempStorage
.
write
(
block
)
if
downloadDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
downloadDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
if
downloadDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
downloadDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
tempStorage
.
seek
(
0
)
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'Successfully downloaded'
,
'Ret'
:
0
,
}})
'Ret'
:
0
,
},
'PostFix'
:
utils
.
get_image_postfix
(
tempStorage
.
read
(
20
)),
})
return
download_fn
def
produce_msg
(
core
,
msgList
):
...
...
@@ -101,8 +105,10 @@ def produce_msg(core, msgList):
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
())
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
,
}})
...
...
@@ -128,8 +134,10 @@ def produce_msg(core, msgList):
tempStorage
=
io
.
BytesIO
()
for
block
in
r
.
iter_content
(
1024
):
tempStorage
.
write
(
block
)
if
attaDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
attaDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
if
attaDir
is
None
:
return
tempStorage
.
getvalue
()
with
open
(
attaDir
,
'wb'
)
as
f
:
f
.
write
(
tempStorage
.
getvalue
())
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'Successfully downloaded'
,
'Ret'
:
0
,
}})
...
...
@@ -255,7 +263,8 @@ def upload_file(self, fileDir, isPicture=False, isVideo=False,
'Ret'
:
-
1002
,
}})
fileSize
=
os
.
path
.
getsize
(
fileDir
)
fileSymbol
=
'pic'
if
isPicture
else
'video'
if
isVideo
else
'doc'
with
open
(
fileDir
,
'rb'
)
as
f
:
fileMd5
=
hashlib
.
md5
(
f
.
read
()).
hexdigest
()
with
open
(
fileDir
,
'rb'
)
as
f
:
fileMd5
=
hashlib
.
md5
(
f
.
read
()).
hexdigest
()
file_
=
open
(
fileDir
,
'rb'
)
chunks
=
int
((
fileSize
-
1
)
/
524288
)
+
1
clientMediaId
=
int
(
time
.
time
()
*
1e4
)
...
...
itchat/utils.py
浏览文件 @
89f219c3
...
...
@@ -70,7 +70,8 @@ def msg_formatter(d, k):
def
check_file
(
fileDir
):
try
:
with
open
(
fileDir
):
pass
with
open
(
fileDir
):
pass
return
True
except
:
return
False
...
...
@@ -130,3 +131,13 @@ def test_connect(retryTime=5):
def
contact_deep_copy
(
core
,
contact
):
with
core
.
storageClass
.
updateLock
:
return
copy
.
deepcopy
(
contact
)
def
get_image_postfix
(
data
):
data
=
data
[:
20
]
if
'GIF'
in
data
:
return
'gif'
elif
'PNG'
in
data
:
return
'png'
elif
'JFIF'
in
data
:
return
'jpg'
return
''
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录