Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BillLi
ItChat
提交
2bc6e0b7
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 搜索 >>
提交
2bc6e0b7
编写于
12月 02, 2016
作者:
L
LittleCoder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add logging of sending messages & fix bug of chatroom returned by sync
上级
b9a152f4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
5 deletion
+33
-5
itchat/components/contact.py
itchat/components/contact.py
+11
-3
itchat/components/hotreload.py
itchat/components/hotreload.py
+5
-1
itchat/components/login.py
itchat/components/login.py
+8
-1
itchat/components/messages.py
itchat/components/messages.py
+9
-0
未找到文件。
itchat/components/contact.py
浏览文件 @
2bc6e0b7
...
...
@@ -98,6 +98,10 @@ def update_friend(self, userName):
return
r
if
1
<
len
(
r
)
else
r
[
0
]
def
update_local_chatrooms
(
core
,
l
):
'''
get a list of chatrooms for updating local chatrooms
return a list of given chatrooms with updated info
'''
oldUsernameList
=
[]
for
chatroom
in
l
:
# format NickName & DisplayName & self keys
...
...
@@ -119,6 +123,7 @@ def update_local_chatrooms(core, l):
oldMember
=
utils
.
search_dict_list
(
oldMemberList
,
'UserName'
,
member
[
'UserName'
])
if
oldMember
is
not
None
:
#TODO
for
k
in
oldMember
:
member
[
k
]
=
member
.
get
(
k
)
or
oldMember
[
k
]
else
:
...
...
@@ -158,12 +163,12 @@ def update_local_chatrooms(core, l):
def
update_local_friends
(
core
,
l
):
fullList
=
core
.
memberList
+
core
.
mpList
for
friend
in
l
:
utils
.
emoji_formatter
(
friend
,
'NickName'
)
utils
.
emoji_formatter
(
friend
,
'DisplayName'
)
oldInfoDict
=
utils
.
search_dict_list
(
fullList
,
'UserName'
,
friend
[
'UserName'
])
if
oldInfoDict
is
None
:
oldInfoDict
=
copy
.
deepcopy
(
friend
)
utils
.
emoji_formatter
(
oldInfoDict
,
'NickName'
)
utils
.
emoji_formatter
(
oldInfoDict
,
'DisplayName'
)
if
oldInfoDict
[
'VerifyFlag'
]
&
8
==
0
:
core
.
memberList
.
append
(
oldInfoDict
)
else
:
...
...
@@ -176,6 +181,10 @@ def update_local_friends(core, l):
oldInfoDict
[
k
]
=
v
def
update_local_uin
(
core
,
msg
):
'''
content contains uins and StatusNotifyUserName contains username
they are in same order, so what I do is to pair them together
'''
uins
=
re
.
search
(
'<username>([^<]*?)<'
,
msg
[
'Content'
])
usernameChangedList
=
[]
r
=
{
...
...
@@ -232,7 +241,6 @@ def get_contact(self, update=False):
tempList
=
json
.
loads
(
r
.
content
.
decode
(
'utf-8'
,
'replace'
))[
'MemberList'
]
chatroomList
,
otherList
=
[],
[]
for
m
in
tempList
:
utils
.
emoji_formatter
(
m
,
'NickName'
)
if
m
[
'Sex'
]
!=
0
:
otherList
.
append
(
m
)
elif
'@@'
in
m
[
'UserName'
]:
...
...
itchat/components/hotreload.py
浏览文件 @
2bc6e0b7
...
...
@@ -52,7 +52,11 @@ def load_login_status(self, fileDir,
'Ret'
:
-
1003
,
}})
else
:
if
contactList
:
update_local_chatrooms
(
self
,
contactList
)
for
contact
in
contactList
:
if
'@@'
in
contact
[
'UserName'
]:
update_local_chatrooms
(
self
,
[
contact
])
else
:
update_local_chatrooms
(
self
,
[
contact
])
if
msgList
:
msgList
=
produce_msg
(
self
,
msgList
)
for
msg
in
msgList
:
self
.
msgList
.
put
(
msg
)
...
...
itchat/components/login.py
浏览文件 @
2bc6e0b7
...
...
@@ -159,6 +159,7 @@ def web_init(self):
for
item
in
dic
[
'SyncKey'
][
'List'
]])
self
.
storageClass
.
userName
=
dic
[
'User'
][
'UserName'
]
self
.
storageClass
.
nickName
=
dic
[
'User'
][
'NickName'
]
self
.
memberList
.
append
(
dic
[
'User'
])
return
dic
def
show_mobile_login
(
self
):
...
...
@@ -190,7 +191,13 @@ def start_receiving(self, exitCallback=None):
else
:
msgList
,
contactList
=
self
.
get_msg
()
if
contactList
:
chatroomMsg
=
update_local_chatrooms
(
self
,
contactList
)
chatroomList
,
otherList
=
[],
[]
for
contact
in
contactList
:
if
'@@'
in
contact
[
'UserName'
]:
chatroomList
.
append
(
contact
)
else
:
otherList
.
append
(
contact
)
chatroomMsg
=
update_local_chatrooms
(
self
,
chatroomList
)
self
.
msgList
.
put
(
chatroomMsg
)
if
msgList
:
msgList
=
produce_msg
(
self
,
msgList
)
...
...
itchat/components/messages.py
浏览文件 @
2bc6e0b7
...
...
@@ -231,10 +231,13 @@ def send_raw_msg(self, msgType, content, toUserName):
return
ReturnValue
(
rawResponse
=
r
)
def
send_msg
(
self
,
msg
=
'Test Message'
,
toUserName
=
None
):
logger
.
debug
(
'Request to send a text message to %s: %s'
%
(
toUserName
,
msg
))
r
=
self
.
send_raw_msg
(
1
,
msg
,
toUserName
)
return
r
def
upload_file
(
self
,
fileDir
,
isPicture
=
False
,
isVideo
=
False
):
logger
.
debug
(
'Request to upload a %s: %s'
%
(
'picture'
if
isPicture
else
'video'
if
isVideo
else
'file'
,
fileDir
))
if
not
utils
.
check_file
(
fileDir
):
return
ReturnValue
({
'BaseResponse'
:
{
'ErrMsg'
:
'No file found in specific dir'
,
...
...
@@ -267,6 +270,8 @@ def upload_file(self, fileDir, isPicture=False, isVideo=False):
return
ReturnValue
(
rawResponse
=
r
)
def
send_file
(
self
,
fileDir
,
toUserName
=
None
,
mediaId
=
None
):
logger
.
debug
(
'Request to send a file(mediaId: %s) to %s: %s'
%
(
mediaId
,
toUserName
,
fileDir
))
if
toUserName
is
None
:
toUserName
=
self
.
storageClass
.
userName
if
mediaId
is
None
:
r
=
self
.
upload_file
(
fileDir
)
...
...
@@ -296,6 +301,8 @@ def send_file(self, fileDir, toUserName=None, mediaId=None):
return
ReturnValue
(
rawResponse
=
r
)
def
send_image
(
self
,
fileDir
,
toUserName
=
None
,
mediaId
=
None
):
logger
.
debug
(
'Request to send a image(mediaId: %s) to %s: %s'
%
(
mediaId
,
toUserName
,
fileDir
))
if
toUserName
is
None
:
toUserName
=
self
.
storageClass
.
userName
if
mediaId
is
None
:
r
=
self
.
upload_file
(
fileDir
,
isPicture
=
not
fileDir
[
-
4
:]
==
'.gif'
)
...
...
@@ -326,6 +333,8 @@ def send_image(self, fileDir, toUserName=None, mediaId=None):
return
ReturnValue
(
rawResponse
=
r
)
def
send_video
(
self
,
fileDir
=
None
,
toUserName
=
None
,
mediaId
=
None
):
logger
.
debug
(
'Request to send a video(mediaId: %s) to %s: %s'
%
(
mediaId
,
toUserName
,
fileDir
))
if
toUserName
is
None
:
toUserName
=
self
.
storageClass
.
userName
if
mediaId
is
None
:
r
=
self
.
upload_file
(
fileDir
,
isVideo
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录