Skip to content

Commit

Permalink
0.11.1 引入虚拟设备信息编辑功能,可主动切换协议
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Mar 1, 2023
1 parent cbf8a8a commit e90f0cc
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 7 deletions.
8 changes: 8 additions & 0 deletions OlivOS/bootAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ def start(self):
bot_info_dict=plugin_bot_info_dict,
logger_proc=Proc_dict[basic_conf_models_this['logger_proc']],
)
if platform.system() == 'Windows':
OlivOS.libEXEModelAPI.accountFix(
bot_info_dict=plugin_bot_info_dict,
logger_proc=Proc_dict[basic_conf_models_this['logger_proc']],
)
plugin_bot_info_dict = OlivOS.accountAPI.accountFix(
basic_conf_models=basic_conf_models,
bot_info_dict=plugin_bot_info_dict,
Expand Down Expand Up @@ -511,6 +516,9 @@ def start(self):
'gocqhttp',
'gocqhttp_hide',
'gocqhttp_show',
'gocqhttp_show_Android_Phone',
'gocqhttp_show_Android_Watch',
'gocqhttp_show_iPad',
'gocqhttp_show_old'
]:
tmp_Proc_name = basic_conf_models_this['name'] + '=' + bot_info_key
Expand Down
4 changes: 2 additions & 2 deletions OlivOS/infoAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import OlivOS


OlivOS_Version = '0.11.0'
OlivOS_SVN = 120
OlivOS_Version = '0.11.1'
OlivOS_SVN = 121

# Compatible <= Plugin[compatible_svn] : Compatible
# OldCompatible <= Plugin[compatible_svn] < Compatible : OldCompatible Warn
Expand Down
43 changes: 41 additions & 2 deletions OlivOS/libEXEModelAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import time
import os
import traceback
import json

import OlivOS

Expand Down Expand Up @@ -47,7 +48,10 @@ def __init__(self, Proc_name, scan_interval=0.001, dead_interval=1, rx_queue=Non
def run(self):
flag_run = True
if self.Proc_data['bot_info_dict'].platform['model'] in [
'gocqhttp_show'
'gocqhttp_show',
'gocqhttp_show_Android_Phone',
'gocqhttp_show_Android_Watch',
'gocqhttp_show_iPad'
]:
self.send_init_event()
while flag_run:
Expand Down Expand Up @@ -78,7 +82,10 @@ def run(self):
self.log(2, 'OlivOS libEXEModel server [' + self.Proc_name + '] exited')
elif self.Proc_data['bot_info_dict'].platform['model'] in [
'gocqhttp',
'gocqhttp_show'
'gocqhttp_show',
'gocqhttp_show_Android_Phone',
'gocqhttp_show_Android_Watch',
'gocqhttp_show_iPad'
]:
self.log(2, 'OlivOS libEXEModel server [' + self.Proc_name + '] will run under visiable mode')
self.clear_gocqhttp()
Expand Down Expand Up @@ -328,6 +335,38 @@ def setConfig(self):
with open('./conf/gocqhttp/' + self.bot_info_dict.hash + '/config.yml', 'w+', encoding='utf-8') as tmp:
tmp.write(self.config_file_str)

def accountFix(bot_info_dict, logger_proc):
releaseDir('./conf')
releaseDir('./conf/gocqhttp')
for bot_info_dict_this in bot_info_dict:
bot_hash = bot_info_dict_this
if bot_info_dict[bot_hash].platform['sdk'] == 'onebot' \
and bot_info_dict[bot_hash].platform['platform'] == 'qq' \
and bot_info_dict[bot_hash].platform['model'] in [
'gocqhttp_show_Android_Phone',
'gocqhttp_show_Android_Watch',
'gocqhttp_show_iPad',
]:
releaseDir('./conf/gocqhttp/' + bot_hash)
file_path = './conf/gocqhttp/' + bot_hash + '/device.json'
device_info = {}
try:
with open(file_path, 'r', encoding = 'utf-8') as f:
device_info = json.loads(f.read())
except:
device_info = {}
if bot_info_dict[bot_hash].platform['model'] == 'gocqhttp_show_Android_Phone':
device_info['protocol'] = 1
elif bot_info_dict[bot_hash].platform['model'] == 'gocqhttp_show_Android_Watch':
device_info['protocol'] = 2
elif bot_info_dict[bot_hash].platform['model'] == 'gocqhttp_show_iPad':
device_info['protocol'] = 5
try:
with open(file_path, 'w', encoding = 'utf-8') as f:
f.write(json.dumps(device_info, ensure_ascii = False))
except:
pass


def releaseDir(dir_path):
if not os.path.exists(dir_path):
Expand Down
33 changes: 30 additions & 3 deletions OlivOS/multiLoginUIAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
'edit_root_Combobox_Account_type_StringVar': tkinter.StringVar(),
'edit_root_Combobox_dict': {
'type_list': [
'传统QQ',
'传统QQ - 默认',
'传统QQ - 安卓手机',
'传统QQ - 安卓手表',
'传统QQ - iPad',
'传统QQ - 旧',
'Discord',
'Telegram',
Expand All @@ -275,11 +278,32 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
# 各类账号组合的匹配与注册表
# type: [platform, sdk, model, server_auto, server_type, {data_dict}]
'type_note_list': {
'传统QQ': '密码留空即尝试使用扫码登录',
'传统QQ - 默认': '密码留空即尝试使用扫码登录',
'传统QQ - 安卓手机': '密码留空即尝试使用扫码登录',
'传统QQ - 安卓手表': '密码留空即尝试使用扫码登录',
'传统QQ - iPad': '密码留空即尝试使用扫码登录',
'传统QQ - 旧': '密码留空即尝试使用扫码登录'
},
'type_mapping_list': {
'传统QQ': ['qq', 'onebot', 'gocqhttp_show', 'True', 'post', {
'传统QQ - 默认': ['qq', 'onebot', 'gocqhttp_show', 'True', 'post', {
'账号': 'edit_root_Entry_ID',
'密码': 'edit_root_Entry_Password',
# 推荐使用扫码登录时,可以隐藏密码栏
}
],
'传统QQ - 安卓手机': ['qq', 'onebot', 'gocqhttp_show_Android_Phone', 'True', 'post', {
'账号': 'edit_root_Entry_ID',
'密码': 'edit_root_Entry_Password',
# 推荐使用扫码登录时,可以隐藏密码栏
}
],
'传统QQ - 安卓手表': ['qq', 'onebot', 'gocqhttp_show_Android_Watch', 'True', 'post', {
'账号': 'edit_root_Entry_ID',
'密码': 'edit_root_Entry_Password',
# 推荐使用扫码登录时,可以隐藏密码栏
}
],
'传统QQ - iPad': ['qq', 'onebot', 'gocqhttp_show_iPad', 'True', 'post', {
'账号': 'edit_root_Entry_ID',
'密码': 'edit_root_Entry_Password',
# 推荐使用扫码登录时,可以隐藏密码栏
Expand Down Expand Up @@ -411,6 +435,9 @@ def __init__(self, action, Account_data, hash_key=None, edit_commit_callback=Non
# 'gocqhttp',
# 'gocqhttp_hide',
'gocqhttp_show',
'gocqhttp_show_Android_Phone',
'gocqhttp_show_Android_Watch',
'gocqhttp_show_iPad',
'gocqhttp_show_old',
'default'
]
Expand Down

0 comments on commit e90f0cc

Please sign in to comment.