Skip to content

Commit

Permalink
多项改进
Browse files Browse the repository at this point in the history
+ Fanbook完整图文收发
+ 改进dodo对接
+ 添加重连screen脚本
  • Loading branch information
lunzhiPenxil committed Dec 8, 2021
1 parent 9ade0d3 commit 47582cb
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 5 deletions.
1 change: 1 addition & 0 deletions OlivOS/dodoPollServerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def run_poll_list(self):
continue
except:
continue
time.sleep(1)

def run_sdk_api(self, sdk_api):
sdk_api.do_api()
84 changes: 80 additions & 4 deletions OlivOS/fanbookSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_Event_from_SDK(target_event):
target_event.platform['sdk'] = target_event.sdk_event.platform['sdk']
target_event.platform['platform'] = target_event.sdk_event.platform['platform']
target_event.platform['model'] = target_event.sdk_event.platform['model']
target_event.plugin_info['message_mode_rx'] = 'fanbook_string'
target_event.plugin_info['message_mode_rx'] = 'olivos_para'
if checkByListAnd([
not target_event.active,
checkInDictSafe('channel_post', target_event.sdk_event.json, []),
Expand All @@ -182,6 +182,48 @@ def get_Event_from_SDK(target_event):
'fanbook_string',
target_event.sdk_event.json['channel_post']['text']
)
message_obj.mode_rx = target_event.plugin_info['message_mode_rx']
message_obj.data_raw = message_obj.data.copy()
target_event.active = True
target_event.plugin_info['func_type'] = 'group_message'
target_event.data = target_event.group_message(
target_event.sdk_event.json['channel_post']['chat']['id'],
target_event.sdk_event.json['channel_post']['from']['id'],
message_obj,
'group'
)
target_event.data.message_sdk = message_obj
target_event.data.message_id = target_event.sdk_event.json['channel_post']['message_id']
target_event.data.raw_message = message_obj
target_event.data.raw_message_sdk = message_obj
target_event.data.font = None
target_event.data.sender['user_id'] = target_event.sdk_event.json['channel_post']['from']['id']
target_event.data.sender['nickname'] = target_event.sdk_event.json['channel_post']['from']['first_name']
target_event.data.sender['sex'] = 'unknown'
target_event.data.sender['age'] = 0
target_event.data.host_id = target_event.sdk_event.json['channel_post']['chat']['guild_id']
target_event.data.extend['host_group_id'] = target_event.sdk_event.json['channel_post']['chat']['guild_id']
elif checkByListAnd([
not target_event.active,
checkInDictSafe('channel_post', target_event.sdk_event.json, []),
checkInDictSafe('photo', target_event.sdk_event.json, ['channel_post']),
checkInDictSafe('chat', target_event.sdk_event.json, ['channel_post']),
checkInDictSafe('type', target_event.sdk_event.json, ['channel_post', 'chat']),
checkInDictSafe('message_id', target_event.sdk_event.json, ['channel_post']),
checkInDictSafe('from', target_event.sdk_event.json, ['channel_post']),
checkInDictSafe('first_name', target_event.sdk_event.json, ['channel_post', 'from']),
checkEquelInDictSafe('channel', target_event.sdk_event.json, ['channel_post', 'chat', 'type'])
]):
message_obj = None
message_para_list = []
if type(target_event.sdk_event.json['channel_post']['photo']) == list:
for photo_this in target_event.sdk_event.json['channel_post']['photo']:
if 'file_id' in photo_this:
message_para_list.append(OlivOS.messageAPI.PARA.image(photo_this['file_id']))
message_obj = OlivOS.messageAPI.Message_templet(
'olivos_para',
message_para_list
)
target_event.active = True
target_event.plugin_info['func_type'] = 'group_message'
target_event.data = target_event.group_message(
Expand All @@ -205,11 +247,30 @@ def get_Event_from_SDK(target_event):
#支持OlivOS API调用的方法实现
class event_action(object):
def send_msg(target_event, chat_id, message):
flag_now_type = 'string'
this_msg = API.sendMessage(get_SDK_bot_info_from_Event(target_event))
this_msg_image = API.sendPhoto(get_SDK_bot_info_from_Event(target_event))
this_msg.data.chat_id = chat_id
this_msg.data.text = message
if this_msg.data.text != '':
this_msg.do_api()
this_msg_image.data.chat_id = chat_id
this_msg.data.text = ''
for message_this in message.data:
if type(message_this) == OlivOS.messageAPI.PARA.image:
if flag_now_type != 'image':
if this_msg.data.text != '':
this_msg.do_api()
this_msg.data.text = ''
this_msg_image.data.photo['Url'] = message_this.data['file']
this_msg_image.do_api()
flag_now_type = 'image'
elif type(message_this) == OlivOS.messageAPI.PARA.text:
this_msg.data.text += message_this.fanbook()
flag_now_type = 'string'
elif type(message_this) == OlivOS.messageAPI.PARA.at:
this_msg.data.text += message_this.fanbook()
flag_now_type = 'string'
if flag_now_type != 'image':
if this_msg.data.text != '':
this_msg.do_api()

def send_private_msg(target_event, chat_id, message):
private_chat_id = None
Expand Down Expand Up @@ -264,6 +325,21 @@ def __init__(self):
self.disable_web_page_preview = True
self.disable_notification = False

class sendPhoto(api_templet):
def __init__(self, bot_info = None):
api_templet.__init__(self)
self.bot_info = bot_info
self.data = self.data_T()
self.host = fanbookAPIHost['a1']
self.route = fanbookAPIRoute['apiroot'] + '/{token}/sendPhoto'

class data_T(object):
def __init__(self):
self.chat_id = 0
self.photo = {
'Url': ''
}

class getPrivateChat(api_templet):
def __init__(self, bot_info = None):
api_templet.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion OlivOS/infoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import OlivOS


OlivOS_Version = '0.7.0'
OlivOS_Version = '0.7.1'

OlivOS_Header_UA = 'OlivOS/' + OlivOS_Version

Expand Down
1 change: 1 addition & 0 deletions script/screen_linkserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
screen -D -r OlivOS

0 comments on commit 47582cb

Please sign in to comment.