Skip to content

Commit

Permalink
style: format code with Autopep8
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in eb21926 according to the output
from Autopep8.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Jan 9, 2024
1 parent eb21926 commit 7fc2ae0
Show file tree
Hide file tree
Showing 34 changed files with 519 additions and 448 deletions.
3 changes: 1 addition & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11Adapter



nonebot.init()

driver = nonebot.get_driver()
Expand All @@ -12,4 +11,4 @@
nonebot.load_from_toml("pyproject.toml")

if __name__ == "__main__":
nonebot.run()
nonebot.run()
2 changes: 1 addition & 1 deletion src/plugins/cave/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def url_to_base64(image_url):
response = requests.get(image_url,timeout=5)
response = requests.get(image_url, timeout=5)
image_data = response.content
return base64.b64encode(image_data).decode("utf-8")

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/ddcheck/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .data_source import get_reply
from .config import Config
import traceback
from typing import Union

Expand All @@ -17,8 +19,6 @@
require("nonebot_plugin_htmlrender")
require("nonebot_plugin_localstore")

from .config import Config
from .data_source import get_reply

__plugin_meta__ = PluginMetadata(
name="成分姬",
Expand Down Expand Up @@ -61,4 +61,4 @@ async def _(
elif isinstance(bot, V12Bot):
resp = await bot.upload_file(type="data", name="ddcheck", data=result)
file_id = resp["file_id"]
await matcher.finish(V12MsgSeg.image(file_id))
await matcher.finish(V12MsgSeg.image(file_id))
3 changes: 2 additions & 1 deletion src/plugins/ddcheck/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ async def get_reply(name: str) -> Union[str, bytes]:

vtbs_num = len(vtbs)
percent = vtbs_num / follows_num * 100 if follows_num else 0
num_per_col = math.ceil(vtbs_num / math.ceil(vtbs_num / 100)) if vtbs_num else 1
num_per_col = math.ceil(
vtbs_num / math.ceil(vtbs_num / 100)) if vtbs_num else 1
result = {
"name": user_info["name"],
"uid": user_info["mid"],
Expand Down
41 changes: 26 additions & 15 deletions src/plugins/ncm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ async def song_is_open(event: Union[GroupMessageEvent, PrivateMessageEvent]) ->
if isinstance(event, GroupMessageEvent):
if info := setting.search(Q["group_id"] == event.group_id):
return info[0]["song"]
setting.insert({"group_id": event.group_id, "song": False, "list": False})
setting.insert({"group_id": event.group_id,
"song": False, "list": False})
return False
elif isinstance(event, PrivateMessageEvent):
if info := setting.search(Q["user_id"] == event.user_id):
Expand All @@ -57,7 +58,8 @@ async def playlist_is_open(event: Union[GroupMessageEvent, PrivateMessageEvent])
if isinstance(event, GroupMessageEvent):
if info := setting.search(Q["group_id"] == event.group_id):
return info[0]["list"]
setting.insert({"group_id": event.group_id, "song": False, "list": False})
setting.insert({"group_id": event.group_id,
"song": False, "list": False})
return False
elif isinstance(event, PrivateMessageEvent):
if info := setting.search(Q["user_id"] == event.user_id):
Expand Down Expand Up @@ -89,14 +91,14 @@ async def music_reply_rule(event: Union[GroupMessageEvent, PrivateMessageEvent])
block=False)
'''功能设置'''
music_regex = on_regex("(song|url)\?id=([0-9]+)(|&)",
block=False)
block=False)
'''歌曲id识别'''
playlist_regex = on_regex("playlist\?id=([0-9]+)&",
block=False)
block=False)
'''歌单识别'''
music_reply = on_message(
rule=Rule(music_reply_rule),
block=False)
rule=Rule(music_reply_rule),
block=False)
'''回复下载'''
search = on_command("点歌",
rule=Rule(check_search), block=False)
Expand Down Expand Up @@ -187,7 +189,8 @@ async def music_reply_receive(bot: Bot, event: Union[GroupMessageEvent, PrivateM
@ncm_set.handle()
async def set_receive(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEvent],
args: Message = CommandArg()): # 功能设置接收
logger.debug(f"权限为{event.sender.role}的用户<{event.sender.nickname}>尝试使用命令{cmd}ncm {args}")
logger.debug(
f"权限为{event.sender.role}的用户<{event.sender.nickname}>尝试使用命令{cmd}ncm {args}")
if args:
args = str(args).split()
if len(args) == 1:
Expand All @@ -197,19 +200,23 @@ async def set_receive(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEv
if mold in TRUE:
info[0]["song"] = True
info[0]["list"] = True
setting.update(info[0], Q["group_id"] == event.group_id)
setting.update(
info[0], Q["group_id"] == event.group_id)
await bot.send(event=event, message=Message(MessageSegment.text("已开启自动下载功能")))
elif mold in FALSE:
info[0]["song"] = False
info[0]["list"] = False
setting.update(info[0], Q["group_id"] == event.group_id)
setting.update(
info[0], Q["group_id"] == event.group_id)
msg = "已关闭自动下载功能"
await bot.send(event=event, message=Message(MessageSegment.text(msg)))
logger.debug(f"用户<{event.sender.nickname}>执行操作成功")
elif mold in TRUE:
setting.insert({"group_id": event.group_id, "song": True, "list": True})
setting.insert({"group_id": event.group_id,
"song": True, "list": True})
elif mold in FALSE:
setting.insert({"group_id": event.group_id, "song": False, "list": False})
setting.insert({"group_id": event.group_id,
"song": False, "list": False})
elif isinstance(event, PrivateMessageEvent):
if info := setting.search(Q["user_id"] == event.user_id):
if mold in TRUE:
Expand All @@ -225,9 +232,11 @@ async def set_receive(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEv
await bot.send(event=event, message=Message(MessageSegment.text(msg)))
logger.debug(f"用户<{event.sender.nickname}>执行操作成功")
elif mold in TRUE:
setting.insert({"user_id": event.user_id, "song": True, "list": True})
setting.insert({"user_id": event.user_id,
"song": True, "list": True})
elif mold in FALSE:
setting.insert({"user_id": event.user_id, "song": False, "list": False})
setting.insert({"user_id": event.user_id,
"song": False, "list": False})
elif len(args) == 2 and args[0] == "search":
mold = args[1]
if info := setting.search(Q["global"] == "search"):
Expand Down Expand Up @@ -263,9 +272,11 @@ async def set_receive(bot: Bot, event: Union[GroupMessageEvent, PrivateMessageEv
await bot.send(event=event, message=Message(MessageSegment.text(msg)))
logger.debug(f"用户<{event.sender.nickname}>执行操作成功")
elif mold in TRUE:
setting.insert({"user_id": event.user_id, "song": True, "list": True})
setting.insert({"user_id": event.user_id,
"song": True, "list": True})
elif mold in FALSE:
setting.insert({"user_id": event.user_id, "song": False, "list": False})
setting.insert({"user_id": event.user_id,
"song": False, "list": False})
else:
msg = f"{cmd}ncm:获取命令菜单\r\n说明:网易云歌曲分享到群内后回复机器人即可下载\r\n" \
f"{cmd}ncm t:开启解析\r\n{cmd}ncm f:关闭解析\n{cmd}点歌 歌名:点歌"
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/ncm/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def get_phone_login(self):
)
if verified.get("code", 0) == 200:
break
result = self.api.login.LoginViaCellphone(phone, captcha=captcha, ctcode=ctcode)
result = self.api.login.LoginViaCellphone(
phone, captcha=captcha, ctcode=ctcode)
self.get_user_info()

def get_qrcode(self):
Expand Down Expand Up @@ -154,7 +155,8 @@ def get_qrcode(self):
def detail(self, ids: list) -> list:
songs: list = self.api.track.GetTrackDetail(song_ids=ids)["songs"]
return [
(data["name"] + "-" + ",".join([names["name"] for names in data["ar"]]))
(data["name"] + "-" + ",".join([names["name"]
for names in data["ar"]]))
for data in songs
]

Expand All @@ -175,7 +177,8 @@ async def search_song(self, keyword: str, limit: int = 1) -> int: # 搜索歌
return data[0]["id"]

async def search_user(self, keyword: str, limit: int = 1): # 搜索用户
self.api.cloudsearch.GetSearchResult(keyword=keyword, stype=USER, limit=limit)
self.api.cloudsearch.GetSearchResult(
keyword=keyword, stype=USER, limit=limit)

async def search_playlist(self, keyword: str, limit: int = 1): # 搜索歌单
self.api.cloudsearch.GetSearchResult(
Expand Down
Loading

0 comments on commit 7fc2ae0

Please sign in to comment.