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 mute_chat(mute_e): from database.mongo import cli cli = cli["Userbot"]["mute_chat"] """ For .mutechat command, mute any chat. """ await mute_e.edit(str(mute_e.chat_id)) cli.insert_one({"chat_id": mute_e.chat_id}) user = await get_user_from_id(mute_e.sender_id, mute_e) await mute_e.edit("`Shush! This chat will be silenced!`") if ENABLE_LOG: await mute_e.client.send_message( LOGGING_CHATID, "#CHAT_MUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {mute_e.chat.title}(`{mute_e.chat_id}`)", )
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_user(user, mute, gmute, gban, chat): return cli.insert_one({ "User": user, "Mute": mute, "GMute": gmute, "GBan": gban, "Chat": chat })
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 set_path(path): return cli.insert_one({"Path": path})
async def set_message(msg): return cli.insert_one({"ID": 2, "Message": msg})
async def others(opt): return cli.insert_one({"Others": opt})
async def set_afk(msg, time): return cli.insert_one({"Message": msg, "AFKTime": time})
async def set_gfolder(id): return cli.insert_one({"GFolder": id})
async def set_restart(chat, msg): return cli.insert_one({"Restart": True, "Chat": chat, "Message": msg})
async def set_limit(digit): return cli.insert_one({"Limit": digit})
async def approve(user): return cli.insert_one({"Approved": user})
async def set_antipm(opt): return cli.insert_one({"AntiPM": opt})
async def add(key, value, media): return cli.insert_one( {"Key": key, "Value": value, "Media": media})
async def add_blacklist(chat_id, trigger): return cli.insert_one({"chat_id": chat_id, "trigger": trigger})
async def set_pack(pack): return cli.insert_one({"Pack": pack})
async def set_prefix(prefix): return cli.insert_one({"Prefix": prefix})
async def set_notif(opt): return cli.insert_one({"Notifications": opt})
async def set_asset(id): return cli.insert_one({"Asset": id})
async def set_sblock(opt): return cli.insert_one({"SuperBlock": opt})
async def save_file(name, path, file): return cli.insert_one({"Name": name, "Path": path, "File": file})
async def mute(chatid, userid): if await is_muted(chatid, userid) is True: return False cli.insert_one({'chat_id': chatid, 'user_id': userid}) return True
async def set_godark(opt): return cli.insert_one({"GoDark": opt})
async def dload(name, link): return cli.insert_one({"Name": name, "URL": link})
async def add(key, value): return cli.insert_one( {"Key": key, "Value": value})
async def set_city(city): return cli.insert_one({"City": city})
async def add_blacklist(id): return cli.insert_one({"Blacklist": id})
async def set_name(name): return cli.insert_one({"ID": 1, "Name": name})