Skip to content

Commit

Permalink
0.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Feb 10, 2023
1 parent 5d31684 commit 337145c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
35 changes: 26 additions & 9 deletions app/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
from graia.ariadne.model import Friend, Member, Group, MemberPerm
from graia.ariadne.message.chain import MessageChain
from graia.ariadne.message.element import At, Plain
from graia.ariadne.event.message import MessageEvent
from graia.ariadne.event import MiraiEvent
from graia.ariadne.event.message import MessageEvent, GroupMessage
from graia.ariadne.app import Ariadne
from datetime import datetime
from app import DataInstance
import random


def require_admin(only: bool = False, __record: Any = None):
Expand All @@ -27,17 +31,12 @@ async def __wrapper__(
interface.data.cache.pop("$admin", None)
return True
if not only and (
(
isinstance(target, Member)
and target.permission in (MemberPerm.Administrator, MemberPerm.Owner)
)
(isinstance(target, Member) and target.permission in (MemberPerm.Administrator, MemberPerm.Owner))
or target.id in interface.config.admin.admins
):
interface.data.cache.pop("$admin", None)
return True
text = (
"权限不足!" if isinstance(sender, Friend) else [At(target.id), Plain("\n权限不足!")]
)
text = "权限不足!" if isinstance(sender, Friend) else [At(target.id), Plain("\n权限不足!")]
logger.debug(f"permission denied for {sender.id} in {__record}")
if id_ not in cache:
cache.clear()
Expand Down Expand Up @@ -70,6 +69,7 @@ def __wrapper__(app: Ariadne, sender: Union[Friend, Group]):
def check_disabled(path: str):
def __wrapper__(app: Ariadne):
from .core import RaianBotInterface

config = app.launch_manager.get_interface(RaianBotInterface).config
if path in config.disabled:
raise ExecutionStop
Expand All @@ -79,12 +79,29 @@ def __wrapper__(app: Ariadne):


def check_exclusive():
def __wrapper__(app: Ariadne, target: Union[Friend, Member]):
def __wrapper__(app: Ariadne, target: Union[Friend, Member], event: MiraiEvent):
from .core import RaianBotInterface

interface = app.launch_manager.get_interface(RaianBotInterface)

if target.id in interface.base_config.bots:
raise ExecutionStop

if isinstance(event, GroupMessage) and len(interface.base_config.bots) > 1:
seed = int(event.source.id + datetime.now().timestamp())
bots = {k : v for k, v in DataInstance.get().items() if v.exist(event.sender.group.id)}
if len(bots) > 1:
default = DataInstance.get()[interface.base_config.default_account]
excl = default.cache.setdefault("$exclusive", {})
if str(event.source.id) not in excl:
excl.clear()
rand = random.Random()
rand.seed(seed)
choice = rand.choice(list(bots.keys()))
excl[str(event.source.id)] = choice
if excl[str(event.source.id)] != app.account:
raise ExecutionStop

return True

return Depend(__wrapper__)
2 changes: 1 addition & 1 deletion plugins/admin/announcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ async def announcement(
await app.send_friend_message(
friend, MessageChain(f"{group.id} 的公告发送失败\n{err}")
)
await asyncio.sleep(random.uniform(2, 3))
await asyncio.sleep(random.uniform(5, 7))
tt = time.time()
await app.send_friend_message(friend, MessageChain(f"群发已完成,耗时 {tt - ft:.6f} 秒"))
2 changes: 2 additions & 0 deletions plugins/gacha.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async def gacha_(app: Ariadne, sender: Sender, target: Target, count: Match[int]
else:
guser = GachaUser()
data = gacha.gacha_with_img(guser, count_)
await app.send_message(sender, "您未签到,抽卡水位是继承不了的说")
return await app.send_message(sender, MessageChain(Image(data_bytes=data)))


Expand All @@ -93,6 +94,7 @@ async def simulate(app: Ariadne, sender: Sender, target: Target, interface: Raia
guser = GachaUser()
ops = gacha.gacha(guser, 10)
data = await simulate_image(ops[0])
await app.send_message(sender, "您未签到,抽卡水位是继承不了的说")
return await app.send_message(sender, MessageChain(Image(data_bytes=data)))


Expand Down
3 changes: 3 additions & 0 deletions plugins/query_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
***请在浏览器中获取token,避免在QQ打开的网页中获取,否则可能获取无效token***
再通过 ’渊白抽卡查询 绑定 token‘ 命令来绑定
""",
),
)
Expand Down Expand Up @@ -59,6 +60,8 @@ async def query(app: Ariadne, target: Target, sender: Sender, count: Match[int])
B服:https://web-api.hypergryph.com/account/info/ak-b
请在浏览器中获取token,避免在QQ打开的网页中获取,否则可能获取无效token
再通过 ’渊白抽卡查询 绑定 token‘ 命令来绑定
""",
)
try:
Expand Down
2 changes: 2 additions & 0 deletions plugins/wecd.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ async def draw(app: Ariadne, sender: Sender, arp: Arparma):
f"{await trans.trans(f'''{start}{count['num']}{count['unit']}''', 'en')}"
)
if arp.components.get("gif"):
if int(count["num"]) > 60:
return await app.send_message(sender, "这个数字太大了!")
data = gen_gif(content, start, int(count["num"]), count["unit"], en)
return await app.send_message(sender, MessageChain(Image(data_bytes=data)))
img = gen_counting_down(content, start, int(count["num"]), count["unit"], en)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ aiohttp==3.8.3
aiosignal==1.2.0
anyio==3.6.1
arclet-alconna==1.5.6
arclet-alconna-ariadne==0.11.6
arclet-alconna-graia==0.11.6
arclet-alconna-ariadne==0.11.7
arclet-alconna-graia==0.11.7
arclet-alconna-tools==0.4.0
arknights-toolkit==0.4.3
asttokens==2.0.8
Expand Down

0 comments on commit 337145c

Please sign in to comment.