async def main(ctx): msg = ctx['raw_message'] m_id = str(ctx['message_id']) if msg == '今日新番': res = Bangumi() r = BangumiImage('{}「星期{}」新番时间表'.format( res.ep.get('date'), week_c[res.ep.get('day_of_week')])) r.gen_image(res.ep.get('seasons')) await bot.send( ctx, MessageSegment(type_='reply', data={'id': m_id}) + MessageSegment.image(file=r.pic2b64())) elif k := re.match('(星期([一二三四五六日天])|周([一二三四五六日]))+?新番', msg): if k.group(2): if k.group(2) == '天': el = '日' else: el = k.group(2) elif k.group(3): el = k.group(3) res = Bangumi(day=week_c.index(el)) r = BangumiImage('{}「星期{}」新番时间表'.format( res.ep.get('date'), week_c[res.ep.get('day_of_week')])) r.gen_image(res.ep.get('seasons')) await bot.send( ctx, MessageSegment(type_='reply', data={'id': m_id}) + MessageSegment.image(file=r.pic2b64()))
async def gacha_10(session:CommandSession): SUPER_LUCKY_LINE = 170 await check_jewel_num(session) uid = session.ctx['user_id'] jewel_limit.increase(uid, 1500) gid = str(session.ctx['group_id']) gacha = Gacha(_group_pool[gid]) result, hiishi = gacha.gacha_ten() silence_time = hiishi * 6 if hiishi < SUPER_LUCKY_LINE else hiishi * 60 if sv.bot.config.IS_CQPRO: res1 = Chara.gen_team_pic(result[:5], star_slot_verbose=False) res2 = Chara.gen_team_pic(result[5:], star_slot_verbose=False) res = concat_pic([res1, res2]) res = pic2b64(res) res = MessageSegment.image(res) result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res}\n{res1}\n{res2}' else: result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res1}\n{res2}' if hiishi >= SUPER_LUCKY_LINE: await session.send('恭喜海豹!おめでとうございます!') await session.send(f'素敵な仲間が増えますよ!\n{res}\n{SWITCH_POOL_TIP}', at_sender=True) await silence(session.ctx, silence_time)
async def gacha_300(session: CommandSession): uid = session.ctx['user_id'] tenjo_limit.increase(uid) gid = str(session.ctx['group_id']) gacha = Gacha(_group_pool[gid]) result = gacha.gacha_tenjou() up = len(result['up']) s3 = len(result['s3']) s2 = len(result['s2']) s1 = len(result['s1']) res = [*(result['up']), *(result['s3'])] random.shuffle(res) lenth = len(res) if lenth <= 0: res = "竟...竟然没有3★?!" else: step = 4 pics = [] for i in range(0, lenth, step): j = min(lenth, i + step) pics.append(Chara.gen_team_pic(res[i:j], star_slot_verbose=False)) res = concat_pic(pics) res = pic2b64(res) res = MessageSegment.image(res) msg = [ f"\n素敵な仲間が増えますよ! {res}", f"★★★×{up+s3} ★★×{s2} ★×{s1}", f"获得记忆碎片×{100*up}与女神秘石×{50*(up+s3) + 10*s2 + s1}!\n第{result['first_up_pos']}抽首次获得up角色" if up else f"获得女神秘石{50*(up+s3) + 10*s2 + s1}个!" ] if up == 0 and s3 == 0: msg.append("太惨了,咱们还是退款删游吧...") elif up == 0 and s3 > 7: msg.append("up呢?我的up呢?") elif up == 0 and s3 <= 3: msg.append("这位酋长,梦幻包考虑一下?") elif up == 0: msg.append("据说天井的概率只有12.16%") elif up <= 2: if result['first_up_pos'] < 50: msg.append("你的喜悦我收到了,滚去喂鲨鱼吧!") elif result['first_up_pos'] < 100: msg.append("已经可以了,您已经很欧了") elif result['first_up_pos'] > 290: msg.append("标 准 结 局") elif result['first_up_pos'] > 250: msg.append("补井还是不补井,这是一个问题...") else: msg.append("期望之内,亚洲水平") elif up == 3: msg.append("抽井母五一气呵成!多出30等专武~") elif up >= 4: msg.append("记忆碎片一大堆!您是托吧?") msg.append(SWITCH_POOL_TIP) await session.send('\n'.join(msg), at_sender=True)
async def daily_report(): res = Bangumi() r = BangumiImage('{}「星期{}」新番时间表'.format(res.ep.get('date'), week_c[res.ep.get('day_of_week')])) r.gen_image(res.ep.get('seasons')) await sv2.broadcast( '又是美好的一天(*•̀ᴗ•́*)و\n' + MessageSegment.image(file=r.pic2b64()), 'biligumi_broadcast', 0)
async def gacha_10(session:CommandSession): SUPER_LUCKY_LINE = 170 await check_jewel_num(session) uid = session.ctx['user_id'] jewel_limit.increase(uid, 1500) gid=session.ctx['group_id'] gacha = Gacha(_group_pool[gid]) result, hiishi = gacha.gacha_ten() silence_time = hiishi * 6 if hiishi < SUPER_LUCKY_LINE else hiishi * 60 cardo = [cardram(),cardram(),cardram(),cardram(),cardram(),cardram(),cardram(),cardram(),cardram(),cardram()] if (cardo[0] + cardo[1] + cardo[2] + cardo[3] + cardo[4] + cardo[5] + cardo[6] + cardo[7] + cardo[8] + cardo[9]) == 60: cardo[9] = 5 cardu = [Chara.cardimg(cardo[0]),Chara.cardimg(cardo[1]),Chara.cardimg(cardo[2]),Chara.cardimg(cardo[3]),Chara.cardimg(cardo[4]),Chara.cardimg(cardo[5]),Chara.cardimg(cardo[6]),Chara.cardimg(cardo[7]),Chara.cardimg(cardo[8]),Chara.cardimg(cardo[9])] card = Chara.gen_card_pic(cardu, star_slot_verbose=False) card = pic2b64(card) card = MessageSegment.image(card) cardm1 = cardmjs(cardo[0])[0] + cardmjs(cardo[1])[0] + cardmjs(cardo[2])[0] + cardmjs(cardo[3])[0] + cardmjs(cardo[4])[0] + cardmjs(cardo[5])[0] + cardmjs(cardo[6])[0] + cardmjs(cardo[7])[0] + cardmjs(cardo[8])[0] + cardmjs(cardo[9])[0] cardm2 = cardmjs(cardo[0])[1] + cardmjs(cardo[1])[1] + cardmjs(cardo[2])[1] + cardmjs(cardo[3])[1] + cardmjs(cardo[4])[1] + cardmjs(cardo[5])[1] + cardmjs(cardo[6])[1] + cardmjs(cardo[7])[1] + cardmjs(cardo[8])[1] + cardmjs(cardo[9])[1] cardm3 = cardmjs(cardo[0])[2] + cardmjs(cardo[1])[2] + cardmjs(cardo[2])[2] + cardmjs(cardo[3])[2] + cardmjs(cardo[4])[2] + cardmjs(cardo[5])[2] + cardmjs(cardo[6])[2] + cardmjs(cardo[7])[2] + cardmjs(cardo[8])[2] + cardmjs(cardo[9])[2] cardmax = f'获得角色碎片x{cardm1},母猪石x{cardm2},公主之心碎片x{cardm3}' if sv.bot.config.IS_CQPRO: res1 = Chara.gen_team_pic(result[ :5], star_slot_verbose=False) res2 = Chara.gen_team_pic(result[5: ], star_slot_verbose=False) res = concat_pic([res1, res2]) res = pic2b64(res) res = MessageSegment.image(res) result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res}\n{res1}\n{res2}' else: result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res1}\n{res2}' if hiishi >= SUPER_LUCKY_LINE: await session.send('恭喜海豹!おめでとうございます!') await session.send(f'素敵な仲間が増えますよ!\n{res}\n{card}\n{cardmax}', at_sender=True) await silence(session.ctx, silence_time)
def concat_poker(card): des = Image.new('RGBA', (max(len(card) % 3, len(card) // 3 * 3) * 105, (len(card) // 4 + 1) * 150), (255, 255, 255, 255)) for ii in range(0, len(card)): cardname = card[ii] #cardpath = R.img('poker/', cardname + '.jpg').path src = R.img('poker/', cardname + '.jpg').open().convert('RGBA').resize( (105, 150), Image.LANCZOS) des.paste(src, (ii % 3 * 105, ii // 3 * 150)) #des = util.concat_pic(cardPIL) des = util.pic2b64(des) des = MessageSegment.image(des) return des
async def throw(qq): avatar_url = f'http://q1.qlogo.cn/g?b=qq&nk={qq}&s=160' imgres = await aiorequests.get(avatar_url) if not imgres: return -1 img = await imgres.content avatar = Image.open(BytesIO(img)).convert('RGBA') avatar = get_circle_avatar(avatar, 139) randomangle = random.randrange(360) throw_img = Image.open(os.path.join(base_path, 'throw.jpg')) throw_img.paste(avatar.rotate(randomangle), (17, 180), avatar.rotate(randomangle)) throw_img = pic2b64(throw_img) throw_img = str(MessageSegment.image(throw_img)) return throw_img
async def creep(qq): cid = random.randint(0, 53) avatar_url = f'http://q1.qlogo.cn/g?b=qq&nk={qq}&s=160' imgres = await aiorequests.get(avatar_url) if not imgres: return -1 img = await imgres.content avatar = Image.open(BytesIO(img)).convert('RGBA') avatar = get_circle_avatar(avatar, 100) creep_img = Image.open(os.path.join(base_path, 'pa', f'爬{cid}.jpg')).convert('RGBA') creep_img = creep_img.resize((500, 500), Image.ANTIALIAS) creep_img.paste(avatar, (0, 400, 100, 500), avatar) creep_img = pic2b64(creep_img) creep_img = str(MessageSegment.image(creep_img)) return creep_img
async def show_collection(session:CommandSession): uid = str(session.ctx['user_id']) uset=load_user_collection(uid)[uid] length = len(uset) if length <= 0: session.finish('您的仓库为空,请多多抽卡哦~',at_sender=True) else: result=list(map(lambda x:Chara.fromname(x),uset)) step = 6 pics = [] for i in range(0, length, step): j = min(length, i + step) pics.append(Chara.gen_team_pic(result[i:j], star_slot_verbose=False)) res = concat_pic(pics) res = pic2b64(res) res = MessageSegment.image(res) msg=[ f'仅展示三星角色~', f'{res}', f'您共有{length}个三星角色~' ] await session.send('\n'.join(msg), at_sender=True)
async def gacha_10(session): SUPER_LUCKY_LINE = 170 await check_jewel_num(session) uid = session.ctx['user_id'] jewel_limit.increase(uid, 1500) uid = str(session.ctx['user_id']) ucollection = load_user_collection(uid) uset = set(ucollection[uid]) gid = session.ctx.get('group_id', 0) gacha = Gacha(_group_pool[str(gid)]) if gid != 0 else Gacha('MIX') result, hiishi = gacha.gacha_ten() silence_time = hiishi * 6 if hiishi < SUPER_LUCKY_LINE else hiishi * 60 for c in result: if 3 == c.star: uset.add(c.name) ucollection[uid] = list(uset) if sv.bot.config.IS_CQPRO: res1 = Chara.gen_team_pic(result[:5], star_slot_verbose=False) res2 = Chara.gen_team_pic(result[5:], star_slot_verbose=False) res = concat_pic([res1, res2]) res = pic2b64(res) res = MessageSegment.image(res) result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res}\n{res1}\n{res2}' else: result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res1}\n{res2}' dump_user_collection(uid, ucollection) if hiishi >= SUPER_LUCKY_LINE: await session.send('恭喜海豹!おめでとうございます!') await session.send(f'素敵な仲間が増えますよ!\n{res}', at_sender=True) if gid != 0: await silence(session.ctx, silence_time)
async def gacha_wai(session: CommandSession): SUPER_LUCKY_LINE = 170 uid = session.ctx['user_id'] gid = str(session.ctx['group_id']) gacha = Gacha(_group_pool[gid]) result, hiishi = gacha.gacha_wai() silence_time = hiishi * 6 if hiishi < SUPER_LUCKY_LINE else hiishi * 60 if sv.bot.config.IS_CQPRO: res1 = Chara.gen_team_pic(result[:5], star_slot_verbose=False) res2 = Chara.gen_team_pic(result[5:], star_slot_verbose=False) res = concat_pic([res1, res2]) res = pic2b64(res) res = MessageSegment.image(res) result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res}\n{res1}\n{res2}' else: result = [f'{c.name}{"★"*c.star}' for c in result] res1 = ' '.join(result[0:5]) res2 = ' '.join(result[5:]) res = f'{res1}\n{res2}' await session.send(f'听说喜欢常驻等歪~~\n{res}\n{SWITCH_POOL_TIP}', at_sender=True)
async def update_report(): sv.logger.info('Checking Update') global cache if not cache: ri = Bangumi() cache = ri.ep return res = Bangumi() updates = res.update_check(cache) cache = res.ep #sv.logger.info(updates) if not updates: return r = BangumiImage('Lately Update') r.gen_image(updates, is_update=True) ''' link = '\n'.join('{} - {}'.format(i.get('title'),i.get('link')) for i in updates) await sv.broadcast(MessageSegment.image(file=r.pic2b64()) + link,'biligumi_broadcast',0) ''' await sv.broadcast(MessageSegment.image(file=r.pic2b64()), 'biligumi_broadcast', 0) for im in updates: await sv.broadcast('{} - {}'.format(im.get('title'), im.get('link')), 'biligumi_broadcast')
async def gacha_300(session:CommandSession): await check_tenjo_num(session) uid = session.ctx['user_id'] tenjo_limit.increase(uid) gid=session.ctx['group_id'] gacha = Gacha(_group_pool[gid]) result = gacha.gacha_tenjou() up = len(result['up']) s3 = len(result['s3']) s2 = len(result['s2']) s1 = len(result['s1']) d1 = 0 d2 = 0 d3 = 0 d4 = 0 d5 = 0 d6 = 0 cardm1 = 0 for i in range(30): if cardm1 < 145: card10 = cardram10() d1 = d1 + card10[0] d2 = d2 + card10[1] d3 = d3 + card10[2] d4 = d4 + card10[3] d5 = d5 + card10[4] d6 = d6 + card10[5] cardm1 = d1 * 40 + d2 * 20 + d3 * 5 + d4 cardp = i + 1 cardpsp = f',你在第{cardp}发十连获得可拼角色的碎片数量' else: card10 = cardram10() d1 = d1 + card10[0] d2 = d2 + card10[1] d3 = d3 + card10[2] d4 = d4 + card10[3] d5 = d5 + card10[4] d6 = d6 + card10[5] cardm1 = d1 * 40 + d2 * 20 + d3 * 5 + d4 cardm2 = d1 * 5 + d2 * 5 + d3 + d4 + d5 + d6 cardm3 = d1 * 5 + d2 * 3 + d3 * 3 + d4 * 2 + d5 cardmax = f'累计获得一等{d1}次,二等{d2}次,三等{d3}次{cardpsp}\n获得角色碎片x{cardm1},母猪石x{cardm2},公主之心碎片x{cardm3}' res = [*(result['up']), *(result['s3'])] random.shuffle(res) lenth = len(res) if lenth <= 0: res = "竟...竟然没有3★?!" else: step = 4 pics = [] for i in range(0, lenth, step): j = min(lenth, i + step) pics.append(Chara.gen_team_pic(res[i:j], star_slot_verbose=False)) res = concat_pic(pics) res = pic2b64(res) res = MessageSegment.image(res) msg1 = [ f"\n素敵な仲間が増えますよ! {res}\n{cardmax}" ] msg = [ f"\n★★★×{up+s3} ★★×{s2} ★×{s1}", f"获得记忆碎片×{100*up}与女神秘石×{50*(up+s3) + 10*s2 + s1}!\n第{result['first_up_pos']}抽首次获得up角色" if up else f"获得女神秘石{50*(up+s3) + 10*s2 + s1}个!" ] if up == 0 and s3 == 0: msg.append("太惨了,咱们还是退款删游吧...") elif up == 0 and s3 > 7: msg.append("up呢?我的up呢?") elif up == 0 and s3 <= 3: msg.append("这位酋长,梦幻包考虑一下?") elif up == 0: msg.append("据说天井的概率只有12.16%") elif up <= 2: if result['first_up_pos'] < 50: msg.append("你的喜悦我收到了,滚去喂鲨鱼吧!") elif result['first_up_pos'] < 100: msg.append("已经可以了,您已经很欧了") elif result['first_up_pos'] > 290: msg.append("标 准 结 局") elif result['first_up_pos'] > 250: msg.append("补井还是不补井,这是一个问题...") else: msg.append("期望之内,亚洲水平") elif up == 3: msg.append("抽井母五一气呵成!多出30等专武~") elif up >= 4: msg.append("记忆碎片一大堆!您是托吧?") # msg.append(SWITCH_POOL_TIP) await session.send('\n'.join(msg1), at_sender=True) await session.send('\n'.join(msg), at_sender=True) silence_time = (100*up + 50*(up+s3) + 10*s2 + s1) * 1 await silence(session.ctx, silence_time)
async def gacha_300(session): await check_tenjo_num(session) uid = session.ctx['user_id'] tenjo_limit.increase(uid) uid = str(session.ctx['user_id']) ucollection = load_user_collection(uid) uset = set(ucollection[uid]) gid = session.ctx.get('group_id', 0) gacha = Gacha(_group_pool[str(gid)]) if gid != 0 else Gacha('MIX') result, up = gacha.gacha_tenjou() s3 = len(result['s3']) s2 = len(result['s2']) s1 = len(result['s1']) res = result['s3'] for c in res: uset.add(c.name) ucollection[uid] = list(uset) dump_user_collection(uid, ucollection) lenth = len(res) if lenth <= 0: res = "竟...竟然没有3★?!" else: step = 4 pics = [] for i in range(0, lenth, step): j = min(lenth, i + step) pics.append(Chara.gen_team_pic(res[i:j], star_slot_verbose=False)) res = concat_pic(pics) res = pic2b64(res) res = MessageSegment.image(res) msg = [ f"\n素敵な仲間が増えますよ! {res}", f"★★★×{s3} ★★×{s2} ★×{s1}", f"获得{up}个up角色与女神秘石×{50*(s3) + 10*s2 + s1}!\n第{result['first_up_pos']}抽首次获得up角色" if up else f"获得女神秘石{50*(up+s3) + 10*s2 + s1}个!" ] if up == 0 and s3 == 0: msg.append("太惨了,咱们还是退款删游吧...") elif up == 0 and s3 > 7: msg.append("up呢?我的up呢?") elif up == 0 and s3 <= 3: msg.append("这位酋长,大月卡考虑一下?") elif up == 0: msg.append("据说天井的概率只有12.16%") elif up <= 2: if result['first_up_pos'] < 50: msg.append("你的喜悦我收到了,滚去喂鲨鱼吧!") elif result['first_up_pos'] < 100: msg.append("已经可以了,您已经很欧了") elif result['first_up_pos'] > 290: msg.append("标 准 结 局") elif result['first_up_pos'] > 250: msg.append("补井还是不补井,这是一个问题...") else: msg.append("期望之内,亚洲水平") elif up == 3: msg.append("抽井母五一气呵成!您就是欧洲人?") elif up >= 4: msg.append("记忆碎片一大堆!您是托吧?") await session.send('\n'.join(msg), at_sender=True) silence_time = (100 * up + 50 * s3 + 10 * s2 + s1) * 1 if gid != 0: await silence(session.ctx, silence_time)