res = sum_ + opr * offset msg = [ f'{TIP}\n', str(num) if num > 1 else '', 'D', f'{min_}~' if min_ != 1 else '', str(max_), (' +-'[opr] + str(offset)) if offset else '', '=', rolls_str, (' +-'[opr] + str(offset)) if offset else '', f'={res}' if offset or num > 1 else '', ] msg = ''.join(msg) if isinstance(event, GroupMessageEvent): await bot.send(event, msg, at_sender=True) elif isinstance(event, PrivateMessageEvent): await bot.send(event, '您' + msg) dice_roll = sv.on_rex(re.compile(r'^\.r\s*((?P<num>\d{0,2})d((?P<min>\d{1,4})~)?(?P<max>\d{0,4})((?P<opr>[+-])(?P<offset>\d{0,5}))?)?\b', re.I), only_group=False) qj = sv.on_fullmatch('.qj', only_group=False) @dice_roll.handle() async def dice(bot: Bot, event: CQEvent, state: T_State): num, min_, max_, opr, offset = 1, 1, 100, 1, 0 match = state['match'] if s := match.group('num'): num = int(s) if s := match.group('min'): min_ = int(s) if s := match.group('max'): max_ = int(s) if s := match.group('opr'): opr = -1 if s == '-' else 1 if s := match.group('offset'):
sv_help = ''' [日/台/陆rank] rank推荐表 [查看当前/全部rank更新源] [设置rank更新源] [更新rank表缓存] [挖矿15001] 矿场余钻 [黄骑充电表] 黄骑1动规律 [谁是霸瞳] 角色别称查询 '''.strip() sv = Service('pcr-query', help_=sv_help, bundle='pcr查询') miner = sv.on_prefix('挖矿', aliases={'jjc钻石', '竞技场钻石', 'jjc钻石查询', '竞技场钻石查询'}, only_group=False) rank = sv.on_rex(r'^(\*?([日台国陆b])服?([前中后]*)卫?)?rank(表|推荐|指南)?$', only_group=False) current_source = sv.on_fullmatch('查看当前rank更新源', only_group=False) all_source = sv.on_fullmatch('查看全部rank更新源', only_group=False) set_source = sv.on_rex(r'^设置rank更新源 (.{0,5}) (.{0,10}) (.{0,20})$', only_group=False) cache_update = sv.on_fullmatch('更新rank表缓存', only_group=False) yukari = sv.on_fullmatch(('yukari-sheet', '黄骑充电', '酒鬼充电', '酒鬼充电表', '黄骑充电表'), only_group=False) who_is = sv.on_prefix('谁是', only_group=False) async def load_config(): global config global server_addr config_path = os.path.join(os.path.dirname(__file__), "rank.json") with open(config_path, "r", encoding="utf8") as fp:
from salmon.modules.setu_hina.base import get_spec_image, get_setu, search_setu, check_path from salmon.modules.setu_hina.lolicon import get_config, get_group_config, set_group_config, lolicon_fetch_process HELP_MSG = ''' 来张 [keyword] 涩/色/瑟图 : 来张keyword的涩图(不指定关键字发送一张随机涩图) 提取图片pid : 获取指定id的p站图片,没有时发送链接 ''' sv = Service('setu', bundle='娱乐', help_=HELP_MSG) # 设置limiter tlmt = util.DailyNumberLimiter(get_config('base', 'daily_max')) flmt = util.FreqLimiter(get_config('base', 'freq_limit')) set_conf = sv.on_prefix('setu', only_group=False) setu = sv.on_rex( r'^[色涩瑟][图圖]$|^[来來发發给給]((?P<num>\d+)|(?:.*))[张張个個幅点點份丶](?P<keyword>.*?)[色涩瑟][图圖]$', only_group=False) get_pic = sv.on_prefix('提取图片', only_group=False) def check_lmt(uid, num): if uid in salmon.configs.SUPERUSERS: return 0, '' if not tlmt.check(uid): return 1, f"您今天已经冲过{get_config('base', 'daily_max')}次了,请明天再来~" if num > 1 and (get_config('base', 'daily_max') - tlmt.get_num(uid)) < num: return 1, f"您今天的剩余次数为{get_config('base', 'daily_max') - tlmt.get_num(uid)}次,已不足{num}次,请注意节制哦~" if not flmt.check(uid): return 1, f'您冲的太快了,{round(flmt.left_time(uid))}秒后再来吧~' # tlmt.increase(uid,num) flmt.start_cd(uid)
def get_setu(): return setu_gener.__next__() async def send_a_setu(bot, event): pic = get_setu() try: await bot.send(event, Message(pic.cqcode)) except: salmon.logger.error(f"发送图片{pic.path}失败") await bot.send(event, '涩图太涩,发不出去勒...') setu = sv.on_rex(r'^[色涩瑟][图圖]|[来來发發给給][张張个個幅点點份丶](?P<keyword>.*?)[色涩瑟][图圖]$') @setu.handle() async def random_setu(bot: Bot, event: CQEvent, state: T_State): uid = event.user_id user_info = await bot.get_stranger_info(user_id=uid) nickname = user_info.get('nickname', '未知用户') sender = f'>{nickname}\n' if not _nlmt.check(uid): if isinstance(event, GroupMessageEvent): await setu.finish(sender + EXCEED_NOTICE) elif isinstance(event, PrivateMessageEvent): await setu.finish(EXCEED_NOTICE) if not _flmt.check(uid): if isinstance(event, GroupMessageEvent): await setu.finish(sender + CD_NOTICE)