提交 83c098b4 编辑于 作者: yuudi's avatar yuudi
浏览文件

fix: forced update when uncommited

上级 456a695f
{
"stable": {
"version": 3459,
"version": 3476,
"url": "http://img.yobot.xyz/yobot/yobot3459.zip"
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@
<p>欢迎{{ user.nickname }}</p>
<div>上次登录:[[ from_ts({{ session.get('last_login_time') }}) ]] at {{ session.get('last_login_ipaddr') }}([[ addr.join('') ]])
</div>
{% if user.authority_group < 100 -%}
{% if user.authority_group < 10 -%}
<el-row>
<a href="{{ url_for('yobot_setting') }}">
<el-button type="primary">设置</el-button>
......
import asyncio
import datetime
import json
import re
......@@ -51,9 +50,6 @@ class Event:
self.timeline = None
loop = asyncio.get_event_loop()
asyncio.ensure_future(self.load_timeline_async(), loop=loop)
def load_timeline(self, rg):
raise RuntimeError("no more sync calling")
......@@ -248,7 +244,8 @@ class Event:
reply = "未设置区服,请发送“{}设置”".format(
self.setting.get("preffix_string", ""))
else:
reply = "日程表未初始化"
reply = "日程表未初始化\n\n更多日程:{}".format(
_calender_url.get(self.setting["calender_region"]))
return {"reply": reply, "block": True}
if match_num == 1:
return {"reply": "", "block": True}
......@@ -304,4 +301,9 @@ class Event:
hour, minute = time.split(":")
trigger = CronTrigger(hour=hour, minute=minute)
job = (trigger, self.send_daily_async)
return (job,)
init_trigger = DateTrigger(
datetime.datetime.now() +
datetime.timedelta(seconds=5)
) # 启动5秒后初始化
init_job = (init_trigger, self.load_timeline_async)
return (job, init_job)
......@@ -95,7 +95,7 @@ class Setting:
if user.authority_group >= 10:
return await render_template(
'unauthorized.html',
limit='机器人管理员',
limit='主人',
uath=user.authority_group,
)
return await render_template('admin/pool-setting.html')
......@@ -156,7 +156,7 @@ class Setting:
if user.authority_group >= 10:
return await render_template(
'unauthorized.html',
limit='机器人管理员',
limit='主人',
uath=user.authority_group,
)
return await render_template('admin/users.html')
......@@ -249,7 +249,7 @@ class Setting:
if user.authority_group >= 10:
return await render_template(
'unauthorized.html',
limit='机器人管理员',
limit='主人',
uath=user.authority_group,
)
return await render_template('admin/groups.html')
......
......@@ -29,10 +29,9 @@ class Updater:
with open(os.path.join(glo_setting['dirname'], 'yobot.pid'), 'w') as f:
f.write(str(os.getpid()))
async def send_reply(self, context: Dict[str, Any],
message: Union[str, Dict[str, Any], List[Dict[str, Any]]],
**kwargs) -> Optional[Dict[str, Any]]:
message: Union[str, Dict[str, Any], List[Dict[str, Any]]],
**kwargs) -> Optional[Dict[str, Any]]:
context = context.copy()
context['message'] = message
context.update(kwargs)
......@@ -101,10 +100,9 @@ class Updater:
async def windows_update_git_async(self, force: bool = False, test_ver: int = 0):
test_version = ["stable", "beta", "alpha"][test_ver]
if not force:
pullcheck = self.check_commit()
if pullcheck is not None:
return pullcheck
pullcheck = self.check_commit(force)
if pullcheck is not None:
return pullcheck
server_available = False
for url in self.ver["check_url"]:
try:
......@@ -137,10 +135,9 @@ class Updater:
async def linux_update_async(self, force: bool = False, test_ver: int = 0):
test_version = ["stable", "beta", "alpha"][test_ver]
if not force:
pullcheck = self.check_commit()
if pullcheck is not None:
return pullcheck
pullcheck = self.check_commit(force)
if pullcheck is not None:
return pullcheck
for url in self.ver["check_url"]:
try:
async with aiohttp.request('GET', url=url) as response:
......@@ -161,12 +158,12 @@ class Updater:
open('.YOBOT_RESTART', 'w').close()
sys.exit(10)
def check_commit(self):
def check_commit(self, force: bool = False):
if not self.ver["commited"]:
if self.ver["ver_name"] == "无法检测版本":
return "没有版本信息,无法更新"
return "存在未提交的修改,无法自动更新"
if self.ver["extra_commit"]:
if not force and self.ver["extra_commit"]:
return "存在额外的提交,建议手动更新\n发送“强制更新”以忽略检查"
return None
......@@ -351,7 +348,7 @@ def get_version(base_version: str, base_commit: int) -> dict:
return {
"run-as": "python",
"commited": False,
"ver_name": "无法检测版本"
"ver_name": f"无法检测版本{base_version}"
}
try:
vername = "yobot{}源码版".format(base_version)
......@@ -380,5 +377,5 @@ def get_version(base_version: str, base_commit: int) -> dict:
return {
"run-as": "python",
"commited": False,
"ver_name": "无法检测版本"
"ver_name": f"无法检测版本{base_version}"
}
......@@ -33,8 +33,8 @@ else:
class Yobot:
Version = "[v3.6.2_beta_1]"
Version_id = 159
Version = "[v3.6.2_beta]"
Version_id = 176
# "git rev-list --count HEAD"
def __init__(self, *,
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册