Exemplo n.º 1
0
cred = credential.Credential(user_data["secret_id"], user_data["secret_key"])
http_profile = HttpProfile()
http_profile.endpoint = "tts.tencentcloudapi.com"
client_profile = ClientProfile()
client_profile.httpProfile = http_profile


@channel.use(
    ListenerSchema(
        listening_events=[GroupMessage],
        inline_dispatchers=[
            Twilight([
                FullMatch("说").space(SpacePolicy.FORCE),
                ArgumentMatch("-v", "--voice", type=int, optional=True)
                @ "voice_type",
                WildcardMatch().flags(re.DOTALL) @ "content"
            ])
        ],
        decorators=[
            FrequencyLimit.require("speak", 2),
            Function.require(channel.module),
            BlackListControl.enable(),
            UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS)
        ]))
async def speak(app: Ariadne, message: MessageChain, group: Group,
                voice_type: ArgResult, content: RegexResult):
    text = content.result.asDisplay()
    voice_type = voice_type.result if voice_type.matched else await group_setting.get_setting(
        group.id, Setting.voice)
    if voice_type == "off":
        return None
Exemplo n.º 2
0
                       member.id) if member else None

    async def detected_event(self, app: Ariadne, group: Group, member: Member,
                             message: MessageChain):
        if group.id == self.group and member.id == self.member:
            return True if re.match(r"[是否]", message.asDisplay()) else False


add_keyword_twilight = Twilight([
    FullMatch(r"添加"),
    FullMatch("群组", optional=True) @ "group_only",
    RegexMatch(r"(模糊|正则)", optional=True) @ "op_type",
    FullMatch("回复关键词#"),
    RegexMatch(r"[^\s]+") @ "keyword",
    FullMatch("#"),
    WildcardMatch().flags(re.DOTALL) @ "response"
])

delete_keyword_twilight = Twilight([
    FullMatch(r"删除"),
    FullMatch("群组", optional=True) @ "group_only",
    RegexMatch(r"(模糊|正则)", optional=True) @ "op_type",
    FullMatch("回复关键词#"),
    RegexMatch(r"[^\s]+") @ "keyword"
])


@channel.use(
    ListenerSchema(listening_events=[GroupMessage],
                   inline_dispatchers=[add_keyword_twilight],
                   decorators=[
Exemplo n.º 3
0
gw = GithubWatcher()


@channel.use(SchedulerSchema(timer=timers.every_minute()))
async def github_schedule(app: Ariadne):
    try:
        await gw.github_schedule(app=app, manual=False)
    except:
        pass


twilight = Twilight([
    FullMatch("/github-watch "),
    UnionMatch("disable", "add", "remove", "check", "cache"),
    WildcardMatch()
])


@channel.use(
    ListenerSchema(listening_events=[FriendMessage],
                   # inline_dispatchers=[twilight]
                   ))
async def github_watcher_friend_handler(app: Ariadne, message: MessageChain,
                                        friend: Friend):
    if result := await gw.real_handle(app, message, friend=friend):
        await MessageSender(result.strategy).send(app, result.message, message,
                                                  friend, friend)


@channel.use(
Exemplo n.º 4
0
saya = Saya.current()
channel = Channel.current()

channel.name("XsList")
channel.author("SAGIRI-kawaii")
channel.description("一个简查老师的插件,发送 `/查老师 {作品名/老师名/图片}` 即可")


@channel.use(
    ListenerSchema(
        listening_events=[GroupMessage],
        inline_dispatchers=[
            Twilight([
                FullMatch("/查老师"), RegexMatch(r"[\s]+", optional=True),
                ElementMatch(Image, optional=True) @ "image",
                WildcardMatch(optional=True) @ "keyword"
            ])
        ],
        decorators=[
            FrequencyLimit.require("xslist", 3),
            Function.require(channel.module),
            BlackListControl.enable(),
            UserCalledCountControl.add(UserCalledCountControl.FUNCTIONS)
        ]
    )
)
async def xslist_handler(app: Ariadne, group: Group, keyword: RegexResult, image: ElementResult):
    if image.matched:
        await app.sendGroupMessage(group, await search(data_bytes=await image.result.get_bytes()))
    elif keyword.matched:
        keyword = keyword.result.asDisplay().strip()
Exemplo n.º 5
0
async def memberjoinevent_listener(app: Ariadne, event: MemberJoinEvent):
    member = event.member
    group = member.group
    if group.id == qq.littleskin_main:
        await app.sendGroupMessage(group, MessageChain.create(
            [At(member.id), Plain(' '), Plain(tF.join_welcome)]))


@bcc.receiver(GroupMessage, dispatchers=[Twilight(Sparkle([CommandMatch('ygg.latest', False)]))])
async def command_handler(app: Ariadne, group: Group):
    infos = await apis.AuthlibInjectorLatest.get()
    _message = f'authlib-injector 最新版本:{infos.version}\n{infos.download_url}'
    await app.sendGroupMessage(group, MessageChain.create([Plain(_message)]))


@bcc.receiver(GroupMessage, dispatchers=[Twilight(Sparkle([CommandMatch('csl.latest')], {"params": WildcardMatch(optional=True)}))])
async def command_handler(app: Ariadne, group: Group, params: WildcardMatch):
    infos = await apis.CustomSkinLoaderLatest.get()
    mod_loader = params.result.asDisplay().strip()
    forge = f'''CustomSkinLoader 最新版本:{infos.version}
1.7.10 ~ 1.16.5: {infos.downloads.Forge}
1.17+: {infos.downloads.ForgeActive}'''
    fabric = f'''CustomSkinLoader 最新版本:{infos.version}
Fabric: {infos.downloads.Fabric}'''
    _message = forge if mod_loader == 'forge' else fabric
    await app.sendGroupMessage(group, MessageChain.create([Plain(_message)]))


@bcc.receiver(GroupMessage, dispatchers=[Twilight(Sparkle([CommandMatch('csl')], {"params": WildcardMatch(optional=True)}))])
async def command_handler(app: Ariadne, group: Group, params: WildcardMatch):
    player_name = params.result.asDisplay()
Exemplo n.º 6
0
from sagiri_bot.control import FrequencyLimit, Function, BlackListControl, UserCalledCountControl

saya = Saya.current()
channel = Channel.current()

channel.name("MessageMerger")
channel.author("SAGIRI-kawaii")
channel.description("将收到的消息合并为图片,在群中发送 `/merge 文字/图片`")


@channel.use(
    ListenerSchema(listening_events=[GroupMessage],
                   inline_dispatchers=[
                       Twilight([
                           FullMatch("/merge"),
                           WildcardMatch().flags(re.S) @ "msg_to_merge"
                       ])
                   ],
                   decorators=[
                       FrequencyLimit.require("message_merger", 2),
                       Function.require(channel.module),
                       BlackListControl.enable(),
                       UserCalledCountControl.add(
                           UserCalledCountControl.FUNCTIONS)
                   ]))
async def message_merger(app: Ariadne, message: MessageChain, group: Group,
                         msg_to_merge: RegexResult):
    await app.sendGroupMessage(
        group,
        MessageChain([
            Image(data_bytes=TextEngine([GraiaAdapter(msg_to_merge.result)],
Exemplo n.º 7
0
@channel.use(
    ListenerSchema(
        listening_events=[GroupMessage],
        inline_dispatchers=[
            Twilight([
                FullMatch("/aminer"),
                ArgumentMatch("-person", action="store_true",
                              optional=True) @ "person",
                ArgumentMatch("-article",
                              "-a",
                              "-paper",
                              action="store_true",
                              optional=True) @ "article",
                ArgumentMatch("-patent", action="store_true", optional=True)
                @ "patent",
                WildcardMatch() @ "keyword"
            ])
        ],
        decorators=[
            FrequencyLimit.require("aminer", 1),
            Function.require(channel.module),
            BlackListControl.enable(),
            UserCalledCountControl.add(UserCalledCountControl.SEARCH)
        ]))
async def aminer(app: Ariadne, group: Group, message: MessageChain,
                 person: ArgResult, article: ArgResult, patent: ArgResult,
                 keyword: RegexResult):
    if person.matched:
        router = "person"
    elif article.matched:
        router = "publication"
Exemplo n.º 8
0
from sagiri_bot.control import FrequencyLimit, Function, BlackListControl, UserCalledCountControl

saya = Saya.current()
channel = Channel.current()

channel.name("DDCheck")
channel.author("SAGIRI-kawaii")
channel.description("一个查成分的插件")

config = AppCore.get_core_instance().get_config()


@channel.use(
    ListenerSchema(
        listening_events=[GroupMessage],
        inline_dispatchers=[Twilight([FullMatch("/查成分"), WildcardMatch() @ "username"])],
        decorators=[
            FrequencyLimit.require("dd_check", 2),
            Function.require(channel.module),
            BlackListControl.enable(),
            UserCalledCountControl.add(UserCalledCountControl.SEARCH)
        ]
    )
)
async def dd_check(app: Ariadne, group: Group, message: MessageChain, username: RegexResult):
    if not username.result.asDisplay().strip():
        return await app.sendGroupMessage(group, MessageChain("空白名怎么查啊kora!"), quote=message.getFirst(Source))
    res = await get_reply(username.result.asDisplay().strip())
    await app.sendGroupMessage(
        group,
        MessageChain(res if isinstance(res, str) else [Image(data_bytes=res)]),