Skip to content

Commit

Permalink
🚨 自动进行代码格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Feb 3, 2022
1 parent 110c36b commit 9a4200d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
1 change: 0 additions & 1 deletion ATRI/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class Setu:
"command_start": BotSelfConfig.command_start,
"command_sep": BotSelfConfig.command_sep,
"session_expire_timeout": BotSelfConfig.session_expire_timeout,

"gocq_accounts": InlineGoCQHTTP.accounts,
"gocq_version": InlineGoCQHTTP.download_version,
}
30 changes: 19 additions & 11 deletions ATRI/plugins/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class BroadCast(Service):
def __init__(self):
Service.__init__(self, "广播", "向bot所在的所有群发送信息", True, to_bot())

@staticmethod
def load_rej_list() -> list:
data = list()
Expand All @@ -41,20 +41,22 @@ def load_rej_list() -> list:
with open(path, "w", encoding="utf-8") as w:
w.write(json.dumps(data))
return data

return json.loads(path.read_bytes())

@classmethod
def store_rej_list(cls, data: list):
path = BC_PATH/ "rej_list.json"
path = BC_PATH / "rej_list.json"
if not path.is_file():
cls.load_rej_list()

with open(path, "w", encoding="utf-8") as w:
w.write(json.dumps(data))


caster = BroadCast().on_command("广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"/bc","bc"}, permission=SUPERUSER)
caster = BroadCast().on_command(
"广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"/bc", "bc"}, permission=SUPERUSER
)


@caster.handle()
Expand All @@ -81,20 +83,22 @@ async def _(bot: Bot, event: MessageEvent, s_msg: str = ArgPlainText("bc_msg")):
su_g.append(group_id)
except:
fl_g.append(group_id)

await asyncio.sleep(random.randint(2, 3))

repo_msg = _BROADCAST_BACK.format(
msg=s_msg,
len_g=len(w_group),
su_g=su_g,
fl_g=fl_g,
f_g="、".join(map(str, fl_g))
f_g="、".join(map(str, fl_g)),
)
await caster.finish(repo_msg)


rej_broadcast = BroadCast().on_command("拒绝广播", "拒绝来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN)
rej_broadcast = BroadCast().on_command(
"拒绝广播", "拒绝来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN
)


@rej_broadcast.handle()
Expand All @@ -109,12 +113,15 @@ async def _(bot: Bot, event: GroupMessageEvent):
BroadCast().store_rej_list(rej_g)
await rej_broadcast.finish("完成~!已将本群列入推送黑名单")


@rej_broadcast.handle()
async def _(event: PrivateMessageEvent):
await rej_broadcast.finish("该功能仅在群聊中触发...")


acc_broadcast = BroadCast().on_command("接受广播", "接受来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN)
acc_broadcast = BroadCast().on_command(
"接受广播", "接受来自开发者的广播推送", permission=GROUP_OWNER | GROUP_ADMIN
)


@acc_broadcast.handle()
Expand All @@ -129,6 +136,7 @@ async def _(bot: Bot, event: GroupMessageEvent):
else:
await rej_broadcast.finish("本群不在推送黑名单里呢...")


@acc_broadcast.handle()
async def _(event: PrivateMessageEvent):
await rej_broadcast.finish("该功能仅在群聊中触发...")
8 changes: 5 additions & 3 deletions ATRI/plugins/essential.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
GroupRecallNoticeEvent,
FriendRecallNoticeEvent,
MessageSegment,
Message
Message,
)

import ATRI
Expand Down Expand Up @@ -302,7 +302,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent):
repo = await bot.get_msg(message_id=event.message_id)
except BaseException:
return

user = event.user_id
repo: dict = repo["message"]

Expand All @@ -315,6 +315,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent):

rej_recall = Essential().on_command("拒绝撤回", "拒绝撤回信息", permission=SUPERUSER)


@rej_recall.handle()
async def _():
global _acc_recall
Expand All @@ -324,6 +325,7 @@ async def _():

acc_recall = Essential().on_command("接受撤回", "接受撤回信息", permission=SUPERUSER)


@acc_recall.handle()
async def _():
global _acc_recall
Expand All @@ -349,7 +351,7 @@ def recall_msg_dealer(msg: dict) -> str:
if _type == "text":
temp_m.append(_data["text"])
elif _type == "image":
url = _data["url"]
url = _data["url"]
check = MessageChecker(url).check_image_url
if check:
temp_m.append(MessageSegment.image(url))
Expand Down
12 changes: 8 additions & 4 deletions ATRI/plugins/setu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@


@random_setu.handle()
async def _random_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()):
async def _random_setu(
bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
):
user_id = event.get_user_id()
if not _setu_flmt.check(user_id):
await random_setu.finish()
Expand All @@ -49,6 +51,7 @@ async def _random_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Me
if msg:
matcher.set_arg("r_rush_after_think", args)


@random_setu.got("r_rush_after_think")
async def _(think: str = ArgPlainText("r_rush_after_think")):
is_repo = will_think(think)
Expand All @@ -58,12 +61,13 @@ async def _(think: str = ArgPlainText("r_rush_after_think")):
await random_setu.finish(is_repo)



tag_setu = Setu().on_regex(r"来[张点丶份](.*?)的[涩色🐍]图", "根据提供的tag查找涩图")


@tag_setu.handle()
async def _tag_setu(bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()):
async def _tag_setu(
bot: Bot, event: MessageEvent, matcher: Matcher, args: Message = CommandArg()
):
user_id = event.get_user_id()
if not _setu_flmt.check(user_id):
await random_setu.finish()
Expand Down Expand Up @@ -247,7 +251,7 @@ async def _scheduler_setu(bot):
def will_think(msg: str) -> str:
if msg in _ag_l:
return str()

ag_jud = re.findall(_ag_patt, msg)
if ag_jud:
return str()
Expand Down
5 changes: 3 additions & 2 deletions ATRI/plugins/setu/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


LOLICON_URL = "https://api.lolicon.app/setu/v2"
DEFAULT_SETU = "https://i.pixiv.cat/img-original/img/2021/02/28/22/44/49/88124144_p0.jpg"

DEFAULT_SETU = (
"https://i.pixiv.cat/img-original/img/2021/02/28/22/44/49/88124144_p0.jpg"
)


class Setu(Service):
Expand Down
2 changes: 1 addition & 1 deletion ATRI/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def check_cq_code(self) -> bool:
return True
else:
return True

@property
def check_image_url(self) -> bool:
if self.tenc_gchat_url not in self.text:
Expand Down

0 comments on commit 9a4200d

Please sign in to comment.