Skip to content

Commit

Permalink
💥 thirteenth step
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Nov 24, 2023
1 parent fc7e36e commit 6a9585d
Show file tree
Hide file tree
Showing 67 changed files with 1,116 additions and 1,574 deletions.
60 changes: 33 additions & 27 deletions app/control.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

import random
from datetime import datetime
from typing import Any

from avilla.core import Context
from avilla.core.account import BaseAccount
from avilla.core.elements import Notice, Text
from avilla.core.event import AvillaEvent
from avilla.elizabeth.account import ElizabethAccount
from avilla.standard.core.message import MessageReceived
from avilla.standard.core.privilege import Privilege
from graia.broadcast.builtin.decorators import Depend
from graia.broadcast.exceptions import ExecutionStop
Expand Down Expand Up @@ -85,30 +88,33 @@ def __wrapper__(serv: RaianBotService, bot: BotConfig):
return Depend(__wrapper__)


# def check_exclusive():
# 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__)
def check_exclusive():
async def __wrapper__(interface: DispatcherInterface[AvillaEvent], serv: RaianBotService, ctx: Context):
if ctx.scene.follows("::friend") or ctx.scene.follows("::guild.user"):
return True
event = interface.event
if isinstance(event, MessageReceived) and len(serv.config.bots) > 1:
seed = datetime.now().timestamp()
async with serv.db.get_session() as session:
group = (
await session.scalars(
select(Group)
.where(Group.id == ctx.scene.last_key)
.where(Group.platform == "qq" if isinstance(ctx.account, ElizabethAccount) else "qqapi")
)
).one_or_none()
if not group or len(group.accounts) < 2:
return True
excl = serv.cache.setdefault("$exclusive", {})
if event.message.to_selector() not in excl:
excl.clear()
rand = random.Random()
rand.seed(seed)
choice = rand.choice(group.accounts)
excl[event.message.id] = choice
if not ctx.account.route.follows(excl[event.message.to_selector()]):
raise ExecutionStop

return True

return Depend(__wrapper__)
5 changes: 5 additions & 0 deletions app/database/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class Group(Base):
id: Mapped[str] = mapped_column(String(128), primary_key=True)
"""群组 ID"""

platform: Mapped[str] = mapped_column(String(128), nullable=False)
"""对应平台"""

accounts: Mapped[list[str]] = mapped_column(JSON, nullable=False, default=[])

in_blacklist: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
"""是否在黑名单中"""

Expand Down
10 changes: 5 additions & 5 deletions app/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from avilla.qqapi.resource import QQAPIImageResource
from graia.saya.factory import ensure_buffer

from .control import check_disabled, require_account, require_admin, require_function
from .control import check_disabled, check_exclusive, require_account, require_admin, require_function
from .core import RaianBotService

T_Callable = TypeVar("T_Callable", bound=Callable)
Expand Down Expand Up @@ -80,7 +80,7 @@ def wrapper(func: T_Callable) -> T_Callable:
return wrapper


# def exclusive(func: T_Callable) -> T_Callable:
# buffer = ensure_buffer(func)
# buffer.setdefault("decorators", []).append(check_exclusive())
# return func
def exclusive(func: T_Callable) -> T_Callable:
buffer = ensure_buffer(func)
buffer.setdefault("decorators", []).append(check_exclusive())
return func
202 changes: 93 additions & 109 deletions assets/data/dialog_templates.json
Original file line number Diff line number Diff line change
@@ -1,112 +1,96 @@
{
"templates": {
"default": [
"\"感染者的每个日出都伴随着死亡\",但我相信,终有一日。。。",
"博士,现在可不是休息的时候",
"泰拉大地如此广阔,可是给感染者的天地,却是如此渺小。。",
"很多人认为感染者受歧视是因为矿石病。可是,没有了源石的这片大地,不公依然会存在",
"博士,有些事情,越是隐藏在自己心里,会越难受的",
"博士,我们是有能力去改变这片大地对感染者的不公,对吧。。。",
"我们一生都在飞翔,有谁想过,自己最后会停在哪儿吗?",
"“即使是冻土,也会开出小小的花。”",
"“没有谁,是不能没有另一个人的。”",
"“如果这片大地不准我放下武器,那我只能拿起剑奋斗,直到末日!”",
"博士,如果累了的话就休息一会儿吧。",
"我很担心...担心有一天,博士会突然离开...如果将来真的有这么一天,能答应我吗博士,至少...至少跟我们说一声道别...",
"我的故乡在很远的地方,很远很远的一片松林。许久的流浪已经使我记不太清了家乡的样子了。。。博士,如果有机会,你愿意跟我回故乡看看吗?",
"博士,我做了一些我们家乡的特色菜肴,要来尝尝吗?"
],
"content": {
"亲亲": [
"亲亲(づ ̄ 3 ̄)づ~",
"不要!你走开!",
"博士,阿米娅在一旁哦",
"博士,凯尔希在一旁哦",
"亲一下就够了哦~",
"#voice^jp$やだー"
],
"贴贴": [
"贴贴😘!",
"不贴!不贴!peach!🍑",
"博士请您稍微克制一点",
"博士,阿米娅在一旁哦",
"博士,凯尔希在一旁哦",
"不要靠这么近嘛~",
"#voice^jp$やだー"
],
"抱抱": [
"抱抱博士\\( ̄︶ ̄*\\))",
"为什么突然抱过来啊喂",
"只能抱一小会哦",
"不要闹啦",
"#voice^jp$やだー"
],
"摸摸": [
"博士也给你摸摸~ヾ(≧▽≦*)o",
"别摸那里啊喂",
"呦西呦西",
"#voice^jp$yoshi、yoshi。"
],
"(笨蛋|傻逼|sb)": [
"八嘎,hentai,无路赛!",
"#voice^jp$バカ、ヘンタイ、ウルサイ!",
"我不笨!你才笨"
],
"(爬|爪巴)": [
"我不爬,您爬",
"你爪巴!",
"#voice^jp$君はひどい!"
],
"(去死|死妈|滚开)": [
"滚!我不想看到你!",
"#voice^jp$君はひどい!"
],
"废物": [
"可笑,谁废啊"
],
"脑子有毛病": [
"你才有毛病吧?"
],
"揍你": [
"你很欠揍欸"
],
"色图": [
"我这里没有!不要找我了!",
"我不是涩涩bot啊喂",
"#voice^jp$Hじゃだ~め"
],
"(透透|让我透)": [
"讨厌你!(╯‵□′)╯︵┻━┻"
],
"单推": [
"阿里嘎多!"
],
"嗦.+?牛子": [
"変態! 大変態!",
"#voice^jp$変態! 大変態!",
"就你?"
],
"击剑": [
"老娘是女的!",
"找南铜去,别找我"
],
"(你)?在哪.*?" : [
"#voice$kokodayo.silk"
],
".*结婚": [
"#image^cover$marry.png"
],
"你的档案": [
"#image$dashboard.png",
"#image$document.png"
],
"(你的)?主人是谁": [
"是RF",
""
],
"(RF(是谁)?|谁是RF)": [
"是我的父母~"
]
}
"default": [
"\"感染者的每个日出都伴随着死亡\",但我相信,终有一日。。。",
"博士,现在可不是休息的时候",
"泰拉大地如此广阔,可是给感染者的天地,却是如此渺小。。",
"很多人认为感染者受歧视是因为矿石病。可是,没有了源石的这片大地,不公依然会存在",
"博士,有些事情,越是隐藏在自己心里,会越难受的",
"博士,我们是有能力去改变这片大地对感染者的不公,对吧。。。",
"我们一生都在飞翔,有谁想过,自己最后会停在哪儿吗?",
"“即使是冻土,也会开出小小的花。”",
"“没有谁,是不能没有另一个人的。”",
"“如果这片大地不准我放下武器,那我只能拿起剑奋斗,直到末日!”",
"博士,如果累了的话就休息一会儿吧。",
"我很担心...担心有一天,博士会突然离开...如果将来真的有这么一天,能答应我吗博士,至少...至少跟我们说一声道别...",
"我的故乡在很远的地方,很远很远的一片松林。许久的流浪已经使我记不太清了家乡的样子了。。。博士,如果有机会,你愿意跟我回故乡看看吗?",
"博士,我做了一些我们家乡的特色菜肴,要来尝尝吗?"
],
"content": {
"亲亲": [
"亲亲(づ ̄ 3 ̄)づ~",
"不要!你走开!",
"博士,阿米娅在一旁哦",
"博士,凯尔希在一旁哦",
"亲一下就够了哦~"
],
"贴贴": [
"贴贴😘!",
"不贴!不贴!peach!🍑",
"博士请您稍微克制一点",
"博士,阿米娅在一旁哦",
"博士,凯尔希在一旁哦",
"不要靠这么近嘛~"
],
"抱抱": [
"抱抱博士\\( ̄︶ ̄*\\))",
"为什么突然抱过来啊喂",
"只能抱一小会哦",
"不要闹啦"
],
"摸摸": [
"博士也给你摸摸~ヾ(≧▽≦*)o",
"别摸那里啊喂",
"呦西呦西"
],
"(笨蛋|傻逼|sb)": [
"八嘎,hentai,无路赛!",
"バカ、ヘンタイ、ウルサイ!",
"我不笨!你才笨"
],
"(爬|爪巴)": [
"我不爬,您爬",
"你爪巴!"
],
"(去死|死妈|滚开)": [
"滚!我不想看到你!"
],
"废物": [
"可笑,谁废啊"
],
"脑子有毛病": [
"你才有毛病吧?"
],
"揍你": [
"你很欠揍欸"
],
"色图": [
"我这里没有!不要找我了!",
"我不是涩涩bot啊喂"
],
"(透透|让我透)": [
"讨厌你!(╯‵□′)╯︵┻━┻"
],
"单推": [
"阿里嘎多!"
],
"嗦.+?牛子": [
"変態! 大変態!",
"就你?"
],
"击剑": [
"老娘是女的!",
"找南铜去,别找我"
],
"你的档案": [
"#image/dashboard.png",
"#image/document.png"
],
"(你的)?主人是谁": [
"是RF",
""
],
"(RF(是谁)?|谁是RF)": [
"是我的父母~"
]
}
}
2 changes: 1 addition & 1 deletion library/ak_closure_talk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# )
# logger.success("[ClosureTalk] Done.")
# return img
from .main import ArknightsClosureStore
from .main import ArknightsClosureStore as ArknightsClosureStore
Loading

0 comments on commit 6a9585d

Please sign in to comment.