Skip to content

Commit

Permalink
版本推进至0.9.3 支持微信
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Mar 31, 2023
1 parent a3837b0 commit 778f64a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions OlivOSOnebotV11/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"namespace" : "OlivOSOnebotV11",
"info" : "基于OlivOS的OneBot协议端,可以基于OlivOS实现多后端对多账号、多平台的支持。",
"message_mode" : "olivos_para",
"version" : "0.9.2",
"svn" : 16,
"version" : "0.9.3",
"svn" : 17,
"compatible_svn" : 100,
"priority" : 50000,
"support" : [
Expand Down
42 changes: 25 additions & 17 deletions OlivOSOnebotV11/eventRouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def heartbeat(eventObj):
eventObj.rvData = {}
eventObj.rvData['post_type'] = 'meta_event'
eventObj.rvData['meta_event_type'] = 'heartbeat'
eventObj.rvData['time'] = int(time.time())
eventObj.rvData['self_id'] = int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['time'] = backport_int(time.time())
eventObj.rvData['self_id'] = backport_int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['status'] = {}
eventObj.rvData['status']['enable'] = True
eventObj.rvData['status']['interval'] = 5000
Expand All @@ -188,19 +188,19 @@ def heartbeat(eventObj):
def group_message(eventObj):
eventObj.rvData = {}
eventObj.rvData['time'] = eventObj.plugin_event.base_info['time']
eventObj.rvData['self_id'] = int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['self_id'] = backport_int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['post_type'] = 'message'
eventObj.rvData['message_type'] = 'group'
eventObj.rvData['sub_type'] = 'normal'
eventObj.rvData['message_id'] = eventObj.plugin_event.data.message_id
eventObj.rvData['user_id'] = int(eventObj.plugin_event.data.user_id)
eventObj.rvData['group_id'] = int(eventObj.plugin_event.data.group_id)
eventObj.rvData['user_id'] = backport_int(eventObj.plugin_event.data.user_id)
eventObj.rvData['group_id'] = backport_int(eventObj.plugin_event.data.group_id)
eventObj.rvData['message'] = paraMapper(eventObj.plugin_event.data.message.data)
eventObj.rvData['raw_message'] = paraMapper(eventObj.plugin_event.data.raw_message.data)
eventObj.rvData['anonymous'] = None
eventObj.rvData['font'] = eventObj.plugin_event.data.font
eventObj.rvData['sender'] = {}
eventObj.rvData['sender']['user_id'] = int(eventObj.plugin_event.data.sender['id'])
eventObj.rvData['sender']['user_id'] = backport_int(eventObj.plugin_event.data.sender['id'])
eventObj.rvData['sender']['nickname'] = eventObj.plugin_event.data.sender['name']
eventObj.rvData['sender']['role'] = 'owner'
if 'role' in eventObj.plugin_event.data.sender:
Expand All @@ -214,17 +214,17 @@ def group_message(eventObj):
def private_message(eventObj):
eventObj.rvData = {}
eventObj.rvData['time'] = eventObj.plugin_event.base_info['time']
eventObj.rvData['self_id'] = int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['self_id'] = backport_int(eventObj.plugin_event.base_info['self_id'])
eventObj.rvData['post_type'] = 'message'
eventObj.rvData['message_type'] = 'private'
eventObj.rvData['sub_type'] = eventObj.plugin_event.data.sub_type
eventObj.rvData['message_id'] = eventObj.plugin_event.data.message_id
eventObj.rvData['user_id'] = int(eventObj.plugin_event.data.user_id)
eventObj.rvData['user_id'] = backport_int(eventObj.plugin_event.data.user_id)
eventObj.rvData['message'] = paraMapper(eventObj.plugin_event.data.message.data)
eventObj.rvData['raw_message'] = paraMapper(eventObj.plugin_event.data.raw_message.data)
eventObj.rvData['font'] = eventObj.plugin_event.data.font
eventObj.rvData['sender'] = {}
eventObj.rvData['sender']['user_id'] = int(eventObj.plugin_event.data.sender['id'])
eventObj.rvData['sender']['user_id'] = backport_int(eventObj.plugin_event.data.sender['id'])
eventObj.rvData['sender']['nickname'] = eventObj.plugin_event.data.sender['name']

class txEvent(object):
Expand Down Expand Up @@ -306,7 +306,7 @@ def get_msg(eventObj):
eventObj.rvData['message_id'] = res['data']['message_id']
eventObj.rvData['real_id'] = res['data']['id']
eventObj.rvData['sender'] = {}
eventObj.rvData['sender']['user_id'] = int(res['data']['sender']['id'])
eventObj.rvData['sender']['user_id'] = backport_int(res['data']['sender']['id'])
eventObj.rvData['sender']['nickname'] = res['data']['sender']['name']
eventObj.rvData['time'] = res['data']['time']
eventObj.rvData['message'] = res['data']['message']
Expand All @@ -320,7 +320,7 @@ def get_login_info(eventObj):
eventObj.active = False
elif res['active']:
eventObj.rvData = {}
eventObj.rvData['user_id'] = int(res['data']['id'])
eventObj.rvData['user_id'] = backport_int(res['data']['id'])
eventObj.rvData['nickname'] = res['data']['name']
else:
eventObj.active = False
Expand All @@ -333,7 +333,7 @@ def get_group_list(eventObj):
eventObj.rvData = []
for data_this in res['data']:
tmp_data_this = {}
tmp_data_this['group_id'] = int(data_this['id'])
tmp_data_this['group_id'] = backport_int(data_this['id'])
tmp_data_this['group_name'] = data_this['name']
tmp_data_this['group_memo'] = data_this['memo']
tmp_data_this['member_count'] = data_this['member_count']
Expand All @@ -350,7 +350,7 @@ def get_group_info(eventObj):
eventObj.rvData = {}
elif res['active']:
eventObj.rvData = {}
eventObj.rvData['group_id'] = int(res['data']['id'])
eventObj.rvData['group_id'] = backport_int(res['data']['id'])
eventObj.rvData['group_name'] = res['data']['name']
eventObj.rvData['group_memo'] = res['data']['memo']
eventObj.rvData['member_count'] = res['data']['member_count']
Expand All @@ -366,7 +366,7 @@ def get_stranger_info(eventObj):
eventObj.rvData = {}
elif res['active']:
eventObj.rvData = {}
eventObj.rvData['user_id'] = int(res['data']['id'])
eventObj.rvData['user_id'] = backport_int(res['data']['id'])
eventObj.rvData['nickname'] = res['data']['name']
else:
eventObj.active = False
Expand All @@ -379,7 +379,7 @@ def get_friend_list(eventObj):
eventObj.rvData = []
for data_this in res['data']:
tmp_data_this = {}
tmp_data_this['user_id'] = int(data_this['id'])
tmp_data_this['user_id'] = backport_int(data_this['id'])
tmp_data_this['nickname'] = data_this['name']
eventObj.rvData.append(tmp_data_this)
else:
Expand All @@ -395,7 +395,7 @@ def get_group_member_info(eventObj):
elif res['active']:
eventObj.rvData = {}
eventObj.rvData['group_id'] = res['data']['group_id']
eventObj.rvData['user_id'] = int(res['data']['id'])
eventObj.rvData['user_id'] = backport_int(res['data']['id'])
eventObj.rvData['join_time'] = res['data']['times']['join_time']
eventObj.rvData['last_sent_time'] = res['data']['times']['last_sent_time']
eventObj.rvData['shut_up_timestamp'] = res['data']['times']['shut_up_timestamp']
Expand All @@ -416,7 +416,7 @@ def get_group_member_list(eventObj):
for data_this in res['data']:
tmp_data_this = {}
tmp_data_this['group_id'] = data_this['group_id']
tmp_data_this['user_id'] = int(data_this['id'])
tmp_data_this['user_id'] = backport_int(data_this['id'])
tmp_data_this['join_time'] = data_this['times']['join_time']
tmp_data_this['last_sent_time'] = data_this['times']['last_sent_time']
tmp_data_this['shut_up_timestamp'] = data_this['times']['shut_up_timestamp']
Expand Down Expand Up @@ -672,3 +672,11 @@ def set_group_add_request(eventObj):
tmp_val['reason'] = eventObj.params['reason']
res = eventObj.plugin_event.set_group_add_request(**tmp_val)
eventObj.rvData = None

def backport_int(src):
res = src
try:
res = int(res)
except:
res = res
return res

0 comments on commit 778f64a

Please sign in to comment.