⚡️🐛 Change the default location of update notifications and fix some bugs. (#137)
⚡️ 修改更新通知默认位置 🐛 批量修复错误
This commit is contained in:
parent
526ec8cf17
commit
cfb45e4724
@ -68,7 +68,7 @@ git_ssh: "https://github.com/Xtao-Labs/PagerMaid-Modify.git"
|
|||||||
# Update Notice
|
# Update Notice
|
||||||
update_check: "True"
|
update_check: "True"
|
||||||
update_time: "86400"
|
update_time: "86400"
|
||||||
update_username: "self"
|
update_username: "PagerMaid_Modify_bot"
|
||||||
update_delete: "True"
|
update_delete: "True"
|
||||||
|
|
||||||
# ipv6
|
# ipv6
|
||||||
|
@ -84,6 +84,11 @@ block_des: 拉黑一個用戶
|
|||||||
block_process: 正在拉黑中 . . .
|
block_process: 正在拉黑中 . . .
|
||||||
block_success: 成功拉黑
|
block_success: 成功拉黑
|
||||||
block_exist: 已存在黑名單中。
|
block_exist: 已存在黑名單中。
|
||||||
|
# unblock
|
||||||
|
unblock_des: 取消拉黑一個用戶
|
||||||
|
unblock_process: 正在取消拉黑中 . . .
|
||||||
|
unblock_success: 成功取消拉黑
|
||||||
|
unblock_exist: 不存在黑名單中。
|
||||||
|
|
||||||
# avoid
|
# avoid
|
||||||
# ghost
|
# ghost
|
||||||
|
@ -68,7 +68,7 @@ git_ssh: "https://github.com/Xtao-Labs/PagerMaid-Modify.git"
|
|||||||
# Update Notice
|
# Update Notice
|
||||||
update_check: "True"
|
update_check: "True"
|
||||||
update_time: "86400"
|
update_time: "86400"
|
||||||
update_username: "self"
|
update_username: "PagerMaid_Modify_bot"
|
||||||
update_delete: "True"
|
update_delete: "True"
|
||||||
|
|
||||||
# ipv6
|
# ipv6
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
""" Pulls in the new version of PagerMaid from the git server. """
|
""" Pulls in the new version of PagerMaid from the git server. """
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
import requests
|
|
||||||
import time
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils.util import strtobool
|
|
||||||
from json import JSONDecodeError
|
|
||||||
from os import remove
|
from os import remove
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
from sys import executable
|
from sys import executable
|
||||||
@ -13,45 +9,10 @@ from sys import executable
|
|||||||
from git import Repo
|
from git import Repo
|
||||||
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
|
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
|
||||||
|
|
||||||
from pagermaid import log, config, proxies
|
from pagermaid import log
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from pagermaid.utils import execute, lang, alias_command
|
from pagermaid.utils import execute, lang, alias_command
|
||||||
|
|
||||||
try:
|
|
||||||
git_api = config['git_api']
|
|
||||||
git_ssh = config['git_ssh']
|
|
||||||
need_update_check = strtobool(config['update_check'])
|
|
||||||
update_time = config['update_time']
|
|
||||||
update_username = config['update_username']
|
|
||||||
update_delete = strtobool(config['update_delete'])
|
|
||||||
except KeyError:
|
|
||||||
git_api = "https://api.github.com/repos/Xtao-Labs/PagerMaid-Modify/commits/master"
|
|
||||||
git_ssh = 'https://github.com/Xtao-Labs/PagerMaid-Modify.git'
|
|
||||||
need_update_check = True
|
|
||||||
update_time = 86400
|
|
||||||
update_username = 'self'
|
|
||||||
update_delete = True
|
|
||||||
try:
|
|
||||||
update_time = int(update_time)
|
|
||||||
except ValueError:
|
|
||||||
update_time = 86400
|
|
||||||
try:
|
|
||||||
update_username = int(update_username)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def update_get():
|
|
||||||
try:
|
|
||||||
data = requests.get(git_api, proxies=proxies).json()
|
|
||||||
except JSONDecodeError as e:
|
|
||||||
raise e
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
update_get_time = 0
|
|
||||||
update_id = 0
|
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=False, incoming=True, owners_only=True, command=alias_command("update"),
|
@listener(is_plugin=False, incoming=True, owners_only=True, command=alias_command("update"),
|
||||||
description=lang('update_des'),
|
description=lang('update_des'),
|
||||||
|
@ -38,6 +38,7 @@ def listener(**args):
|
|||||||
is_plugin = args.get('is_plugin', True)
|
is_plugin = args.get('is_plugin', True)
|
||||||
owners_only = args.get("owners_only", False)
|
owners_only = args.get("owners_only", False)
|
||||||
admins_only = args.get("admins_only", False)
|
admins_only = args.get("admins_only", False)
|
||||||
|
groups_only = args.get("groups_only", False)
|
||||||
if command is not None:
|
if command is not None:
|
||||||
if command in help_messages:
|
if command in help_messages:
|
||||||
raise ValueError(f"{lang('error_prefix')} {lang('command')} \"{command}\" {lang('has_reg')}")
|
raise ValueError(f"{lang('error_prefix')} {lang('command')} \"{command}\" {lang('has_reg')}")
|
||||||
@ -64,6 +65,8 @@ def listener(**args):
|
|||||||
del args['owners_only']
|
del args['owners_only']
|
||||||
if 'admins_only' in args:
|
if 'admins_only' in args:
|
||||||
del args['admins_only']
|
del args['admins_only']
|
||||||
|
if 'groups_only' in args:
|
||||||
|
del args['groups_only']
|
||||||
|
|
||||||
def decorator(function):
|
def decorator(function):
|
||||||
|
|
||||||
@ -79,6 +82,10 @@ def listener(**args):
|
|||||||
if admins_only:
|
if admins_only:
|
||||||
if not (await admin_check(context)):
|
if not (await admin_check(context)):
|
||||||
return
|
return
|
||||||
|
# groups only
|
||||||
|
if groups_only:
|
||||||
|
if not context.is_group:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
analytic = True
|
analytic = True
|
||||||
try:
|
try:
|
||||||
|
@ -154,7 +154,8 @@ async def flip(context):
|
|||||||
await edit_reply(result, context)
|
await edit_reply(result, context)
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=False, outgoing=True, command=alias_command("ship"),
|
@listener(is_plugin=False, outgoing=True, groups_only=True,
|
||||||
|
command=alias_command("ship"),
|
||||||
description=lang('ship_des'),
|
description=lang('ship_des'),
|
||||||
parameters="<username> <username>")
|
parameters="<username> <username>")
|
||||||
async def ship(context):
|
async def ship(context):
|
||||||
|
@ -29,7 +29,7 @@ except KeyError:
|
|||||||
git_ssh = 'https://github.com/Xtao-Labs/PagerMaid-Modify.git'
|
git_ssh = 'https://github.com/Xtao-Labs/PagerMaid-Modify.git'
|
||||||
need_update_check = True
|
need_update_check = True
|
||||||
update_time = 86400
|
update_time = 86400
|
||||||
update_username = 'self'
|
update_username = 'PagerMaid_Modify_bot'
|
||||||
update_delete = True
|
update_delete = True
|
||||||
try:
|
try:
|
||||||
update_time = int(update_time)
|
update_time = int(update_time)
|
||||||
|
Loading…
Reference in New Issue
Block a user