Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

telegram:适配新的图文数据格式 #123

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions OlivOS/adapter/telegram/telegramSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\____/ /_____/___/ _____/ \____/ /____/

@File : OlivOS/telegramSDK.py
@Author : lunzhiPenxil仑质
@Author : lunzhiPenxil仑质, MetaLeo元理
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2023, OlivOS-Team
Expand Down Expand Up @@ -222,12 +222,20 @@ def get_message_obj_from_SDK(target_event):
checkInDictSafe('photo', target_event.sdk_event.json, ['message'])
]):
message_list = []
if type(target_event.sdk_event.json['message']['photo']) == list:
if type(target_event.sdk_event.json['message']['photo']) is list:
message_list.append(
OlivOS.messageAPI.PARA.image(
target_event.sdk_event.json['message']['photo'][0]['file_id']
)
)
if checkByListAnd([
checkInDictSafe('caption', target_event.sdk_event.json, ['message'])
]):
message_list.append(
OlivOS.messageAPI.PARA.text(
text = str(target_event.sdk_event.json['message']['caption'])
)
)
message_obj = OlivOS.messageAPI.Message_templet(
'olivos_para',
message_list
Expand Down Expand Up @@ -288,7 +296,7 @@ def get_Event_from_SDK(target_event):
checkInDictSafe('message_id', target_event.sdk_event.json, ['message']),
checkInDictSafe('from', target_event.sdk_event.json, ['message']),
checkInDictSafe('first_name', target_event.sdk_event.json, ['message', 'from']),
checkInDictSafe('text', target_event.sdk_event.json, ['message']),
#checkInDictSafe('text', target_event.sdk_event.json, ['message']),
checkEquelInDictSafe('private', target_event.sdk_event.json, ['message', 'chat', 'type'])
]):
message_obj = None
Expand Down Expand Up @@ -324,7 +332,7 @@ def get_Event_from_SDK(target_event):
checkInDictSafe('from', target_event.sdk_event.json, ['message']),
checkInDictSafe('id', target_event.sdk_event.json, ['message', 'from']),
checkInDictSafe('first_name', target_event.sdk_event.json, ['message', 'from']),
checkInDictSafe('text', target_event.sdk_event.json, ['message']),
#checkInDictSafe('text', target_event.sdk_event.json, ['message']),
checkEquelInDictSafe('group', target_event.sdk_event.json, ['message', 'chat', 'type'])
]):
message_obj = None
Expand Down Expand Up @@ -362,7 +370,7 @@ def get_Event_from_SDK(target_event):
checkInDictSafe('from', target_event.sdk_event.json, ['message']),
checkInDictSafe('id', target_event.sdk_event.json, ['message', 'from']),
checkInDictSafe('first_name', target_event.sdk_event.json, ['message', 'from']),
checkInDictSafe('text', target_event.sdk_event.json, ['message']),
#checkInDictSafe('text', target_event.sdk_event.json, ['message']),
checkEquelInDictSafe('supergroup', target_event.sdk_event.json, ['message', 'chat', 'type'])
]):
message_obj = None
Expand Down