Skip to content

Commit

Permalink
账号管理器支持配置签名服务器
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Jun 28, 2023
1 parent 67cab05 commit 6b2dd74
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 680 deletions.
1 change: 1 addition & 0 deletions OlivOS/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, id=-1, password='', server_type='post', server_auto=False, ho
port=port,
access_token=access_token
)
self.extends = {}
self.debug_mode = False
self.getHash()

Expand Down
6 changes: 5 additions & 1 deletion OlivOS/accountAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def load(path, logger_proc, safe_mode=False):
platform_platform=account_conf_account_this['platform_type'],
platform_model=account_conf_account_this['model_type']
)
if 'extends' in account_conf_account_this \
and dict is type(account_conf_account_this['extends']):
bot_info_tmp.extends = account_conf_account_this['extends']
bot_info_tmp.debug_mode = account_conf_account_this['debug']
plugin_bot_info_dict[bot_info_tmp.hash] = bot_info_tmp
logger_proc.log(2, OlivOS.L10NAPI.getTrans('generate [{0}] account [{1}] as [{2}] ... done', [
Expand All @@ -75,7 +78,7 @@ def save(path, logger_proc, Account_data, safe_mode=False):
tmp_total_account_data = {}
tmp_total_account_data['account'] = []
for Account_data_this_key in Account_data:
Account_data_this = Account_data[Account_data_this_key]
Account_data_this:OlivOS.API.bot_info_T = Account_data[Account_data_this_key]
tmp_this_account_data = {}
tmp_this_account_data['id'] = Account_data_this.id
tmp_this_account_data['password'] = Account_data_this.password
Expand All @@ -88,6 +91,7 @@ def save(path, logger_proc, Account_data, safe_mode=False):
tmp_this_account_data['server']['host'] = Account_data_this.post_info.host
tmp_this_account_data['server']['port'] = Account_data_this.post_info.port
tmp_this_account_data['server']['access_token'] = Account_data_this.post_info.access_token
tmp_this_account_data['extends'] = Account_data_this.extends
tmp_this_account_data['debug'] = Account_data_this.debug_mode
tmp_total_account_data['account'].append(tmp_this_account_data)
with open(path, 'w', encoding='utf-8') as account_conf_f:
Expand Down
113 changes: 59 additions & 54 deletions OlivOS/libEXEModelAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,60 +356,61 @@ def __init__(self, bot_info_dict, target_proc):
self.config_file_format = {}

def setConfig(self):
self.config_file_str = (
"account:\n"
" uin: {uin}\n"
" password: '{password}'\n"
" encrypt: false\n"
" status: 0\n"
" relogin:\n"
" disabled: false\n"
" delay: 3\n"
" interval: 0\n"
" max-times: 0\n"
" use-sso-address: true\n"
"\n"
"heartbeat:\n"
" disabled: false\n"
" interval: 5\n"
"\n"
"message:\n"
" post-format: string\n"
" ignore-invalid-cqcode: false\n"
" force-fragment: false\n"
" fix-url: false\n"
" proxy-rewrite: ''\n"
" report-self-message: true\n"
" remove-reply-at: false\n"
" extra-reply-data: false\n"
"\n"
"output:\n"
" log-level: info\n"
" debug: false\n"
"\n"
"default-middlewares: &default\n"
" access-token: '{access-token}'\n"
" filter: '../filter.json'\n"
" rate-limit:\n"
" enabled: false\n"
" frequency: 1\n"
" bucket: 1\n"
"\n"
"servers:\n"
" - http:\n"
" disabled: false\n"
" host: {servers-host}\n"
" port: {servers-port}\n"
" timeout: 60\n"
" middlewares:\n"
" <<: *default\n"
" post:\n"
" - url: '{servers-post-url}'\n"
"\n"
"database:\n"
" leveldb:\n"
" enable: true\n"
)
self.config_file_str = '''
account:
uin: {uin}
password: '{password}'
encrypt: false
status: 0
relogin:
disabled: false
delay: 3
interval: 0
max-times: 0
use-sso-address: true
sign-server: '{sign-server}'
heartbeat:
disabled: false
interval: 5
message:
post-format: string
ignore-invalid-cqcode: false
force-fragment: false
fix-url: false
proxy-rewrite: ''
report-self-message: true
remove-reply-at: false
extra-reply-data: false
output:
log-level: info
debug: false
default-middlewares: &default
access-token: '{access-token}'
filter: '../filter.json'
rate-limit:
enabled: false
frequency: 1
bucket: 1
servers:
- http:
disabled: false
host: {servers-host}
port: {servers-port}
timeout: 60
middlewares:
<<: *default
post:
- url: '{servers-post-url}'
database:
leveldb:
enable: true
'''

self.config_file_format['uin'] = str(self.bot_info_dict.id)
self.config_file_format['password'] = self.bot_info_dict.password
Expand All @@ -429,6 +430,10 @@ def setConfig(self):
self.config_file_format['servers-port'] = str(self.bot_info_dict.post_info.port)
self.config_file_format['servers-post-url'] = 'http://127.0.0.1:' + str(
self.target_proc['server']['port']) + '/OlivOSMsgApi/qq/onebot/gocqhttp'
self.config_file_format['sign-server'] = '-'
if 'sign-server' in self.bot_info_dict.extends \
and '' != self.bot_info_dict.extends['sign-server']:
self.config_file_format['sign-server'] = str(self.bot_info_dict.extends['sign-server'])

self.config_file_str = self.config_file_str.format(**self.config_file_format)

Expand Down
Loading

0 comments on commit 6b2dd74

Please sign in to comment.