def get_cqcode(chara_id): dir_path = os.path.join(os.path.expanduser(hoshino.config.RES_DIR), 'img', 'priconne', 'unit') if not os.path.exists(dir_path): os.makedirs(dir_path) c = chara.fromid(chara_id) cqcode = '' if not c.icon.exist else c.icon.cqcode return c.name, cqcode
async def avatar_guess(bot: KokkoroBot, ev: EventInterface): gid = ev.get_group_id() if winner_judger.get_on_off_status(gid): correct_id = winner_judger.get_result(gid) c = chara.fromid(correct_id) msg = f'正确答案是: {c.name}\n很遗憾,没有人答对~' await bot.kkr_send(ev, msg) await bot.kkr_send(ev, c.icon) winner_judger.turn_off(gid)
async def hint(bot: KokkoroBot, ev: EventInterface): gid = ev.get_group_id() if not winner_judger.get_on_off_status(gid): await bot.kkr_send(ev, '尚未开始猜头像0x0') return cnt = group_hint_cnt[gid] if cnt >= HINT_LIMIT: await bot.kkr_send(ev, '提示次数用完啦0x0\n输入"头像答案"查看答案') return correct_id = winner_judger.get_result(gid) c = chara.fromid(correct_id) img = c.icon.open() left = math.floor(random.random() * (129 - PIC_SIDE_LENGTH)) upper = math.floor(random.random() * (129 - PIC_SIDE_LENGTH)) cropped_img = img.crop( (left, upper, left + PIC_SIDE_LENGTH, upper + PIC_SIDE_LENGTH)) await bot.kkr_send(ev, f'提示{cnt+1}/{HINT_LIMIT}:') await bot.kkr_send(ev, cropped_img) group_hint_cnt[gid] += 1
async def on_input_chara_name(bot: KokkoroBot, ev: EventInterface): gid = ev.get_group_id() uid = ev.get_author_id() if winner_judger.get_on_off_status(gid): s = ev.get_param().remain cid = chara.name2id(s) correct_id = winner_judger.get_result(gid) if cid != chara.UNKNOWN and cid == winner_judger.get_result(gid) and winner_judger.get_winner(gid) == None: winner_judger.record_winner(gid, uid) winning_counter = WinningCounter(DB_PATH) winning_counter._record_winning(gid, uid) winning_count = winning_counter._get_winning_number(gid, uid) nick = ev.get_author().get_nick_name() msg_part = f'{nick}猜对了,真厉害!TA已经猜对{winning_count}次了~' c = chara.fromid(correct_id) msg = f'正确答案是: {c.name}' await bot.kkr_send(ev, msg) await bot.kkr_send(ev, c.icon) await bot.kkr_send(ev, msg_part) winner_judger.turn_off(gid)