Skip to content

Commit

Permalink
自动更新功能预装部分
Browse files Browse the repository at this point in the history
  • Loading branch information
lunzhiPenxil committed Aug 28, 2022
1 parent af92f5b commit 73aca56
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
1 change: 1 addition & 0 deletions OlivaDiceMaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
from . import msgCustomManager
from . import data
from . import webTool
from . import webAPI
4 changes: 2 additions & 2 deletions OlivaDiceMaster/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"namespace" : "OlivaDiceMaster",
"message_mode" : "old_string",
"info" : "本模块为OlivaDice的大师模块,提供了更高级的骰主管理功能,其中的功能可能不是必须的,但是却是强大的,这些功能包括但不限于更新和安装新的模块。",
"version" : "3.0.7",
"svn" : 8,
"version" : "3.0.8",
"svn" : 9,
"compatible_svn" : 101,
"priority" : 20020,
"support" : [
Expand Down
6 changes: 4 additions & 2 deletions OlivaDiceMaster/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
'''


OlivaDiceMaster_ver = '3.0.7'
OlivaDiceMaster_svn = 8
OlivaDiceMaster_ver = '3.0.8'
OlivaDiceMaster_svn = 9
OlivaDiceMaster_ver_short = '%s(%s)' % (str(OlivaDiceMaster_ver), str(OlivaDiceMaster_svn))

OlivaDiceMaster_oopm_host = 'https://api.dice.center/OlivaDiceVer'

globalProc = None
1 change: 1 addition & 0 deletions OlivaDiceMaster/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

class Event(object):
def init(plugin_event, Proc):
OlivaDiceMaster.data.globalProc = Proc
OlivaDiceMaster.msgReply.unity_init(plugin_event, Proc)

def init_after(plugin_event, Proc):
Expand Down
1 change: 1 addition & 0 deletions OlivaDiceMaster/msgReply.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def unity_init(plugin_event, Proc):

def data_init(plugin_event, Proc):
OlivaDiceMaster.msgCustomManager.initMsgCustom(Proc.Proc_data['bot_info_dict'])
OlivaDiceMaster.webAPI.init_getCheckAPI(Proc.Proc_data['bot_info_dict'])

def unity_reply(plugin_event, Proc):
OlivaDiceCore.userConfig.setMsgCount()
Expand Down
56 changes: 56 additions & 0 deletions OlivaDiceMaster/webAPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- encoding: utf-8 -*-
'''
_______________________ _________________________________________
__ __ \__ /____ _/_ | / /__ |__ __ \___ _/_ ____/__ ____/
_ / / /_ / __ / __ | / /__ /| |_ / / /__ / _ / __ __/
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : webAPI.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
@Copyright : (C) 2020-2021, OlivOS-Team
@Desc : None
'''

import OlivaDiceCore
import OlivaDiceMaster

import threading
import time

def init_getCheckAPI(botDict:dict):
threading.Thread(
target = getCheckAPI,
args = (botDict, )
).start()

def getCheckAPI(botDict:dict):
while True:
webRes = None
for botDict_this in botDict:
webRes = None
webRes = OlivaDiceMaster.webTool.GETHttpJson2Dict('http://api.oliva.icu/checkout/?hash=%s' % str(botDict_this))
if 'code' in webRes and webRes['code'] == 0:
if (
'data' in webRes
) and (
'svn' in webRes['data']
) and (
type(webRes['data']['svn']) == int
) and (
webRes['data']['svn'] > OlivaDiceCore.data.OlivaDiceCore_svn
):
if OlivaDiceMaster.data.globalProc != None:
OlivaDiceMaster.data.globalProc.log(3, '检测到新版本: %s' % str(webRes['data']['svn']), [
('OlivaDice', 'default'),
('init', 'default')
])
else:
if OlivaDiceMaster.data.globalProc != None:
OlivaDiceMaster.data.globalProc.log(2, '当前已为最新版本' , [
('OlivaDice', 'default'),
('init', 'default')
])
time.sleep(1 * 60 * 60)
2 changes: 1 addition & 1 deletion OlivaDiceMaster/webTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/ /_/ /_ /____/ / __ |/ / _ ___ | /_/ /__/ / / /___ _ /___
\____/ /_____/___/ _____/ /_/ |_/_____/ /___/ \____/ /_____/
@File : msgReply.py
@File : webTool.py
@Author : lunzhiPenxil仑质
@Contact : [email protected]
@License : AGPL
Expand Down

0 comments on commit 73aca56

Please sign in to comment.