Skip to content

Commit

Permalink
Merge pull request #1595 from 6vision/master
Browse files Browse the repository at this point in the history
企微优化
zhayujie authored Dec 14, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 3514c37 + 413e09f commit 219e9ec
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion channel/wework/wework_channel.py
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ def wrapper(self, cmsg: ChatMessage):


@wework.msg_register(
[ntwork.MT_RECV_TEXT_MSG, ntwork.MT_RECV_IMAGE_MSG, 11072, ntwork.MT_RECV_VOICE_MSG])
[ntwork.MT_RECV_TEXT_MSG, ntwork.MT_RECV_IMAGE_MSG, 11072, ntwork.MT_RECV_LINK_CARD_MSG,ntwork.MT_RECV_FILE_MSG, ntwork.MT_RECV_VOICE_MSG])
def all_msg_handler(wework_instance: ntwork.WeWork, message):
logger.debug(f"收到消息: {message}")
if 'data' in message:
13 changes: 13 additions & 0 deletions channel/wework/wework_message.py
Original file line number Diff line number Diff line change
@@ -128,6 +128,18 @@ def __init__(self, wework_msg, wework, is_group=False):
self.ctype = ContextType.IMAGE
self.content = os.path.join(current_dir, "tmp", file_name)
self._prepare_fn = lambda: cdn_download(wework, wework_msg, file_name)
elif wework_msg["type"] == 11045: # 文件消息
print("文件消息")
print(wework_msg)
file_name = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
file_name = file_name + wework_msg['data']['cdn']['file_name']
current_dir = os.getcwd()
self.ctype = ContextType.FILE
self.content = os.path.join(current_dir, "tmp", file_name)
self._prepare_fn = lambda: cdn_download(wework, wework_msg, file_name)
elif wework_msg["type"] == 11047: # 链接消息
self.ctype = ContextType.SHARING
self.content = wework_msg['data']['url']
elif wework_msg["type"] == 11072: # 新成员入群通知
self.ctype = ContextType.JOIN_GROUP
member_list = wework_msg['data']['member_list']
@@ -179,6 +191,7 @@ def __init__(self, wework_msg, wework, is_group=False):
if conversation_id:
room_info = get_room_info(wework=wework, conversation_id=conversation_id)
self.other_user_nickname = room_info.get('nickname', None) if room_info else None
self.from_user_nickname = room_info.get('nickname', None) if room_info else None
at_list = data.get('at_list', [])
tmp_list = []
for at in at_list:

0 comments on commit 219e9ec

Please sign in to comment.