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 else: cli.update_one( { '_id': to_check["_id"], 'chat_id': to_check["chat_id"], 'trigger': to_check["trigger"], }, {"$set": { 'trigger': trigger }}) return False
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 else: cli.update_one( { '_id': to_check["_id"], 'chat_id': to_check["chat_id"], 'keyword': to_check["keyword"], }, {"$set": { 'msg': msg_id }}) return False
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 else: cli.update_one( { '_id': to_check["_id"], 'chat_id': to_check["chat_id"], 'name': to_check["name"], }, {"$set": { 'text': text }}) return False
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
async def update_user(query, newvalue): return cli.update_one(query, {"$set": newvalue})
async def update(query, key, value): return cli.update_one( query, {"$set": {"Key": key, "Value": value}})
async def update_file(name, path, newfile): return cli.update_one({"Name": name}, {"$set": { "File": newfile, "Path": path }})
async def update(query, key, value, media): return cli.update_one( query, {"$set": {"Key": key, "Value": value, "Media": media}})