🐛 Change the default location of update notifications and fix some bugs. (#137)

️ 修改更新通知默认位置
🐛 批量修复错误
This commit is contained in:
Xtao_dada 2021-10-09 21:55:28 +08:00 committed by GitHub
parent 526ec8cf17
commit cfb45e4724
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 44 deletions

View File

@ -68,7 +68,7 @@ git_ssh: "https://github.com/Xtao-Labs/PagerMaid-Modify.git"
# Update Notice
update_check: "True"
update_time: "86400"
update_username: "self"
update_username: "PagerMaid_Modify_bot"
update_delete: "True"
# ipv6

View File

@ -84,6 +84,11 @@ block_des: 拉黑一個用戶
block_process: 正在拉黑中 . . .
block_success: 成功拉黑
block_exist: 已存在黑名單中。
# unblock
unblock_des: 取消拉黑一個用戶
unblock_process: 正在取消拉黑中 . . .
unblock_success: 成功取消拉黑
unblock_exist: 不存在黑名單中。
# avoid
# ghost

View File

@ -68,7 +68,7 @@ git_ssh: "https://github.com/Xtao-Labs/PagerMaid-Modify.git"
# Update Notice
update_check: "True"
update_time: "86400"
update_username: "self"
update_username: "PagerMaid_Modify_bot"
update_delete: "True"
# ipv6

View File

@ -1,11 +1,7 @@
""" Pulls in the new version of PagerMaid from the git server. """
import platform
import requests
import time
from datetime import datetime
from distutils.util import strtobool
from json import JSONDecodeError
from os import remove
from subprocess import run, PIPE
from sys import executable
@ -13,45 +9,10 @@ from sys import executable
from git import Repo
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError
from pagermaid import log, config, proxies
from pagermaid import log
from pagermaid.listener import listener
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"),
description=lang('update_des'),

View File

@ -38,6 +38,7 @@ def listener(**args):
is_plugin = args.get('is_plugin', True)
owners_only = args.get("owners_only", False)
admins_only = args.get("admins_only", False)
groups_only = args.get("groups_only", False)
if command is not None:
if command in help_messages:
raise ValueError(f"{lang('error_prefix')} {lang('command')} \"{command}\" {lang('has_reg')}")
@ -64,6 +65,8 @@ def listener(**args):
del args['owners_only']
if 'admins_only' in args:
del args['admins_only']
if 'groups_only' in args:
del args['groups_only']
def decorator(function):
@ -79,6 +82,10 @@ def listener(**args):
if admins_only:
if not (await admin_check(context)):
return
# groups only
if groups_only:
if not context.is_group:
return
try:
analytic = True
try:

View File

@ -154,7 +154,8 @@ async def flip(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'),
parameters="<username> <username>")
async def ship(context):

View File

@ -29,7 +29,7 @@ except KeyError:
git_ssh = 'https://github.com/Xtao-Labs/PagerMaid-Modify.git'
need_update_check = True
update_time = 86400
update_username = 'self'
update_username = 'PagerMaid_Modify_bot'
update_delete = True
try:
update_time = int(update_time)