Example #1
0
async def command_ban(app: GraiaMiraiApplication, group: Group,
                      _gm: GroupMessage):
    M = MessagePro(_gm)

    def add() -> str:
        _l = str()
        for t in M.at:
            targetP = PermissionsHandler(t.target)
            if not targetP.isAdmin():
                _result = targetP.blockme()
                _message = f'{t.display} {tF.ban.add_succ}\n' if _result else f'{t.display} {tF.ban.add_fail}\n'
                _l = f'{_l}{_message}'
        return _l.strip('\n')

    def remove() -> str:
        _l = str()
        for t in M.at:
            targetP = PermissionsHandler(t.target)
            _result = targetP.unblockme()
            _message = f'{t.display} {tF.ban.remove_succ}\n' if _result else f'{t.display} {tF.ban.remove_fail}\n'
            _l = f'{_l}{_message}'
        return _l.strip('\n')

    if M.Command.args:
        subCommand = M.Command.argsList[0]
        if subCommand == 'add':
            await app.sendGroupMessage(group,
                                       MessageChain.create([Plain(add())]))
        if subCommand == 'remove':
            await app.sendGroupMessage(group,
                                       MessageChain.create([Plain(remove())]))
Example #2
0
async def command_ygg(app: GraiaMiraiApplication, group: Group,
                      _gm: GroupMessage):
    M = MessagePro(_gm)
    _playerName = M.Command.args if M.Command.args else M.quote_plain_message
    _player = PlayerProfile(_playerName)
    _message = _player.getYgg()
    await app.sendGroupMessage(group, MessageChain.create(_message))
Example #3
0
async def parse_csl_log(app: GraiaMiraiApplication, group: Group,
                        _gm: GroupMessage):
    await app.sendGroupMessage(
        group, MessageChain.create([Plain(tF.csl_log_parsing)]))
    M = MessagePro(_gm)
    fromLs = group.id in [qq.littleskin_main, qq.littleskin_cafe]
    try:
        _message = aoscPastebin(M.plain_message, fromLittleSkin=fromLs)
        await app.sendGroupMessage(group,
                                   MessageChain.create([Plain(_message)]))
    except Exception as e:
        await app.sendGroupMessage(group, MessageChain.create([Plain(e)]))
Example #4
0
async def command_ot(app: GraiaMiraiApplication, group: Group,
                     _gm: GroupMessage):
    M = MessagePro(_gm)
    atList: List[Optional[At]] = [At(t.target)
                                  for t in M.at] if M.at != [] else []
    await app.sendGroupMessage(
        group,
        MessageChain.create([
            Image.fromLocalFile('./images/off-topic.png'),
            *atList,
            # 仅在 LittleSkin 主群中启用此文本消息
            *([Plain(tF.ot)] if group.id == qq.littleskin_main else [])
        ]))
Example #5
0
async def command_view(app: GraiaMiraiApplication, group: Group,
                       _gm: GroupMessage):
    M = MessagePro(_gm)
    _textureHash = M.Command.args
    if not _textureHash:
        await app.sendGroupMessage(
            group, MessageChain.create([Plain(tF.view_no_hash_error)]))
    elif len(_textureHash) != 64:
        await app.sendGroupMessage(
            group, MessageChain.create([Plain(tF.view_hash_length_error)]))
    else:
        _image_message = PlayerProfile.getPreviewByHash(_textureHash)
        if _image_message:
            await app.sendGroupMessage(group,
                                       MessageChain.create([_image_message]))
        else:
            await app.sendGroupMessage(
                group, MessageChain.create([Plain(tF.view_not_200_error)]))
Example #6
0
async def why_listener(app: GraiaMiraiApplication, _gm: GroupMessage):
    M = MessagePro(_gm)
    await app.sendGroupMessage(qq.notification_channel,
                               MessageChain.create([Plain(tF.why_notify)]),
                               quote=M.source)
Example #7
0
async def command_test(app: GraiaMiraiApplication, group: Group,
                       _gm: GroupMessage):
    M = MessagePro(_gm)
    await app.sendGroupMessage(group,
                               MessageChain.create([Plain(tF.test)]),
                               quote=M.source)