Пример #1
0
        def decorator(func: Callable):
            matcher = on_endswith(suffix, **kwargs)

            @wraps(func)
            @self._pre_check(only_to_me=only_to_me)
            async def wrapper(bot: Bot, event: Event, state: T_State):
                await func(bot, event)
                logger.info(
                    f'消息{event.get_session_id()}已被on_endswith处理器{func.__name__}处理。'
                )
                await matcher.finish()

            return matcher.handle()(wrapper)
Пример #2
0
from nonebot import on_endswith
from nonebot.adapters.cqhttp import Bot, Event, Message
from datetime import datetime
import os

tf = on_endswith('天赋')
we = on_endswith('武器')
zb = on_endswith('周本')

PATH = os.path.abspath('.')


@zb.handle()
async def _(bot: Bot, event: Event):
    # await zb.finish(message=Message(f'[CQ:image,file=http://pic.xiaoxuan.xyz:88/image/zb.png]'))
    await zb.finish(message=Message(
        f'[CQ:image,file=http://pic.xiaoxuan.xyz:88/image/zb.png]'))


@tf.handle()
async def _(bot: Bot, event: Event):
    mes = str(event.get_message())
    if '一' in mes:
        await tf.finish(message=Message(
            f'[CQ:image,file=http://pic.xiaoxuan.xyz:88/image/tf1.png]'))
    elif '二' in mes:
        await tf.finish(message=Message(
            f'[CQ:image,file=http://pic.xiaoxuan.xyz:88/image/tf2.png]'))
    elif '三' in mes:
        await tf.finish(message=Message(
            f'[CQ:image,file=http://pic.xiaoxuan.xyz:88/image/tf3.png]'))
Пример #3
0
    final = combo * left_increment + msg_base + combo * right_increment
    can_mutate = random.randint(1, 100) <= mutate_prob

    # add combo for self repetition if the message is not mutated
    save(universal_id, 'current_combo', (combo + 1) * (not can_mutate))
    return mutate_msg(final, mutate=can_mutate)


praise = on_command(cmd='praise', aliases={'膜'}, rule=check('exclaim'))

admire = on_command(cmd='admire', aliases={'狂膜'}, rule=check('exclaim'))

cheer = on_command(cmd='cheer', aliases={'加油 '}, rule=check('exclaim'))

cheer_ending = on_endswith(msg='加油', priority=10, rule=check('exclaim'))

greet = on_simple_command(cmd='greet', aliases={'小鱼'}, rule=check('exclaim'))

poke_greet = on_notice(priority=10,
                       block=True,
                       rule=check('exclaim', PokeNotifyEvent))

repeater = on_endswith(msg='', priority=11, block=True, rule=check('exclaim'))


@praise.handle()
async def show_praise(bot: Bot, event: Event, state: dict):
    """Praise the person."""
    person = str(event.message).strip()
    await bot.send(event=event, message=exclaim_msg(person, '1', True))
Пример #4
0
# from .identity_cards import *
from .player import Player

# 游戏是否开始
game_flag = False
# 玩家数据
players = {}
# 身份牌
identities = ['公爵 ', '队长 ', '夫人 ', '刺客 ', '大使 '] * 4
# 身份牌墓地
card_graveyard = []

help_documentation = on_command("帮助", rule=to_me(), priority=0)

start_game = on_command("开始", rule=to_me(), priority=1)
draw_cards = on_endswith("人", rule=to_me(), priority=1)
give_cards = on_regex("^[1-7一二三四五六七两俩]", rule=to_me(), priority=2)
change_cards = on_startswith("换牌", rule=to_me(), priority=2)
die_cards = on_startswith("死亡", rule=to_me(), priority=2)
end_game = on_command("结束", rule=to_me(), priority=1)


@help_documentation.handle()
async def _(bot: Bot, event: Event):
    text = '请先呼我名\n' \
           '创建房间命令是”开始“\n' \
           '选择人数命令是“n人”\n' \
           '加入房间的命令是“n“\n' \
           '换牌命令是”换牌第n张“\n' \
           '死亡命令是”死亡第n张“\n' \
           '支持命令”结束“快速结束\n' \
Пример #5
0
from nonebot import on_endswith
from nonebot.adapters.cqhttp import Bot, Event, Message
from datetime import datetime
import os

tf = on_endswith('.天赋')
we = on_endswith('.武器')
zb = on_endswith('.周本')

PATH = os.path.abspath('.')
print(PATH)


@zb.handle()
async def _(bot: Bot, event: Event):
    # await zb.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/zb.png]'))
    await zb.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/zb.png]'))


@tf.handle()
async def _(bot: Bot, event: Event):
    mes = str(event.get_message())
    if '一' in mes:
        await tf.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/tf1.png]'))
    elif '二' in mes:
        await tf.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/tf2.png]'))
    elif '三' in mes:
        await tf.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/tf3.png]'))
    elif '四' in mes:
        await tf.finish(message=Message(f'[CQ:image,file=file:///{PATH}/src/data/challenge/tf4.png]'))
    elif '五' in mes: