async def add_chat_service(chatid):
    check = await get_service(chatid)

    if not check:
        cli.insert_one({'chatid': chatid})
        return True
    cli.update_one({
        '_id': check['id'],
    }, {'&set': {
        'chatid': check['chatid']
    }})
    return False
예제 #2
0
async def set_weather(city):
    to_check = await get_weather()

    if to_check:
        cli.update_one(
            {
                '_id': to_check['_id'],
                'weather_city': to_check['weather_city']
            }, {"$set": {
                'weather_city': city
            }})
    else:
        cli.insert_one({'weather_city': city})
예제 #3
0
async def add_to_blacklist(chat_id, trigger):
    to_check = await check_blacklist(chat_id, trigger)
    if not to_check:
        cli.insert_one({'chat_id': chat_id, 'trigger': trigger})
        return True
    cli.update_one(
        {
            '_id': to_check["_id"],
            'chat_id': to_check["chat_id"],
            'trigger': to_check["trigger"],
        }, {"$set": {
            'trigger': trigger
        }})
    return False
예제 #4
0
async def set_ses(chat_id, ses_id, expires):
    check = await is_chat(chat_id)
    if not check:
        cli.insert_one({
            'chat_id': chat_id,
            'ses_id': ses_id,
            'expires': expires
        })
        return True
    cli.update_one({
        '_id': check['_id'],
    }, {'$set': {
        'ses_id': check['ses_id'],
        'expires': check['expires']
    }})
    return False
예제 #5
0
async def add_filter(chatid, keyword, msg_id):
    to_check = await get_filter(chatid, keyword)

    if not to_check:
        cli.insert_one({'chat_id': chatid, 'keyword': keyword, 'msg': msg_id})
        return True
    cli.update_one(
        {
            '_id': to_check["_id"],
            'chat_id': to_check["chat_id"],
            'keyword': to_check["keyword"],
        }, {"$set": {
            'msg': msg_id
        }})

    return False
예제 #6
0
async def add_note(chatid, name, text):
    to_check = await get_note(chatid, name)

    if not to_check:
        cli.insert_one({'chat_id': chatid, 'name': name, 'text': text})

        return True
    cli.update_one(
        {
            '_id': to_check["_id"],
            'chat_id': to_check["chat_id"],
            'name': to_check["name"],
        }, {"$set": {
            'text': text
        }})

    return False
예제 #7
0
async def add_welcome_setting(chat_id, should_clean_welcome, previous_welcome,
                              f_mesg_id):
    check = await get_current_welcome_settings(chat_id)
    if not check:
        cli.insert_one({
            'chat_id': chat_id,
            'should_clean_welcome': should_clean_welcome,
            'previous_welcome': previous_welcome,
            'f_mesg_id': f_mesg_id
        })
        return True
    cli.update_one(
        {
            '_id': check['_id'],
            'chat_id': check['chat_id'],
            'should_clean_welcome': should_clean_welcome,
            'previous_welcome': check['previous_welcome']
        }, {'$set': {
            'f_mesg_id': f_mesg_id
        }})
    return False
예제 #8
0
async def update(query, key, value):
    return cli.update_one(
        query, {"$set": {"Key": key, "Value": value}})
예제 #9
0
async def update_file(name, path, newfile):
    return cli.update_one(
        {"Name": name}, {"$set": {"File": newfile, "Path": path}})
예제 #10
0
async def update_user(query, newvalue):
    return cli.update_one(query, {"$set": newvalue})