Example #1
0
async def send_others_report(bot, event):
    if not priv.check_priv(event, priv.ADMIN):
        return

    gid = event['group_id']
    message = event['message']
    nickname, uid = None, None
    for msg in message:
        if msg.type == 'at' and msg.data['qq'] != 'all':
            uid = int(msg.data['qq'])
            info = await bot.get_group_member_info(group_id=gid, user_id=uid)
            nickname = info['card'] or info['nickname']

    if nickname:
        msg = gen_report(gid, uid, nickname, type=REPORT_NORMAL, kpi=True)
    else:
        msg = '参数错误!'
    await bot.send(event, msg)
async def set_box_collection(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '抱歉,您非管理员,无此指令使用权限')
    s = parse_message(ev.message)
    if len(s)==0:
        await bot.finish(ev, '请在指令后输入正确参数,发送"帮助pcrbox统计"查看更多\n例如"设置box统计 巨蟹座公会战 allE@xxx@yyy 会战前能达到的星级 狼,狗,黑骑"')
    s = s.lstrip().split(' ', 3)
    if len(s)!=4 or '' in s:
        await bot.finish(ev, '参数格式错误,输入"帮助pcrbox统计"查看正确参数格式')
    broadcast_list_str = await get_broadcast_list_str(bot, ev, s[1])
    chara_name_str = normalize_str(s[3])
    unknown_name, valid = is_valid_input(chara_name_str)
    if not valid:
        await bot.finish(ev, f'检测到输入参数中存在未知人物名"{unknown_name}",请重新输入')
    db = ColleSettingDao()
    db._update_or_insert_by_id(ev.group_id, s[0], broadcast_list_str, s[2], chara_name_str)
    command_confirmer.reset(ev.group_id)
    await bot.send(ev, '设定box统计项目完毕!')
Example #3
0
async def turn_on_spider(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '抱歉,您非管理员,无此指令使用权限')
    config = load_file('spider_config.json')
    gid = str(ev.group_id)
    s = ev.message.extract_plain_text()
    if s == '':
        s = config[gid].replace('(已禁用)',
                                '') if config.get(gid) is not None else '国服'
    if s not in ['国服', '日服', '台服']:
        await bot.finish(ev, '错误: 参数请从"国服"/"日服"/"台服"中选择')
    else:
        section = s
    config[gid] = section
    if save_file(config, 'spider_config.json'):
        await bot.send(ev, f'nga会战爬虫已启用(爬取版面:{section}讨论)')
    else:
        await bot.send(ev, '启用nga会战爬虫失败,请重试')
Example #4
0
async def cheat_score(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.SUPERUSER):
        await bot.finish(ev, '只有机器人管理才能使用氪金功能哦。', at_sender=True)
    gid = ev.group_id
    match = ev['match']
    id = int(match.group(1))
    num = int(match.group(2))
    duel = DuelCounter()
    score_counter = ScoreCounter2()
    if duel._get_level(gid, id) == 0:
        await bot.finish(ev, '该用户还未在本群创建贵族哦。', at_sender=True)
    if num > 0:  ##可充值负数
        score_counter._add_score(gid, id, num)
    else:
        score_counter._reduce_score(gid, id, -num)
    score = score_counter._get_score(gid, id)
    msg = f'已为[CQ:at,qq={id}]充值{num}金币。\n现在共有{score}金币。'
    await bot.send(ev, msg)
Example #5
0
async def remove_follow(bot, ev: CQEvent):
    gid = ev.group_id
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.send(ev, '该操作需要管理员权限')
        return
    clan_name, _ = get_arg_names(ev.message.extract_plain_text())
    if not clan_name:
        await bot.send(ev, '参数错误')
        return
    msg = ''
    config = load_group_config(gid)
    if clan_name in config:
        config.pop(clan_name)
        save_group_config(gid, config)
        msg = '删除成功'
    else:
        msg = '未关注指定公会'
    await bot.send(ev, msg)
Example #6
0
async def remove_banned(bot, ev):
    if not priv.check_priv(ev, priv.SUPERUSER):
        await bot.send(ev, '我只听主人的话哦~', at_sender=True)
        return
    user_id = extract_target_members(ev.message)
    if not user_id:
        await bot.send(ev, '你要解除谁的禁言呀?', at_sender=True)
        return
    if user_id == 'all':
        await bot.send(ev, '人家还不会啦, 你自己动手嘛~')
        return
    else:
        user_id = list(map(lambda u: int(u), user_id))
    for uid in user_id:
        await util.silence(ev, ban_time=0, user_id=uid)
    await bot.send(
        ev,
        ''.join([f'{MessageSegment.at(uid)}' for uid in user_id]) + ' 出来放风咯~')
Example #7
0
async def remove_follow(bot, ev: CQEvent):
    gid = ev.group_id
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.send(ev, '该操作需要管理员权限', at_sender=True)
        return
    args = ev.message.extract_plain_text().split()
    if len(args) == 0:
        await bot.send(ev, '参数错误', at_sender=True)
        return
    clan_name = args[0]
    msg = ''
    config = load_group_config(gid)
    if clan_name in config:
        config.pop(clan_name)
        save_group_config(gid, config)
        msg = '删除成功'
    else:
        msg = '未关注指定公会'
    await bot.send(ev, msg, at_sender=True)
Example #8
0
async def gruop_silence(bot, ev, gid, status):
    self_info = await self_member_info(bot, ev, gid)
    if self_info['role'] != 'owner' and self_info['role'] != 'admin':
        await bot.send(ev, '\n不给我管理员?', at_sender=True)
        return    
    if not priv.check_priv(ev,priv.ADMIN):
        await bot.send(ev, '只有管理才能给大家塞口球哦w', at_sender=True) 
    else:   
        try:
            await bot.set_group_whole_ban(
                    group_id = gid,
                    enable = status
                )
            if not status:
                await bot.send(ev, '全员禁言取消啦w')
            else:
                await bot.send(ev, '嘻嘻大家都被塞口球啦~')
        except Exception as e:
            await bot.send(ev, f'操作失败惹...\n错误代码:{e}', at_sender=True)
Example #9
0
async def dice_ob(bot, ev):
    command = str(ev.message)
    group_id, player_id = str(ev.group_id), str(ev.user_id)
    if command == 'exit':
        msg = await ob.quit_ob_list(group_id, player_id)
    elif command == 'list':
        msg = await ob.get_ob_list(group_id)
    elif command == 'clr':
        if not priv.check_priv(ev, priv.ADMIN):
            msg = p["权限不足"]
        else:
            msg = await ob.quit_ob_list(group_id, player_id, ALL=True)
    elif command == 'join':
        msg = await ob.join_ob_list(group_id, player_id)
    elif command != "":
        msg = p["未知指令"]
    else:
        msg = await ob.join_ob_list(group_id, player_id)
    await bot.send(ev, msg)
Example #10
0
async def kakin(bot, ev: CQEvent):
    recharge = ev.message.extract_plain_text().strip()  #取出金币参数
    if len(recharge) == 0:
        return
    elif int(recharge) == 0:
        return
    else:
        recharge = int(recharge)
    
    if priv.check_priv(ev, priv.SUPERUSER):
    #超级管理员
        count = 0
        for m in ev.message:
            if m.type == 'at' and m.data['qq'] != 'all':
                uid = int(m.data['qq'])
                cdb.write(uid, cdb.read(uid, '金币') + recharge, '金币')
                count += 1
        if count:   #为别人充值
            await bot.send(ev, f"已为{count}位骑士君充值{recharge}金币!")
Example #11
0
async def remove_meme(bot, event):
    if not priv.check_priv(event, priv.ADMIN):
        await bot.send(event, '该操作需要管理员权限', at_sender=True)
        return
    msg = event.message.extract_plain_text().split(" ")
    meme_name = msg[0]
    if meme_name not in img_name:
        await bot.send(event, f'没有找到表情"{meme_name}"', at_sender=True)
        return

    idx = img_name.index(meme_name)
    file_path = os.path.join(img_dir, img[idx])
    if os.path.exists(file_path):
        os.remove(file_path)
        await bot.send(event, f'删除表情"{meme_name}"成功', at_sender=True)
    else:
        await bot.send(event, f'表情文件"{meme_name}"不存在', at_sender=True)

    del img[idx], img_name[idx]
Example #12
0
async def modify_business_card(bot, ev):
    user_id = extract_target_members(ev.message)
    card_content = extract_plain_text(ev.message)
    if not user_id:
        user_id = ev.user_id
    elif user_id == 'all':
        await bot.send(ev, '诶~? 你是想累死我吗!?')
        return
    else:
        if not priv.check_priv(ev, priv.ADMIN):
            await bot.send(ev, '只有管理员可以修改名片哟~')
            return
        user_id = int(user_id[0])
    if not card_content:
        await bot.send(ev, '无名氏桑? 想清楚名字再来吧~')
    else:
        await util.set_group_card(ev,
                                  card_content=card_content,
                                  user_id=user_id)
Example #13
0
async def disable_email(bot, ev):
    uid = str(ev.user_id)
    username = str(ev.message)
    with open(current_dir, 'r', encoding='UTF-8') as f:
        f_data = json.load(f)
    if username not in list(f_data.keys()):
        msg = f'未找到此用户:{username}'
        await bot.finish(ev, msg)
    qq = f_data[username]['email'].replace('@qq.com', '')
    if not priv.check_priv(ev, priv.SUPERUSER) and uid != qq:
        msg = '您不是该学号对应QQ本人,需要删除需要本人操作或联系管理员操作!'
        await bot.finish(ev, msg)
    if not f_data[username]['enable_email']:
        msg = '您已经关闭了邮件提醒,无需再次关闭'
        await bot.finish(ev, msg)
    f_data[username]['enable_email'] = False
    with open(current_dir, 'w', encoding='UTF-8') as f:
        json.dump(f_data, f, indent=4, ensure_ascii=False)
    msg = '邮件提醒关闭成功'
    await bot.send(ev, msg)
Example #14
0
async def uninstall_yocool_force_chat(session):
    '''
    强制卸载
    '''
    if not priv.check_priv(session.event, priv.SUPERUSER):
        return
    await session.send('YoCool强制卸载开始,需要一定时间,请耐心等待……')
    yocode = await uninstall_yocool(force=True)
    if yocode == 0:
        await session.finish('尚未安装YoCool,无法操作')
    elif yocode == 1:
        await session.finish('YoCool完整性验证未通过,没有找到YoCool文件或备份文件夹')
    elif yocode == 2:
        await session.finish('移除YoCool文件出错,请手动卸载')
    elif yocode == 3:
        await session.finish('恢复原生主题出错,请手动恢复')
    elif yocode == 4:
        await session.finish('清理残留出错,请手动删除backup文件夹')
    else:
        await session.finish('YoCool卸载完成!')
async def delete_fav(bot, ev):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '抱歉,只有管理员才能使用该指令~', at_sender=True)

    # 处理输入数据
    name = ev.message.extract_plain_text()
    if len(name) == 0:
        await bot.finish(ev, "请发送'删除关注+公会名称'进行删除,无需+号", at_sender=True)

    try:
        db = ClanFav()
        gid = int(ev.group_id)
        record = db._find_by_name(gid, name)
        if not record:
            await bot.finish(ev, "未找到该记录哦~", at_sender=True)

        if db._delete(gid, name):
            await bot.send(ev, "删除成功!", at_sender=True)
    except:
        await bot.send(ev, "删除失败,请联系维护组或稍后再试", at_sender=True)
Example #16
0
async def get_jewel(bot, ev: CQEvent):
    gid = ev.group_id
    sid = None
    uid = ev.user_id
    for m in ev.message:
        if m.type == 'at' and m.data['qq'] != 'all':
            sid = int(m.data['qq'])
        elif m.type == 'at' and m.data['qq'] == 'all':
            await bot.send(ev, '人干事?', at_sender=True)
            return
    if sid is None:
        sid = uid
    if uid == sid or priv.check_priv(ev,priv.ADMIN):
        try:
            current_jewel = jewel_counter._get_jewel(gid, uid)
            msg = f'您的宝石为{current_jewel}'
            await bot.send(ev, msg, at_sender=True)
            return
        except Exception as e:
            await bot.send(ev, '错误:\n' + str(e))
Example #17
0
async def demo_chat(session):
    '''
    强制更新卡池时试用此命令
    '''
    if not priv.check_priv(session.event,priv.SUPERUSER):
        return
    online_ver = check_ver()
    if type(online_ver) != int:
        await session.finish(f'检查版本发生错误{type(online_ver)}')
    if not online_ver:
        # 返回0则卡池最新
        await session.finish('当前卡池已为最新')
    if online_ver < 1000:
        # 版本号比这个大多了!
        await session.finish(f'检查版本发生错误{online_ver}')

    result = update_pool(online_ver)
    if result:
        await session.finish(f'更新过程中发生错误{result}')
    await session.finish(f'更新完成, 当前卡池版本号{online_ver}')
Example #18
0
async def unsubscribe(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '只有群管理才能设置订阅。', at_sender=True)
    comm = str(ev.message).strip()
    msg = ev.detail_type
    if msg == 'group':
        user_id = ev.group_id
    elif msg == 'private':
        user_id = ev.user_id
    elif msg == 'discuss':
        user_id = ev.discuss_id
    else:
        await bot.finish(ev, '不支持群/私聊/讨论组以外的订阅方式')
    pc = PixivCounter()
    old = pc._get_subscribe_id(user_id, msg, 'pixiv', 'user', comm)
    if not old:
        await bot.send(ev, '未订阅过该作者作品')
    else:
        pc._del_by_subscribe_id(old)
        await bot.send(ev, '取消订阅成功')
Example #19
0
async def write_box_colle_to_csv(bot, ev: CQEvent):
    try:
        if not priv.check_priv(ev, priv.ADMIN):
            await bot.finish(ev, '抱歉,您非管理员,无此指令使用权限')
        s = ev.message.extract_plain_text()
        if len(s) == 0:
            db = ColleSettingDao()
            r = db._find_by_id(ev.group_id)
            db_name = '' if r == None else r[0]
        else:
            db_name = s

        file_path = os.path.normcase(
            os.path.expanduser(f'~/.hoshino/box_{ev.group_id}.csv'))
        with open(file_path, 'w', newline='', encoding='utf-8-sig') as f:
            writer = csv.writer(f)
            db = BoxColleDao()
            charaname_list = db._get_recorded_charaname_list(db_name)
            row0 = ['']
            row0.extend(charaname_list)
            writer.writerow(row0)

            uid_list = db._get_recorded_uid_list(db_name)
            user_card_dict = await get_user_card_dict(bot, ev.group_id)
            for uid in uid_list:
                row = [uid2card(uid, user_card_dict)]
                for chara_name in charaname_list:
                    star_rank = db._find_by_primary_key(
                        uid, db_name, chara_name2chara_id(chara_name))
                    if star_rank == '':
                        star_rank_str = star_rank
                    elif star_rank.startswith('0x'):
                        star_rank_str = '-'
                    else:
                        star_rank_str = star_rank.replace('.', '')
                    row.append(star_rank_str)
                writer.writerow(row)
            f.close()
        await bot.send(ev, f'{db_name}数据库的box统计表已导出到\n{file_path}')
    except:
        await bot.send(ev, f'导出失败')
Example #20
0
async def set_calendar(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '只有群管理才能切换日程', at_sender=True)
    name = util.normalize_str(ev.message.extract_plain_text())
    if not name:
        await bot.finish(ev, CALENDAR_NAME_TIP, at_sender=True)
    elif name in ('b', 'b服', 'bl', 'bilibili', '国', '国服', 'cn'):
        name = 'cn'
        reply = '国服'
    elif name in ('台', '台服', 'tw', 'sonet'):
        name = 'tw'
        reply = '台服'
    elif name in ('日', '日服', 'jp', 'cy', 'cygames'):
        name = 'jp'
        reply = '日服'
    else:
        await bot.finish(ev, f'未知服务器地区 {CALENDAR_NAME_TIP}', at_sender=True)
    gid = str(ev.group_id)
    _group_calendar[gid].update({"calendar_region": name})
    dump_calendar_config()
    await bot.send(ev, f'日程表已切换为{reply}', at_sender=True)
Example #21
0
async def add_spider_keyword(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '抱歉,您非管理员,无此指令使用权限')
    s = ev.message.extract_plain_text()
    config = load_config()
    gid = str(ev.group_id)
    if gid in config.keys():
        if s not in config[gid]:
            config[gid].append(s)
        else:
            await bot.finish(ev, '此群已经添加过该关键词,请勿重复添加')
    else:
        config[gid] = [s]
    if save_config(config):
        await bot.send(ev, f'添加关键词"{s}"成功!')
        # 重置群gid的item_cache和idx_cache,并重新加载缓存
        BiliSearchSpider.item_cache[gid] = []
        BiliSearchSpider.idx_cache[gid] = []
        await bili_search_spider()
    else:
        await bot.send(ev, '添加关键词失败,请重试')
Example #22
0
async def set_pool(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '只有群管理才能切换卡池哦~', at_sender=True)
    name = util.normalize_str(ev.message.extract_plain_text())
    if not name:
        await bot.finish(ev, POOL_NAME_TIP, at_sender=True)
    elif name in ('b', 'b服', 'bl', 'bilibili', '国', '国服', 'cn'):
        name = 'CN'
    elif name in ('台', '台服', 'tw', 'sonet'):
        name = 'TW'
    elif name in ('日', '日服', 'jp', 'cy', 'cygames'):
        name = 'JP'
    elif name in ('混', '混合', 'mix'):
        name = 'MIX'
    else:
        await bot.finish(ev, f'未知服务器地区 {POOL_NAME_TIP}', at_sender=True)
    gid = str(ev.group_id)
    _group_pool[gid] = name
    dump_pool_config()
    await bot.send(ev, f'卡池已切换为{name}池', at_sender=True)
    await gacha_info(bot, ev)
Example #23
0
async def awarded_title(bot, ev):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.send(ev, '只有管理员可以颁发头衔哟~')
        return
    user_id = extract_target_members(ev.message)
    special_title = extract_plain_text(ev.message)
    if not user_id:
        await bot.send(ev, '这个头衔, 你是打算给谁?')
        return
    elif user_id == 'all':
        await bot.send(ev, '诶~? 你是想累死我吗!?')
        return
    else:
        user_id = int(user_id[0])
    if not special_title:
        await bot.send(ev, '这是要发皇帝的新头衔吗? 我不会呀T^T')
        return
    else:
        await util.set_group_special_title(ev,
                                           special_title=special_title,
                                           user_id=user_id)
Example #24
0
async def one_key_yocool(session):
    if not priv.check_priv(session.event, priv.SUPERUSER):
        return
    if os.path.exists(backup_themes_path):
        await session.finish('您已经安装过了,如需更新请发送【更新YoCool】')
    name = util.normalize_str(session.current_arg_text)
    if not name:
        select = 1
    elif name in ('公主冒险', 'PrincessAdventure', '1'):
        select = 1
    elif name in ('轻酷', 'CoolLite', '2'):
        select = 2
    else:
        await session.finish(f'没有找到主题{name},请检查输入后再试')
    hoshino.logger.info('正在进行安装前初始化')
    if os.path.exists(current_info_path):
        for infile in glob.glob(os.path.join(path, '*.json')):
            os.remove(infile)
    newest_yocool_ver = await aiorequests.get(url=newest_info_url)
    if newest_yocool_ver.status_code != 200:
        hoshino.logger.error(
            f'获取YoCool版本信息时发生错误{newest_yocool_ver.status_code}')
        await session.send(f'获取YoCool版本信息时发生错误{newest_yocool_ver.status_code}')
    yocool_info_json = await newest_yocool_ver.json()
    yocool_info_json['Themes'] = select
    with open(current_info_path, 'w+', encoding='utf-8') as f:
        json.dump(yocool_info_json, f, indent=4, ensure_ascii=False)
    themes = get_yocool_themes(select)
    await session.send(f'YoCool初始化完成,准备使用{themes}主题进行安装,安装需要一定时间,请耐心等待……')
    status, version, updatenote = await update_yocool(force=True)
    if status == 0:
        for infile in glob.glob(os.path.join(path, '*.json')):
            os.remove(infile)
        await session.finish('本地版本信息异常!请重新发送指令再试!')
    elif status < 1000:
        await session.finish(f'发生错误{status}')
    else:
        await session.finish(
            f'一键安装已完成!\n当前YoCool版本:YoCool-{version}\n使用主题:{themes}\n更新日志:\n{updatenote}\n*电脑端请使用Ctrl+F5强制刷新浏览器缓存,移动端请在浏览器设置中清除缓存'
        )
Example #25
0
async def add_colle(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.SUPERUSER):
        await bot.finish(ev, '测试功能,仅限主人使用哦', at_sender=True)

    uid = str(ev.user_id)
    name = ev.sender['nickname']
    if not _colle_enable[uid]:
        await bot.finish(ev, f'{name}君你还没有开启仓库功能,请使用\"启用仓库\"开启功能')

    gm = GachaMaster(ev.user_id)
    if gm.has_colle():
        await bot.send(ev, '你已经有一个仓库了,不可以重复建立哦~', at_sender=True)
    else:
        colle = pickle.dumps({'贪吃佩可': 1, '可可萝': 1, '凯留': 1, '优衣': 1})
        try:
            gm.add_colle(colle, 45000, 0)
        except DatabaseError as e:
            await bot.finish(ev,
                             f'DatabaseError: {e.message}\nごめんなさい!嘤嘤嘤(〒︿〒)',
                             at_sender=True)
        await bot.send(ev, f'恭喜{name}君的仓库建立成功~')
        await list_colle(bot, ev)
Example #26
0
async def set_pool(bot, ev):

    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '只有群管理才能切换卡池', at_sender=True)

    pool_name = ev.message.extract_plain_text().strip()
    gid = str(ev.group_id)

    if pool_name in POOL.keys():
        if gid in group_pool:
            group_pool[gid] = pool_name
        else:
            group_pool.setdefault(gid,pool_name)
        save_group_pool()
        await bot.send(ev, f"卡池已切换为 {pool_name} ")
        return

    txt = "请使用以下命令来切换卡池\n"
    for i in POOL.keys():
        txt += f"原神卡池切换 {i} \n"

    await bot.send(ev, txt)
Example #27
0
async def delete_arena_sub(bot,ev):
    global binds, lck

    uid = str(ev['user_id'])

    if ev.message[0].type == 'at':
        if not priv.check_priv(ev, priv.SUPERUSER):
            await bot.finish(ev, '删除他人订阅请联系维护', at_sender=True)
            return
        uid = str(ev.message[0].data['qq'])
    elif len(ev.message) == 1 and ev.message[0].type == 'text' and not ev.message[0].data['text']:
        uid = str(ev['user_id'])


    if not uid in binds:
        await bot.finish(ev, '未绑定竞技场', at_sender=True)
        return

    async with lck:
        delete_arena(uid)

    await bot.finish(ev, '删除竞技场订阅成功', at_sender=True)
Example #28
0
async def admin_set(bot, ev, sid, gid, status):
    self_info = await self_member_info(bot, ev, gid)
    if self_info['role'] != 'owner':
        await bot.send(ev, '我必须要当群主才行o(╥﹏╥)o', at_sender=True)
        return
    if not priv.check_priv(ev,priv.ADMIN):
        await bot.send(ev, '才不听你的~哼╭(╯^╰)╮', at_sender=True) 
        return
    else: 
        try:
            for m in ev.message:
                await bot.set_group_admin(
                    group_id= gid, 
                    user_id= sid, 
                    enable= status
                )
            if not status:
                await bot.send(ev, f'[CQ:at,qq={sid}]已经成为成员啦~')
            else:
                await bot.send(ev, f'[CQ:at,qq={sid}]已经成为管理啦~')
        except Exception as e:
            await bot.send(ev, f'诶!!!为什么设置成功!\n错误代码:{e}', at_sender=True)
Example #29
0
async def confirm_broadcast(bot, ev: CQEvent):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.finish(ev, '抱歉,您非管理员,无此指令使用权限')
    if command_confirmer.check():
        db1 = ColleSettingDao()
        r = db1._find_by_id(ev.group_id)
        db_name, broadcast_list_str, detail, collection_setting = r[0], r[1], r[2], r[3]
        broadcast_list = broadcast_list_str.split(',')
        if command_confirmer.last_command_name == COMMAND_NAMES[0]:
            user_card = await get_user_card(bot, ev.group_id, ev.user_id)
            db2 = ColleRequestDao()
            command_confirmer.reset()
            await bot.send(ev, f'即将开始广播,此过程大约需要{int(len(broadcast_list)*SEND_INTERVAL)+1}s完成,请耐心等待')
            for uid in broadcast_list:
                db2._update_or_insert_by_id(int(uid), ev.group_id, db_name, detail, collection_setting)
                await bot.send_private_msg(user_id=int(uid), message=f'您好~群{ev.group_id}的管理员{user_card}({ev.user_id})正在统计公会成员的box,请输入"录入box"并根据指示向机器人录入您的box~')
                sleep(SEND_INTERVAL)
            await bot.send(ev, f'广播成功!已向{len(broadcast_list)}人私聊发送box统计请求')
        elif command_confirmer.last_command_name == COMMAND_NAMES[1]:
            collection_replenish_dict =  get_collection_replenish_dict(broadcast_list, db_name, collection_setting)
            user_card = await get_user_card(bot, ev.group_id, ev.user_id)
            db2 = ColleRequestDao()
            command_confirmer.reset()
            await bot.send(ev, f'即将开始广播,此过程大约需要{int(len(collection_replenish_dict.keys())*SEND_INTERVAL)+1}s完成,请耐心等待')
            for uid in collection_replenish_dict.keys():
                db2._update_or_insert_by_id(uid, ev.group_id, db_name, detail, collection_replenish_dict[uid])
                msg = f'''
您好~群{ev.group_id}的管理员{user_card}({ev.user_id})正在补录上次统计中漏统计的角色星级,您还需要补充录入的的角色为:\n
{collection_replenish_dict[uid]}\n
请输入"录入box"查看填写格式的相关说明
'''.strip()
                await bot.send_private_msg(user_id=uid, message=msg)
                sleep(SEND_INTERVAL)
            await bot.send(ev, f'广播成功!已向{len(collection_replenish_dict.keys())}人私聊发送box补录请求')            
    elif command_confirmer.has_command_wait_to_confirm():
        await bot.send(ev, f'确认超时,请在{MAX_VALID_TIME}s内完成确认')
    else:
        await bot.send(ev, '未找到需要确认的指令')
Example #30
0
async def get_pixiv(bot, ev):
    if not priv.check_priv(ev, priv.SUPERUSER):

        await bot.send(ev, '你不是主人,爬')
    else:
        await bot.send(ev, '好的主人,将爬取pixiv排行榜前三页图片')
        num_img = 0
        my_spider = spider()
        #my_pixiv_spider = pixiv_spider(new=True)
        date = datetime.datetime.now() - datetime.timedelta(days=2)
        path = '/lustre/qq_bot/res/img/pixiv/%02d%02d' % (date.month, date.day)
        is_dir = check_dir(path)
        if (is_dir):
            await bot.send(ev, '图片已经完成爬取')
        else:
            mkdir(path)
            my_pixiv_spider = pixiv_spider_mp(spider=my_spider,
                                              path=path,
                                              new=False,
                                              r18=False)
            for i in range(1, 4):
                num_img = num_img + my_pixiv_spider.get_pictures(i)
            await bot.send(ev, '爬取完成,共收集{0}张图片'.format(num_img))