Skip to content

Commit

Permalink
fix 0.19.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Feb 9, 2023
1 parent 53066cb commit 20652fe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
10 changes: 6 additions & 4 deletions plugins/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from graia.ariadne.model import Friend
from graia.ariadne.util.cooldown import CoolDown
from graia.broadcast.exceptions import PropagationCancelled
from graiax.shortcut.saya import dispatch, listen, priority
from graiax.shortcut.saya import listen, priority
from library.aiml.entry import AIML
from library.chat import TencentChatBot
from library.rand import random_pick_small
Expand All @@ -24,7 +24,7 @@
from plugins.config.dialog import DialogConfig

bot = RaianBotService.current()

cd = CoolDown(0.1)
json_filename = "assets/data/dialog_templates.json"
with open(json_filename, "r", encoding="UTF-8") as f_obj:
dialog_templates = ujson.load(f_obj)["templates"]
Expand Down Expand Up @@ -204,7 +204,6 @@ async def ematch(app: Ariadne, target: Target, sender: Sender, message: MessageC


@listen(GroupMessage, FriendMessage)
@dispatch(CoolDown(0.1))
@priority(22)
@record("ai")
@exclusive
Expand All @@ -218,6 +217,9 @@ async def aitalk(app: Ariadne, target: Target, sender: Sender, message: MessageC
for n in cmds:
if re.search(f".*{n}.*", str(message)):
raise PropagationCancelled
async with cd.trigger(sender.id, int) as res:
if not res[1]:
return
if isinstance(target, Friend):
reply = await random_ai(
app, sender, target, str(message.include(Plain, Face)).strip(" +")[:120], gpt=0.5, tx=0.4
Expand All @@ -234,7 +236,7 @@ async def aitalk(app: Ariadne, target: Target, sender: Sender, message: MessageC
if reply:
await app.send_message(sender, reply, quote=False if isinstance(target, Friend) else source)
return
for elem in bot.config.command_prefix:
for elem in bot.config.command.headers:
message = message.replace(elem, "")
if random.randint(0, 2000) == datetime.now().microsecond // 5000:
reply = await random_ai(
Expand Down
7 changes: 4 additions & 3 deletions plugins/gacha.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
bot = RaianBotService.current()
config = bot.config.plugin.get(GachaConfig)
gacha = ArknightsGacha(config.file)

cd = CoolDown(config.cooldown)

class arkgacha_proba(NamedTuple):
six_statis: int
Expand Down Expand Up @@ -73,13 +73,14 @@ async def gacha_(app: Ariadne, sender: Sender, target: Target, count: Match[int]


@alcommand(Alconna("十连", meta=CommandMeta("生成仿真寻访图", usage="灰色头像表示新干员但是头图未更新")))
#@dispatch(CoolDown(config.cooldown))
@record("抽卡")
@exclusive
@accessable
async def simulate(app: Ariadne, sender: Sender, target: Target, interface: RaianBotInterface):
from arknights_toolkit.gacha import simulate_image

async with cd.trigger(target.id, int) as res:
if not res[1]:
return
if interface.data.exist(target.id):
user = interface.data.get_user(target.id)
proba = user.get(arkgacha_proba, arkgacha_proba(0, 2))
Expand Down
1 change: 0 additions & 1 deletion plugins/genshin_characard.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ async def init():

@alcommand(cmd, send_error=True)
@record("原神角色卡查询")
@dispatch(CoolDown(5))
@exclusive
@accessable
async def genshin_chara_card(app: Ariadne, sender: Sender, source: Source, uid: Match[str], name: Match[str]):
Expand Down
8 changes: 8 additions & 0 deletions plugins/nudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from graia.ariadne.event.mirai import NudgeEvent
from graia.ariadne.model import Group, Member
from graia.ariadne.app import Ariadne
from graia.ariadne.util.cooldown import CoolDown
from graiax.shortcut.saya import listen

from app import RaianBotInterface, record, accessable, exclusive
Expand All @@ -19,6 +20,7 @@
)

pet = PetGenerator("assets/image/rua")
cd = CoolDown(1)


@alcommand(rua, private=False)
Expand All @@ -44,6 +46,12 @@ async def draw(
async def draw(app: Ariadne, event: NudgeEvent, bot: RaianBotInterface):
if event.supplicant in bot.base_config.bots or event.target != bot.config.account:
return
async with cd.trigger(event.group_id or event.friend_id, int) as res:
if not res[1]:
if event.group_id:
return await app.send_group_message(event.group_id, "戳太快了!")
else:
return await app.send_friend_message(event.friend_id, "戳太快了!")
async with app.service.client_session.get(
f"https://q1.qlogo.cn/g?b=qq&nk={event.supplicant}&s=640"
) as resp:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ imageio-ffmpeg==0.4.7
importlib-metadata==4.12.0
Jinja2==3.1.2
kiwisolver==1.4.4
launart==0.6.2
launart==0.6.3
linkify-it-py==1.0.3
loguru==0.6.0
lxml==4.9.1
Expand Down

0 comments on commit 20652fe

Please sign in to comment.