示例#1
0
def add_question_reply_at(word, reply_text, at, config, group_id):
    if word in KeyScreenWord:
        return word + '为保留字,不可以添加'
    if reply_text in KeyScreenWord:
        return reply_text + '为保留字,不可以添加'

    if len(config['key_reply']['question_at']) >= 100:
        return '最多只可以添加100个回复哦~'

    if at == '全体成员':
        at = -1
    elif at == '触发人':
        at = 0
    elif at.isdigit():
        at = int(at)
    else:
        return '艾特对象格式错误'
    if at != -1 and at < 0:
        return '艾特对象格式错误'

    reply_text = reply_text + '~$~' + str(at)

    if config['key_reply']['question_at'].__contains__(word):
        if reply_text in config['key_reply']['question_at'][word]:
            return '已经有该回复了'
        else:
            if len(config['key_reply']['question_at'][word]) >= 15:
                return '单个关键词只能添加15个回复~'
            config['key_reply']['question_at'][word].append(reply_text)
            dataManage.save_group(group_id, config)
            return '添加成功~'
    else:
        config['key_reply']['question_at'][word] = [reply_text]
        dataManage.save_group(group_id, config)
        return '添加成功~'
示例#2
0
def del_question_reply_at(word, reply_text, at, config, group_id):
    if word in KeyScreenWord:
        return word + '为保留字,不可以删除'
    if reply_text in KeyScreenWord:
        return reply_text + '为保留字,不可以删除'

    if at == '全体成员':
        at = -1
    elif at == '触发人':
        at = 0
    elif at.isdigit():
        at = int(at)
    else:
        return '艾特对象格式错误'
    if at != -1 and at < 0:
        return '艾特对象格式错误'

    reply_text = reply_text + '~$~' + str(at)

    if config['key_reply']['question_at'].__contains__(word):
        if reply_text in config['key_reply']['question_at'][word]:
            config['key_reply']['question_at'][word].remove(reply_text)
            if len(config['key_reply']['question_at'][word]) == 0:
                del config['key_reply']['question_at'][word]
            dataManage.save_group(group_id, config)
            return '删除成功~!'
        else:
            return '没有该词组配对~'
    else:
        return '没有该词组配对~'
示例#3
0
def clear_key(mode, config, group_id, qq):
    config['config']['key'] = []
    if mode == 1:
        dataManage.save_group(group_id, config)
    else:
        dataManage.save_user(qq, config)
    return '已清除所有触发词'
示例#4
0
def quit_group(group_id, config, name, qq):
    if not config['group'].__contains__(name):
        return '不存在该分组哦~'
    if qq not in config['group'][name]:
        return '你不在分组内'
    config['group'][name].remove(qq)
    dataManage.save_group(group_id, config)
    return '退出成功'
示例#5
0
def join_group(group_id, config, name, qq):
    if not config['group'].__contains__(name):
        return '不存在该分组哦~'
    if qq in config['group'][name]:
        return '你已经在分组内'
    config['group'][name].append(qq)
    dataManage.save_group(group_id, config)
    return '加入成功'
示例#6
0
def add_group_screen_word(group_id, config, word):
    if word in config['prohibited_word']:
        return '已经有该屏蔽词了'
    if word.isdigit():
        return '屏蔽词不能为纯数字哦~'

    config['prohibited_word'].append(word)
    dataManage.save_group(group_id, config)
    return '添加成功~!目前屏蔽词个数:' + str(len(config['prohibited_word']))
示例#7
0
def edit_key_probability(probability, config, group_id):
    if not probability.isdigit():
        return '格式错误,请输入0~100的数字'
    p = int(probability)
    if p < 0 or p > 100:
        return '概率只能在0到100之间'
    config['key_reply']['key']['RecoveryProbability'] = p
    dataManage.save_group(group_id, config)
    return '已将关键词回复概率修改为了' + str(p) + '%'
示例#8
0
def remove_key(key, mode, config, group_id, qq):
    if key not in config['config']['key']:
        return '未启用该触发词'

    config['config']['key'].remove(key)
    if mode == 1:
        dataManage.save_group(group_id, config)
    else:
        dataManage.save_user(qq, config)
    return '操作成功!已删除触发词' + key
示例#9
0
def remove_group(group_id, config, name, members):
    if not config['group'].__contains__(name):
        return '不存在该分组哦~'
    number = 0
    for qq in members:
        if qq in config['group'][name]:
            config['group'][name].remove(qq)
            number += 1
    dataManage.save_group(group_id, config)
    return '成功删除' + str(number) + '个人'
示例#10
0
def add_group(group_id, config, name, members, qq):
    if config['group'].__contains__(name):
        user = dataManage.read_user(qq)
        user['buffer']['id'] = 3
        user['buffer']['buffer'] = {
            'name': name,
            'group_id': group_id,
            'members': members
        }
        dataManage.save_user(qq, user)
        return '已经有该分组了哦~,是否要覆盖,回答“是”或者“否”'
    config['group'][name] = members
    dataManage.save_group(group_id, config)
    return '创建分组成功~'
示例#11
0
def add_key(key, mode, config, group_id, qq):
    if key in config['config']['key']:
        return '已启用该触发词'
    if key not in key_allow:
        reply = '该触发词不允许使用,仅允许使用以下符号作为触发词:'
        for i in key_allow:
            reply += i
        return reply

    config['config']['key'].append(key)
    if mode == 1:
        dataManage.save_group(group_id, config)
    else:
        dataManage.save_user(qq, config)
    return '操作成功!启用触发词“' + key + '”,使用“*key list”命令可以查看当前启用的触发词'
示例#12
0
def del_question_reply(word, reply_text, config, group_id):
    if word in KeyScreenWord:
        return word + '为保留字,不可以删除'
    if reply_text in KeyScreenWord:
        return reply_text + '为保留字,不可以删除'

    if config['key_reply']['question'].__contains__(word):
        if reply_text in config['key_reply']['question'][word]:
            config['key_reply']['question'][word].remove(reply_text)
            if len(config['key_reply']['question'][word]) == 0:
                del config['key_reply']['question'][word]
            dataManage.save_group(group_id, config)
            return '删除成功~!'
        else:
            return '没有该词组配对~'
    else:
        return '没有该词组配对~'
示例#13
0
def add_key_reply(word, reply_text, config, group_id):
    if word in KeyScreenWord:
        return word + '为保留字,不可以添加'
    if reply_text in KeyScreenWord:
        return reply_text + '为保留字,不可以添加'

    if len(config['key_reply']['key']) >= 100:
        return '最多只可以添加100个回复哦~'

    if config['key_reply']['key'].__contains__(word):
        if reply_text in config['key_reply']['key'][word]:
            return '已经有该回复了'
        else:
            if len(config['key_reply']['key'][word]) >= 15:
                return '单个关键词只能添加15个回复~'
            config['key_reply']['key'][word].append(reply_text)
            dataManage.save_group(group_id, config)
            return '添加成功~'
    else:
        config['key_reply']['key'][word] = [reply_text]
        dataManage.save_group(group_id, config)
        return '添加成功~'
示例#14
0
async def administrator_operation(bot, event, message, qq, name, group_id,
                                  mode, bot_config, config, statistics, right,
                                  group_right):
    bot_qq = bot_config['qq']
    bot_name = bot_config['name']
    master_qq = bot_config['master']

    message_len = len(message)
    message4 = message[:4]
    message5 = message[:5]
    message6 = message[:6]
    message7 = message[:7]
    message8 = message[:8]

    need_reply = False
    need_at = False
    reply_text = ''
    reply_image = ''

    # ===================================================================================
    # ===================================================================================
    # 主人权限
    if message == '主人帮助':
        if right < 1:
            reply_image = command.help_master()
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message == bot_name + '关机':
        if right < 1:
            logManage.log(getNow.toString(), bot_name + '关机!')
            await bot.send(event, '小柒已关机~请手动重新启动小柒')
            print('退出')
            sys.exit()
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

    elif message == '查看机器人信息':
        if right < 1:
            reply_text = '机器人名字:' + bot_name + '\n机器人QQ:' + str(
                bot_qq) + '\n主人QQ:' + str(master_qq)
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message4 == '删除文摘' and message_len > 4:
        if right < 1:
            tmp = message[4:].strip()
            if tmp.isdigit():
                reply_text = talk.delPoem(int(tmp))
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message4 == '删除情话' and message_len > 4:
        if right < 1:
            tmp = message[4:].strip()
            if tmp.isdigit():
                reply_text = talk.delLoveTalk(int(tmp))
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message4 == '删除脏话' and message_len > 4:
        if right < 1:
            tmp = message[4:].strip()
            if tmp.isdigit():
                reply_text = talk.delSwear(int(tmp))
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message7 == '添加黑名单 群' and message_len > 7:
        if right < 1:
            tmp = message[7:].strip().split(' ')
            if len(tmp) == 2 and tmp[0].isdigit():
                reply_text = add_blacklist_group(int(tmp[0]), tmp[1],
                                                 bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message7 == '添加黑名单 人' and message_len > 7:
        if right < 1:
            tmp = message[7:].strip().split(' ')
            if len(tmp) == 2 and tmp[0].isdigit():
                reply_text = add_blacklist_member(int(tmp[0]), tmp[1],
                                                  bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message7 == '移除黑名单 群' and message_len > 7:
        if right < 1:
            tmp = message[7:].strip()
            if tmp.isdigit():
                reply_text = remove_blacklist_group(int(tmp), bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message7 == '移除黑名单 人' and message_len > 7:
        if right < 1:
            tmp = message[7:].strip()
            if tmp.isdigit():
                reply_text = remove_blacklist_member(int(tmp), bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message6 == '修改版本信息' and message_len > 6:
        if right < 1:
            reply_text = change_version(message[6:].strip(), bot_config)
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message7 == '修改机器人名字' and message_len > 7:
        if right < 1:
            reply_text = change_bot_name(message[7:].strip(), bot_config)
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message7 == '修改机器人QQ' and message_len > 7:
        if right < 1:
            tmp = message[7:].strip()
            if tmp.isdigit():
                reply_text = change_bot_qq(int(tmp), bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    # 屏蔽词不用strip,因为可能有一些带空格屏蔽词
    elif message8 == '添加全局屏蔽词 ' and message_len > 8:
        if right < 1:
            reply_text = add_screen_word(message[8:])
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message8 == '删除全局屏蔽词 ' and message_len > 8:
        if right < 1:
            reply_text = del_screen_word(message[8:])
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message == '查看全局屏蔽词':
        if right < 1:
            reply_text = view_screen_word()
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message == '查看管理员':
        if right < 1:
            reply_text = str(bot_config["administrator"])
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message5 == '添加管理员' and message_len > 5:
        if right < 1:
            tmp = message[5:].strip()
            if tmp.isdigit():
                reply_text = add_administrator(int(tmp), bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message5 == '删除管理员' and message_len > 5:
        if right < 1:
            tmp = message[5:].strip()
            if tmp.isdigit():
                reply_text = del_administrator(int(tmp), bot_config)
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message4 == '开启脏话' and message_len > 4:
        if right < 1:
            tmp = message[4:].strip()
            if tmp.isdigit():
                reply_text = add_curse_plan_group(
                    dataManage.read_group(int(tmp)), int(tmp))
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message4 == '关闭脏话' and message_len > 4:
        if right < 1:
            tmp = message[4:].strip()
            if tmp.isdigit():
                reply_text = del_curse_plan_group(
                    dataManage.read_group(int(tmp)), int(tmp))
            else:
                reply_text = '格式错误'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message == '清空每分钟回复条数':
        if right < 1:
            statistics['lastMinute'] = 0
            dataManage.save_statistics(statistics)
            reply_text = '清空成功!'
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    elif message == '开启涩图' and mode == 1:
        if right < 1:
            reply_text = add_image_search_group(config, group_id)
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True
    elif message == '关闭涩图' and mode == 1:
        if right < 1:
            reply_text = del_image_search_group(config, group_id)
        else:
            reply_text = '权限不足,请输入"我的权限"查看'
        need_reply = True

    # ===================================================================================
    # ===================================================================================
    # 管理员权限
    if not need_reply:
        if message == '管理员帮助':
            if right < 2:
                reply_image = command.help_administrator()
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message5 == '添加贡献者' and message_len > 5:
            if right < 2:
                tmp = message[5:].strip()
                if tmp.isdigit():
                    reply_text = add_contributors(int(tmp), bot_config)
                else:
                    reply_text = '格式错误'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message5 == '删除贡献者' and message_len > 5:
            if right < 2:
                tmp = message[5:].strip()
                if tmp.isdigit():
                    reply_text = del_contributors(int(tmp), bot_config)
                else:
                    reply_text = '格式错误'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '查看贡献者':
            if right < 2:
                reply_text = str(bot_config["contributor"])
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message == '查看黑名单 人':
            if right < 2:
                reply_text = str(bot_config["blacklist_member"])
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '查看黑名单 群':
            if right < 2:
                reply_text = str(bot_config["blacklist_group"])
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message4 == '添加文摘' and message_len > 4:
            if right < 2:
                poem_list = message.split(' ')
                del poem_list[0]
                reply_text = talk.addPoem(poem_list)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message4 == '添加情话' and message_len > 4:
            if right < 2:
                love_talk_list = message.split(' ')
                del love_talk_list[0]
                reply_text = talk.addLoveTalk(love_talk_list)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message4 == '添加脏话' and message_len > 4:
            if right < 2:
                swear_list = message.split(' ')
                del swear_list[0]
                reply_text = talk.addSwear(swear_list)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '文摘条数':
            if right < 2:
                reply_text = talk.numPoem()
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '情话条数':
            if right < 2:
                reply_text = talk.numLoveTalk()
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '脏话条数':
            if right < 2:
                reply_text = talk.numSwear()
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '版本信息' or message == '查看版本信息':
            if right < 2:
                reply_text = '当前版本为:' + bot_config['version']
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif (message == '开启脏话' or message == '脏话开启') and mode == 1:
            if right < 2 or group_right < 2:
                reply_text = add_curse_plan_group(config, group_id)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif (message == '关闭脏话' or message == '脏话关闭') and mode == 1:
            if right < 2 or group_right < 2:
                reply_text = del_curse_plan_group(config, group_id)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
    # ===================================================================================
    # ===================================================================================
    # 贡献者权限
    if not need_reply:
        if message == '贡献者帮助':
            if right < 3:
                reply_image = command.help_contributor()
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message5 == '添加回复 ' and message_len > 5 and mode == 1:
            if right < 3:
                stringList = message.split(' ')
                if len(stringList) == 3:
                    reply_text = add_question_reply(stringList[1],
                                                    stringList[2], config,
                                                    group_id)
                elif len(stringList) == 4:
                    reply_text = add_question_reply_at(stringList[1],
                                                       stringList[2],
                                                       stringList[3], config,
                                                       group_id)
                else:
                    reply_text = '格式错误!请检查空格'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message5 == '删除回复 ' and message_len > 5 and mode == 1:
            if right < 3:
                stringList = message.split(' ')
                if len(stringList) == 3:
                    reply_text = del_question_reply(stringList[1],
                                                    stringList[2], config,
                                                    group_id)
                elif len(stringList) == 4:
                    reply_text = del_question_reply_at(stringList[1],
                                                       stringList[2],
                                                       stringList[3], config,
                                                       group_id)
                else:
                    reply_text = '格式错误!请检查空格'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message5 == '添加回复*' and message_len > 5 and mode == 1:
            if right < 3:
                stringList = message.split('*')
                if len(stringList) == 3:
                    reply_text = add_question_reply(stringList[1],
                                                    stringList[2], config,
                                                    group_id)
                elif len(stringList) == 4:
                    reply_text = add_question_reply_at(stringList[1],
                                                       stringList[2],
                                                       stringList[3], config,
                                                       group_id)
                else:
                    reply_text = '格式错误!请检查星号'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message5 == '删除回复*' and message_len > 5 and mode == 1:
            if right < 3:
                stringList = message.split('*')
                if len(stringList) == 3:
                    reply_text = del_question_reply(stringList[1],
                                                    stringList[2], config,
                                                    group_id)
                elif len(stringList) == 4:
                    reply_text = del_question_reply_at(stringList[1],
                                                       stringList[2],
                                                       stringList[3], config,
                                                       group_id)
                else:
                    reply_text = '格式错误!请检查星号'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message6 == '添加关键词 ' and message_len > 6 and mode == 1:
            if right < 3:
                stringList = message.split(' ')
                if len(stringList) == 3:
                    reply_text = add_key_reply(stringList[1], stringList[2],
                                               config, group_id)
                elif len(stringList) == 4:
                    reply_text = add_key_reply_at(stringList[1], stringList[2],
                                                  stringList[3], config,
                                                  group_id)
                else:
                    reply_text = '格式错误!请检查空格'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message6 == '删除关键词 ' and message_len > 6 and mode == 1:
            if right < 3:
                stringList = message.split(' ')
                if len(stringList) == 3:
                    reply_text = del_key_reply(stringList[1], stringList[2],
                                               config, group_id)
                elif len(stringList) == 4:
                    reply_text = del_key_reply_at(stringList[1], stringList[2],
                                                  stringList[3], config,
                                                  group_id)
                else:
                    reply_text = '格式错误!请检查空格'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message6 == '添加关键词*' and message_len > 6 and mode == 1:
            if right < 3:
                stringList = message.split('*')
                if len(stringList) == 3:
                    reply_text = add_key_reply(stringList[1], stringList[2],
                                               config, group_id)
                elif len(stringList) == 4:
                    reply_text = add_key_reply_at(stringList[1], stringList[2],
                                                  stringList[3], config,
                                                  group_id)
                else:
                    reply_text = '格式错误!请检查星号'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message6 == '删除关键词*' and message_len > 6 and mode == 1:
            if right < 3:
                stringList = message.split('*')
                if len(stringList) == 3:
                    reply_text = del_key_reply(stringList[1], stringList[2],
                                               config, group_id)
                elif len(stringList) == 4:
                    reply_text = del_key_reply_at(stringList[1], stringList[2],
                                                  stringList[3], config,
                                                  group_id)
                else:
                    reply_text = '格式错误!请检查星号'
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif message7 == '关键词回复概率' and message_len > 7 and mode == 1:
            if right < 3:
                reply_text = edit_key_probability(message[7:].strip(), config,
                                                  group_id)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif (message == '添加复杂回复' or message == '创建复杂回复') and mode == 1:
            user = dataManage.read_user(qq)
            user['buffer']['id'] = 5
            user['buffer']['buffer'] = group_id
            dataManage.save_user(qq, user)
            reply_text = '请在小柒的指引下完成复杂回复的添加~请问你的触发该回复的触发词是什么呢?(只能包含文本和艾特消息,你可以随时输入“*取消创建*”来取消,星号不可以省略哦~)'
            need_reply = True
        elif message == '查看复杂回复' and mode == 1:
            if not config['key_reply'].__contains__('complex'):
                reply_text = '没有开放的复杂回复触发词'
            else:
                if len(config['key_reply']['complex']) != 0:
                    reply_text = '开放的复杂回复触发词如下:'
                    for key, value in config['key_reply']['complex'].items():
                        reply_text += '\n' + key
                else:
                    reply_text = '没有开放的复杂回复触发词'
            need_reply = True
        elif message7 == '删除复杂回复 ' and mode == 1:
            key = message[7:]
            if config['key_reply']['complex'].__contains__(key):
                del config['key_reply']['complex'][key]
                dataManage.save_group(group_id, config)
                reply_text = '删除成功~'
            else:
                reply_text = '没有该触发词'
            need_reply = True

        elif message == '申请权限' and mode == 1:
            if group_right == 0:
                member_list = await bot.member_list(group_id)
                if len(member_list.data) > 10:
                    reply_text = add_contributors(qq, bot_config)
                    if reply_text == '添加成功~':
                        reply_text = '申请贡献者权限成功,可以输入“贡献者帮助”获取管理指令,需要更高权限的请前往' + bot_name + '官方群(479504567)找主人要'
                    elif '正确' in reply_text:
                        reply_text = '因为未知原因申请失败,请稍后重试'
                    else:
                        reply_text = reply_text.replace('他', '你').replace(
                            '该成员', '你')
                else:
                    reply_text = '你的群需要超过10人,请去' + bot_name + '官方群(479504567)找主人要权限'
            else:
                reply_text = '你并非群主(群需要超过10人),请去' + bot_name + '官方群(479504567)找主人要权限'
            need_reply = True

        # 屏蔽词不用strip,因为可能有一些带空格屏蔽词
        elif message6 == '添加屏蔽词 ' and message_len > 6 and mode == 1:
            if group_right < 2 or right < 2:
                reply_text = add_group_screen_word(group_id, config,
                                                   message[6:])
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message6 == '删除屏蔽词 ' and message_len > 6 and mode == 1:
            if group_right < 2 or right < 2:
                reply_text = del_group_screen_word(group_id, config,
                                                   message[6:])
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '查看屏蔽词' and mode == 1:
            if group_right < 2 or right < 2:
                reply_text = view_group_screen_word(config)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True
        elif message == '清空屏蔽词' and mode == 1:
            if group_right < 2 or right < 2:
                reply_text = clear_group_screen_word(qq, group_id, config)
            else:
                reply_text = '权限不足,请输入"我的权限"查看'
            need_reply = True

        elif (message5 == '创建分组 ' or message5 == '添加分组 ') and message_len > 5:
            group_name = ''
            i = 5
            while i < message_len:
                if message[i] != ' ' and message[i] != '@':
                    group_name += message[i]
                else:
                    break
                i += 1
            if len(group_name) > 0:
                member_text = message[i:]
                members = analysis_qqs(member_text)
                reply_text = add_group(group_id, config, group_name, members,
                                       qq)
            else:
                reply_text = '格式错误!'
            need_reply = True
        elif message7 == '添加分组成员 ' and message_len > 7:
            group_name = ''
            i = 7
            while i < message_len:
                if message[i] != ' ' and message[i] != '@':
                    group_name += message[i]
                else:
                    break
                i += 1
            if len(group_name) > 0:
                member_text = message[i:]
                members = analysis_qqs(member_text)
                reply_text = append_group(group_id, config, group_name,
                                          members)
            else:
                reply_text = '格式错误!'
            need_reply = True
        elif message7 == '删除分组成员 ' and message_len > 7:
            group_name = ''
            i = 7
            while i < message_len:
                if message[i] != ' ' and message[i] != '@':
                    group_name += message[i]
                else:
                    break
                i += 1
            if len(group_name) > 0:
                member_text = message[i:]
                members = analysis_qqs(member_text)
                reply_text = remove_group(group_id, config, group_name,
                                          members)
            else:
                reply_text = '格式错误!'
            need_reply = True
        elif message5 == '删除分组 ' and message_len > 5:
            group_name = message[5:].strip()
            reply_text = del_group(group_id, config, group_name)
            need_reply = True
        elif message5 == '查看分组 ' and message_len > 5:
            group_name = message[5:].strip()
            # reply_text = '暂时不能查看分组'
            reply_text = await view_group(bot, group_id, config, group_name)
            need_reply = True
        elif message == '清空分组':
            reply_text = clear_group(group_id, config, qq)
            need_reply = True
        elif message == '分组列表' or message == '查看分组列表':
            reply_text = view_all_group(config)
            need_reply = True

    if need_reply:
        if message != '贡献者帮助' and message != '管理员帮助' and message != '主人帮助':
            logManage.member_log(getNow.toString(), qq,
                                 message + "; 执行结果:" + reply_text)
        else:
            logManage.member_log(getNow.toString(), qq,
                                 message + "; 执行结果:参见command.py里的帮助内容")

    return need_reply, need_at, reply_text, reply_image
示例#15
0
    for i in bot_information['blacklistGroup']:
        config['blacklist_group'][i] = '未知原因,诞生于增加原因之前'
    for i in bot_information['blacklistMember']:
        config['blacklist_member'][i] = '未知原因,诞生于增加原因之前'

    dataManage.save_config(config)

    groups = {}
    users = {}

    for id in bot_information['cursePlanGroup']:
        if not groups.__contains__(id):
            groups[id] = dataManage.read_group(id)
        groups[id]['config']['curse'] = False
        dataManage.save_group(id, groups[id])
    
    for id in bot_information['mute']:
        if not groups.__contains__(id):
            groups[id] = dataManage.read_group(id)
        groups[id]['config']['mute'] = True
        dataManage.save_group(id, groups[id])
    
    for id in bot_information['gameOff']:
        if not groups.__contains__(id):
            groups[id] = dataManage.read_group(id)
        groups[id]['config']['RPG'] = True
        dataManage.save_group(id, groups[id])
    
    for id in bot_information['noAI']['group']:
        if not groups.__contains__(id):
示例#16
0
def reply(strMessage, group_id, config, statistics):
    questionReply = {}
    KeyReply = {}
    questionReplyAt = {}
    KeyReplyAt = {}
    complexReply = {}

    if config['key_reply'].__contains__('question'):
        questionReply = config['key_reply']['question']
    if config['key_reply'].__contains__('key'):
        KeyReply = config['key_reply']['key']
    if config['key_reply'].__contains__('question_at'):
        questionReplyAt = config['key_reply']['question_at']
    if config['key_reply'].__contains__('key_at'):
        KeyReplyAt = config['key_reply']['key_at']
    if config['key_reply'].__contains__('complex'):
        complexReply = config['key_reply']['complex']

    need_reply = False
    needAt = False
    reply = ''
    AtId = 0
    need_complex_reply = False  # 是否是复杂回复
    complex_at = {
        'at_type': -1,  # -1:不艾特;0:艾特;1:艾特分组
        'at': 0
    }  # 复杂艾特
    complex_reply = None  # 复杂回复

    p = random.randrange(0, 100)
    if not KeyReply.__contains__('RecoveryProbability'):
        KeyReply['RecoveryProbability'] = 100
        config['key_reply']['key'] = KeyReply
        dataManage.save_group(group_id, config)

    # if statistics['last_minute'] <= 10:
    # 全字段匹配
    if questionReply.__contains__(strMessage):
        replyList = questionReply[strMessage]
        if len(replyList) > 0:
            tmpNumber = random.randrange(0, len(replyList))
            reply = replyList[tmpNumber]
            need_reply = True
            statistics['last_minute'] += 1
            dataManage.save_statistics(statistics)

    # 全字段匹配带at
    if not need_reply:
        if questionReplyAt.__contains__(strMessage):
            replyList = questionReplyAt[strMessage]
            if len(replyList) > 0:
                tmpNumber = random.randrange(0, len(replyList))
                tmp = replyList[tmpNumber].split('~$~')
                reply = tmp[0]
                AtId = int(tmp[1])
                need_reply = True
                needAt = True
                statistics['last_minute'] += 1
                dataManage.save_statistics(statistics)

    # 关键词匹配
    if not need_reply:
        if p < KeyReply['RecoveryProbability']:
            for i in KeyReply:
                if i in strMessage:
                    replyList = KeyReply[i]
                    if len(replyList) > 0:
                        tmpNumber = random.randrange(0, len(replyList))
                        reply = replyList[tmpNumber]
                        need_reply = True
                        statistics['last_minute'] += 1
                        dataManage.save_statistics(statistics)
                        break

    # 关键词匹配(带艾特)
    if not need_reply:
        if p < KeyReply['RecoveryProbability']:
            for i in KeyReplyAt:
                if i in strMessage:
                    replyList = KeyReplyAt[i]
                    if len(replyList) > 0:
                        tmpNumber = random.randrange(0, len(replyList))
                        tmp = replyList[tmpNumber].split('~$~')
                        reply = tmp[0]
                        AtId = int(tmp[1])
                        need_reply = True
                        needAt = True
                        statistics['last_minute'] += 1
                        dataManage.save_statistics(statistics)
                        break

    if not need_reply:
        if complexReply.__contains__(strMessage):
            need_reply = True
            need_complex_reply = True
            complex_reply = complexReply[strMessage]['reply']
            complex_at = {
                'at_type': complexReply[strMessage]['at_type'],
                'at': complexReply[strMessage]['at']
            }
            statistics['last_minute'] += 1
            dataManage.save_statistics(statistics)

    # print('\tKeyReply AtId:', AtId)
    # print('\tKeyReply Reply:', reply)
    return need_reply, reply, '', AtId, needAt, need_complex_reply, complex_reply, complex_at
示例#17
0
def add_curse_plan_group(config, group_id):
    if config['config']['curse']:
        return '该群已经开启了脏话哦~'
    config['config']['curse'] = True
    dataManage.save_group(group_id, config)
    return '已开启∑(っ°Д°;)っ'
示例#18
0
def del_curse_plan_group(config, group_id):
    if not config['config']['curse']:
        return '该群本来就没有开启脏话!!!∑(゚Д゚ノ)ノ'
    config['config']['curse'] = False
    dataManage.save_group(group_id, config)
    return '已关闭,切,懦夫~'
示例#19
0
def del_group_screen_word(group_id, config, word):
    if word not in config['prohibited_word']:
        return '没有这个词语哦!'
    config['prohibited_word'].remove(word)
    dataManage.save_group(group_id, config)
    return '删除成功目前屏蔽词个数:' + str(len(config['prohibited_word']))
示例#20
0
def add_image_search_group(config, group_id):
    if config['config']['image']:
        return '该群已经开启了涩图哦~'
    config['config']['image'] = True
    dataManage.save_group(group_id, config)
    return '已开启ヾ(・ω・*)ノ'
示例#21
0
def del_image_search_group(config, group_id):
    if not config['config']['image']:
        return '该群本来就没有开启涩图!!!∑(゚Д゚ノ)ノ'
    config['config']['image'] = False
    dataManage.save_group(group_id, config)
    return '已关闭,(灬°ω°灬) '
示例#22
0
def del_group(group_id, config, name):
    if not config['group'].__contains__(name):
        return '不存在该分组哦~'
    del config['group'][name]
    dataManage.save_group(group_id, config)
    return '删除成功'