diff --git a/OlivOS/API.py b/OlivOS/API.py index 76f078a3..bf46e0fb 100644 --- a/OlivOS/API.py +++ b/OlivOS/API.py @@ -99,6 +99,8 @@ def __init__(self, sdk_event = None, log_func = None): self.base_info['type'] = None self.plugin_info = {} self.plugin_info['func_type'] = None + self.plugin_info['name'] = 'unity' + self.plugin_info['namespace'] = 'unity' self.sdk_event = sdk_event self.sdk_event_type = type(self.sdk_event) self.get_Event_from_SDK() @@ -170,6 +172,7 @@ def do_init_log(self): tmp_log_message = 'Interval(' + str(self.data.interval) + ')' self.log_func(tmp_log_level, tmp_log_message, [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), (self.plugin_info['func_type'], 'default') ]) @@ -325,6 +328,7 @@ def funcWarpped(*args, **kwargs): callback_msg = 'done' event_obj.log_func(2, callback_msg , [ (event_obj.platform['platform'], 'default'), + (event_obj.plugin_info['name'], 'default'), (func_name, 'callback') ]) return warppedRes @@ -339,6 +343,7 @@ def __set_block(self, enable, flag_log = True): if flag_log: self.log_func(2, str(enable) , [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('set_block', 'callback') ]) @@ -397,11 +402,13 @@ def __reply(self, message, flag_log = True): if flag_type == 'private': self.log_func(2, 'User(' + str(self.data.user_id) + '): ' + message, [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('reply', 'callback') ]) elif flag_type == 'group': self.log_func(2, 'Group(' + str(self.data.group_id) + '): ' + message, [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('reply', 'callback') ]) @@ -426,11 +433,13 @@ def __send(self, send_type, target_id, message, flag_log = True): if flag_type == 'private': self.log_func(2, 'User(' + str(target_id) + '): ' + message, [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('send', 'callback') ]) elif flag_type == 'group': self.log_func(2, 'Group(' + str(target_id) + '): ' + message, [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('send', 'callback') ]) @@ -674,11 +683,13 @@ def __get_login_info(self, flag_log = True): if res_data['active'] == True: self.log_func(2, 'name(' + res_data['data']['name'] + ') id(' + str(res_data['data']['id']) + ')' , [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('get_login_info', 'callback') ]) else: self.log_func(2, 'failed' , [ (self.platform['platform'], 'default'), + (self.plugin_info['name'], 'default'), ('get_login_info', 'callback') ]) return res_data @@ -699,9 +710,6 @@ def __get_stranger_info(self, user_id, no_cache, flag_log = True): res_data = OlivOS.onebotSDK.event_action.get_stranger_info(self, user_id, no_cache) elif self.platform['sdk'] == 'telegram_poll': pass - - if res_data == None: - return None return res_data def get_stranger_info(self, user_id, no_cache = False, flag_log = True, remote = False): diff --git a/OlivOS/diagnoseAPI.py b/OlivOS/diagnoseAPI.py index 131e124b..1f9d5c1c 100644 --- a/OlivOS/diagnoseAPI.py +++ b/OlivOS/diagnoseAPI.py @@ -70,7 +70,7 @@ def log_output(self, log_packet_this): if log_packet_this['log_level'] in self.Proc_config['logger_vis_level']: if self.Proc_config['logger_mode'] == 'console': log_output_str = '' - log_output_str += '[' + str(datetime.datetime.fromtimestamp(log_packet_this['log_time'])) + '] - ' + log_output_str += '[' + str(datetime.datetime.fromtimestamp(int(log_packet_this['log_time']))) + '] - ' log_output_str += '[' + self.Proc_config['level_dict'][log_packet_this['log_level']] + ']' + ' - ' for segment_this in log_packet_this['log_segment']: (segment_this_mark, segment_this_type) = segment_this diff --git a/OlivOS/pluginAPI.py b/OlivOS/pluginAPI.py index c328fb7f..4643951c 100644 --- a/OlivOS/pluginAPI.py +++ b/OlivOS/pluginAPI.py @@ -84,9 +84,11 @@ def run(self): if self.Proc_config['enable_auto_restart']: rx_count += 1 if rx_count == self.Proc_config['step_to_restart']: - self.log(2, 'OlivOS plugin shallow [' + self.Proc_name + '] call restart') - self.Proc_info.rx_queue.put(OlivOS.API.Control.packet('restart_do', self.Proc_name), block=False) + self.set_restart() + def set_restart(self): + self.log(2, 'OlivOS plugin shallow [' + self.Proc_name + '] call restart') + self.Proc_info.rx_queue.put(OlivOS.API.Control.packet('restart_do', self.Proc_name), block=False) def run_plugin(self, sdk_event): log_str_tmp = str(sdk_event.json) @@ -127,9 +129,12 @@ def run_plugin(self, sdk_event): if flag_support_found_dict['sdk'] and flag_support_found_dict['platform'] and flag_support_found_dict['model']: flag_support_found_dict['flag'] = True if flag_support_found_dict['flag']: + plugin_event.plugin_info['name'] = self.plugin_models_dict[plugin_models_index_this]['name'] + plugin_event.plugin_info['namespace'] = self.plugin_models_dict[plugin_models_index_this]['namespace'] self.plugin_event_router(plugin_event, self.plugin_models_dict[plugin_models_index_this]['model']) self.log(0, 'event [' + str(plugin_event.plugin_info['func_type']) + '] call plugin [' + self.plugin_models_dict[plugin_models_index_this]['name'] + '] done') if plugin_event.blocked: + self.log(2, 'event [' + str(plugin_event.plugin_info['func_type']) + '] call blocked by plugin [' + self.plugin_models_dict[plugin_models_index_this]['name'] + ']') break return