Skip to content

Commit

Permalink
🚨 auto fix by pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 5, 2024
1 parent 11a84ae commit cc8f16c
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion magic/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .config import MagicConfig
from .utils import load_config
from .config import MagicConfig
from .path import BOT_DIR as BOT_DIR
from .path import LOG_DIR as LOG_DIR
from .path import RES_DIR as RES_DIR
Expand Down
3 changes: 1 addition & 2 deletions magic/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ class Config:

if TYPE_CHECKING:

def __getattr__(self, name: str) -> Any:
...
def __getattr__(self, name: str) -> Any: ...


class MagicConfig(BaseConfig):
Expand Down
16 changes: 12 additions & 4 deletions magic/plugins/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ async def add(
if admin_target.available:
if await user.filter(bind__uid=str(admin_target.result)).exists():
await user.filter(uid=admin_target.result).update(permission="ADMIN")
await Text(f"已成功增加 Bot管理员:{admin_target.result}").send(at_sender=True)
await Text(f"已成功增加 Bot管理员:{admin_target.result}").send(
at_sender=True
)

elif admin_target.result == 0:
...
Expand All @@ -142,7 +144,9 @@ async def add(
if helper_target.available:
if await user.filter(bind__uid=str(admin_target.result)).exists():
await user.filter(uid=helper_target.result).update(permission="HELPER")
await Text(f"已成功增加 Bot协助者:{helper_target.result}").send(at_sender=True)
await Text(f"已成功增加 Bot协助者:{helper_target.result}").send(
at_sender=True
)

elif helper_target.result == 0:
...
Expand All @@ -166,7 +170,9 @@ async def remove(
if admin_target.available:
if await user.filter(bind__uid=str(admin_target.result)).exists():
await user.filter(uid=admin_target.result).update(permission="NORMAL")
await Text(f"已取消 {admin_target.result} 的 Bot管理员 身份").send(at_sender=True)
await Text(f"已取消 {admin_target.result} 的 Bot管理员 身份").send(
at_sender=True
)

elif admin_target.result == 0:
...
Expand All @@ -177,7 +183,9 @@ async def remove(
if helper_target.available:
if await user.filter(bind__uid=str(admin_target.result)).exists():
await user.filter(uid=helper_target.result).update(permission="NORMAL")
await Text(f"已取消 {helper_target.result} 的 Bot协助者 身份").send(at_sender=True)
await Text(f"已取消 {helper_target.result} 的 Bot协助者 身份").send(
at_sender=True
)

elif helper_target.result == 0:
...
Expand Down
8 changes: 6 additions & 2 deletions magic/plugins/ban/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ async def add(
else:
minutes_result = 0
hours_result = hours.result
logger.info(f"封禁目标:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟")
logger.info(
f"封禁目标:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟"
)
await Ban.ban(uid, duration=convert_to_seconds(hours_result, minutes_result))
await Text(
f"已成功封禁用户:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟"
Expand Down Expand Up @@ -107,7 +109,9 @@ async def unban(
else:
minutes_result = 0
hours_result = hours.result
logger.info(f"封禁目标:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟")
logger.info(
f"封禁目标:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟"
)
await Ban.unban(uid)
await Text(
f"已成功封禁用户:{uid}({user_name}),时长:{hours_result}小时{minutes_result}分钟"
Expand Down
10 changes: 6 additions & 4 deletions magic/plugins/control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ async def _():
latest_version, update_time = await CheckUpdate.show_latest_version()
if latest_version and update_time:
if latest_version != __version__:
await Text(f"新版本已发布, 请更新\n最新版本: {latest_version} 更新时间: {update_time}").send(
at_sender=True
)
await Text(
f"新版本已发布, 请更新\n最新版本: {latest_version} 更新时间: {update_time}"
).send(at_sender=True)
else:
await Text("当前已是最新版本").send(at_sender=True)
await check_update_cmd.finish()
Expand All @@ -128,7 +128,9 @@ async def _(matcher: AlconnaMatcher, cmd: Match[tuple[str, ...]]):

@run_cmd.got_path(
"cmd",
prompt=UniMessage.template("{:At(user, $event.get_user_id())} 请输入你要运行的命令"),
prompt=UniMessage.template(
"{:At(user, $event.get_user_id())} 请输入你要运行的命令"
),
parameterless=[HandleCancellation("已取消")],
)
async def _(cmd: str):
Expand Down
4 changes: 3 additions & 1 deletion magic/plugins/control/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ async def remind():
"python3 bot.py"
)
os.system("chmod +x ./restart.sh")
logger.info("配置", "已自动生成 restart.sh 重启脚本,请检查脚本是否与本地指令符合..")
logger.info(
"配置", "已自动生成 restart.sh 重启脚本,请检查脚本是否与本地指令符合.."
)
6 changes: 4 additions & 2 deletions magic/plugins/help/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ async def statis_cmd_most(arp: Arparma):
sort = sorted(table.items(), key=lambda x: x[1], reverse=True)
sort = sort[: arp.query[int]("count")]
await statis_cmd.finish(
"以下按照命令使用频率排序\n" + "\n".join(f"[{k}] {v[0]}" for k, v in enumerate(sort))
"以下按照命令使用频率排序\n"
+ "\n".join(f"[{k}] {v[0]}" for k, v in enumerate(sort))
)


Expand All @@ -128,5 +129,6 @@ async def statis_cmd_least(arp: Arparma):
sort = sorted(table.items(), key=lambda x: x[1], reverse=False)
sort = sort[: arp.query[int]("count")]
await statis_cmd.finish(
"以下按照命令使用频率排序\n" + "\n".join(f"[{k}] {v[0]}" for k, v in enumerate(sort))
"以下按照命令使用频率排序\n"
+ "\n".join(f"[{k}] {v[0]}" for k, v in enumerate(sort))
)
1 change: 1 addition & 0 deletions magic/plugins/hooks/user_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
用来在处理事件前先判断用户是否存在
如果不存在则自动为其注册账号
"""

import inspect

from nonebot import require
Expand Down
4 changes: 3 additions & 1 deletion magic/plugins/sign/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ async def _(user: UserInfo):
if last_sign is not None and abs((date.today() - last_sign.date()).days) == 1:
continuous_days += 1
extra_coin = int(continuous_days * 1.5)
msg = f"你当前连续签到 {str(continuous_days)} 天,额外奖励 {extra_coin} 枚硬币。"
msg = (
f"你当前连续签到 {str(continuous_days)} 天,额外奖励 {extra_coin} 枚硬币。"
)
await User.reward(uid, reward={"coin": extra_coin})
await Sign.filter(uid=uid).update(continuous_days=F("continuous_days") + 1)
else:
Expand Down
5 changes: 4 additions & 1 deletion magic/plugins/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
Args["input_token?", str],
Option("-t|--token", Args["token?", str], help_text="生成token"),
Option(
"-l|--list", Args["target?", At], alias={"列表", "信息"}, help_text="查询绑定信息"
"-l|--list",
Args["target?", At],
alias={"列表", "信息"},
help_text="查询绑定信息",
),
Option("-r|--rebind", alias={"取消"}, help_text="取消绑定"),
meta=CommandMeta(
Expand Down
8 changes: 6 additions & 2 deletions magic/utils/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ async def download_file(
).content
async with aiofiles.open(path, "wb") as wf:
await wf.write(content)
logger.success("请求", f"下载 {url} 成功!Path:{path.absolute()}")
logger.success(
"请求", f"下载 {url} 成功!Path:{path.absolute()}"
)
return True
except (TimeoutError, ConnectTimeout):
pass
Expand Down Expand Up @@ -221,7 +223,9 @@ async def download_file(
else:
logger.error("请求", f"下载 {url} 下载超时!Path:{path.absolute()}")
except Exception as e:
logger.error("请求", f"下载 {url} 未知错误 {type(e)}{e} | Path:{path.absolute()}")
logger.error(
"请求", f"下载 {url} 未知错误 {type(e)}{e} | Path:{path.absolute()}"
)
return False

@classmethod
Expand Down
8 changes: 6 additions & 2 deletions magic/utils/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def update():
pyproject_new_content = pyproject_raw_content.replace(
raw_plugins_load.group(), "plugins = []"
)
logger.info("更新", f"检测到已安装插件:{raw_plugins_load.group()},暂时重置")
logger.info(
"更新", f"检测到已安装插件:{raw_plugins_load.group()},暂时重置"
)
else:
pyproject_new_content = pyproject_raw_content
pyproject_file.write_text(pyproject_new_content, encoding="utf-8")
Expand All @@ -64,7 +66,9 @@ def update():
"plugins = []", raw_plugins_load.group()
)
pyproject_file.write_text(pyproject_new_content, encoding="utf-8")
logger.info("更新", f"更新结束,还原插件:{raw_plugins_load.group()}")
logger.info(
"更新", f"更新结束,还原插件:{raw_plugins_load.group()}"
)
return msg
else:
msg = f"更新失败,错误信息:{e.stderr},请尝试手动进行更新"
Expand Down

0 comments on commit cc8f16c

Please sign in to comment.