| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817 |
- """
- MIT License
- Copyright (c) 2024 TheHamkerCat
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- """
- import codecs
- import pickle
- from string import ascii_lowercase
- from typing import Dict, List, Union
- from wbb import db
- from wbb.utils.dbadmin import get_managed_chat_settings, update_managed_chat_settings
- # SOME THINGS ARE FUCKED UP HERE, LIKE TOGGLEABLES HAVE THEIR OWN COLLECTION
- # (SHOULD FIX IT WITH SOMETHING LIKE TOGGLEDB), MOST OF THE CODE IS BAD AF
- # AND NEEDS TO BE REWRITTEN, BUT I WON'T, AS IT WILL TAKE
- # TOO MUCH TIME AND WILL BE BAD FOR ALREADY STORED DATA
- notesdb = db.notes
- filtersdb = db.filters
- warnsdb = db.warns
- karmadb = db.karma
- chatsdb = db.chats
- usersdb = db.users
- gbansdb = db.gban
- coupledb = db.couple
- captchadb = db.captcha
- solved_captcha_db = db.solved_captcha
- captcha_cachedb = db.captcha_cache
- antiservicedb = db.antiservice
- pmpermitdb = db.pmpermit
- welcomedb = db.welcome_text
- blacklist_filtersdb = db.blacklistFilters
- pipesdb = db.pipes
- sudoersdb = db.sudoers
- blacklist_chatdb = db.blacklistChat
- restart_stagedb = db.restart_stage
- flood_toggle_db = db.flood_toggle
- rssdb = db.rss
- rulesdb = db.rules
- chatbotdb = db.chatbot
- def obj_to_str(obj):
- if not obj:
- return False
- string = codecs.encode(pickle.dumps(obj), "base64").decode()
- return string
- def str_to_obj(string: str):
- obj = pickle.loads(codecs.decode(string.encode(), "base64"))
- return obj
- async def get_notes_count() -> dict:
- chats_count = 0
- notes_count = 0
- async for chat in notesdb.find({"chat_id": {"$exists": 1}}):
- notes_name = await get_note_names(chat["chat_id"])
- notes_count += len(notes_name)
- chats_count += 1
- return {"chats_count": chats_count, "notes_count": notes_count}
- async def _get_notes(chat_id: int) -> Dict[str, int]:
- _notes = await notesdb.find_one({"chat_id": chat_id})
- if not _notes:
- return {}
- return _notes["notes"]
- async def get_note_names(chat_id: int) -> List[str]:
- _notes = []
- for note in await _get_notes(chat_id):
- _notes.append(note)
- return _notes
- async def get_note(chat_id: int, name: str) -> Union[bool, dict]:
- name = name.lower().strip()
- _notes = await _get_notes(chat_id)
- if name in _notes:
- return _notes[name]
- return False
- async def save_note(chat_id: int, name: str, note: dict):
- name = name.lower().strip()
- _notes = await _get_notes(chat_id)
- _notes[name] = note
- await notesdb.update_one(
- {"chat_id": chat_id}, {"$set": {"notes": _notes}}, upsert=True
- )
- async def delete_note(chat_id: int, name: str) -> bool:
- notesd = await _get_notes(chat_id)
- name = name.lower().strip()
- if name in notesd:
- del notesd[name]
- await notesdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"notes": notesd}},
- upsert=True,
- )
- return True
- return False
- async def deleteall_notes(chat_id: int):
- return await notesdb.delete_one({"chat_id": chat_id})
- async def get_filters_count() -> dict:
- chats_count = 0
- filters_count = 0
- async for chat in filtersdb.find({"chat_id": {"$lt": 0}}):
- filters_name = await get_filters_names(chat["chat_id"])
- filters_count += len(filters_name)
- chats_count += 1
- return {
- "chats_count": chats_count,
- "filters_count": filters_count,
- }
- async def _get_filters(chat_id: int) -> Dict[str, int]:
- _filters = await filtersdb.find_one({"chat_id": chat_id})
- if not _filters:
- return {}
- return _filters["filters"]
- async def get_filters_names(chat_id: int) -> List[str]:
- _filters = []
- for _filter in await _get_filters(chat_id):
- _filters.append(_filter)
- return _filters
- async def get_filter(chat_id: int, name: str) -> Union[bool, dict]:
- name = name.lower().strip()
- _filters = await _get_filters(chat_id)
- if name in _filters:
- return _filters[name]
- return False
- async def save_filter(chat_id: int, name: str, _filter: dict):
- name = name.lower().strip()
- _filters = await _get_filters(chat_id)
- _filters[name] = _filter
- await filtersdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"filters": _filters}},
- upsert=True,
- )
- async def delete_filter(chat_id: int, name: str) -> bool:
- filtersd = await _get_filters(chat_id)
- name = name.lower().strip()
- if name in filtersd:
- del filtersd[name]
- await filtersdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"filters": filtersd}},
- upsert=True,
- )
- return True
- return False
- async def deleteall_filters(chat_id: int):
- return await filtersdb.delete_one({"chat_id": chat_id})
- async def get_rules(chat_id: int):
- chat = await rulesdb.find_one({"chat_id": chat_id})
- if not chat:
- return ""
- rules = chat.get("rules", "")
- return rules
- async def set_chat_rules(chat_id: int, rules: str):
- await rulesdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"rules": rules}},
- upsert=True,
- )
- async def delete_rules(chat_id: int):
- return await rulesdb.delete_one({"chat_id": chat_id})
- async def int_to_alpha(user_id: int) -> str:
- alphabet = list(ascii_lowercase)[:10]
- text = ""
- user_id = str(user_id)
- for i in user_id:
- text += alphabet[int(i)]
- return text
- async def alpha_to_int(user_id_alphabet: str) -> int:
- alphabet = list(ascii_lowercase)[:10]
- user_id = ""
- for i in user_id_alphabet:
- index = alphabet.index(i)
- user_id += str(index)
- user_id = int(user_id)
- return user_id
- async def get_warns_count() -> dict:
- chats_count = 0
- warns_count = 0
- async for chat in warnsdb.find({"chat_id": {"$lt": 0}}):
- for user in chat["warns"]:
- warns_count += chat["warns"][user]["warns"]
- chats_count += 1
- return {"chats_count": chats_count, "warns_count": warns_count}
- async def get_warns(chat_id: int) -> Dict[str, int]:
- warns = await warnsdb.find_one({"chat_id": chat_id})
- if not warns:
- return {}
- return warns["warns"]
- async def get_warn(chat_id: int, name: str) -> Union[bool, dict]:
- name = name.lower().strip()
- warns = await get_warns(chat_id)
- if name in warns:
- return warns[name]
- async def add_warn(chat_id: int, name: str, warn: dict):
- name = name.lower().strip()
- warns = await get_warns(chat_id)
- warns[name] = warn
- await warnsdb.update_one(
- {"chat_id": chat_id}, {"$set": {"warns": warns}}, upsert=True
- )
- async def remove_warns(chat_id: int, name: str) -> bool:
- warnsd = await get_warns(chat_id)
- name = name.lower().strip()
- if name in warnsd:
- del warnsd[name]
- await warnsdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"warns": warnsd}},
- upsert=True,
- )
- return True
- return False
- async def get_karmas_count() -> dict:
- chats_count = 0
- karmas_count = 0
- async for chat in karmadb.find({"chat_id": {"$lt": 0}}):
- for i in chat["karma"]:
- karma_ = chat["karma"][i]["karma"]
- if karma_ > 0:
- karmas_count += karma_
- chats_count += 1
- return {"chats_count": chats_count, "karmas_count": karmas_count}
- async def user_global_karma(user_id) -> int:
- total_karma = 0
- async for chat in karmadb.find({"chat_id": {"$lt": 0}}):
- karma = chat["karma"].get(await int_to_alpha(user_id))
- if karma and (int(karma["karma"]) > 0):
- total_karma += int(karma["karma"])
- return total_karma
- async def get_karmas(chat_id: int) -> Dict[str, int]:
- karma = await karmadb.find_one({"chat_id": chat_id})
- if not karma:
- return {}
- return karma["karma"]
- async def get_karma(chat_id: int, name: str) -> Union[bool, dict]:
- name = name.lower().strip()
- karmas = await get_karmas(chat_id)
- if name in karmas:
- return karmas[name]
- async def update_karma(chat_id: int, name: str, karma: dict):
- name = name.lower().strip()
- karmas = await get_karmas(chat_id)
- karmas[name] = karma
- await karmadb.update_one(
- {"chat_id": chat_id}, {"$set": {"karma": karmas}}, upsert=True
- )
- async def is_karma_on(chat_id: int) -> bool:
- chat = await karmadb.find_one({"chat_id_toggle": chat_id})
- if not chat:
- return True
- return False
- async def karma_on(chat_id: int):
- is_karma = await is_karma_on(chat_id)
- if is_karma:
- return
- return await karmadb.delete_one({"chat_id_toggle": chat_id})
- async def karma_off(chat_id: int):
- is_karma = await is_karma_on(chat_id)
- if not is_karma:
- return
- return await karmadb.insert_one({"chat_id_toggle": chat_id})
- async def is_served_chat(chat_id: int) -> bool:
- chat = await chatsdb.find_one({"chat_id": chat_id})
- if not chat:
- return False
- return True
- async def get_served_chats() -> list:
- chats_list = []
- async for chat in chatsdb.find({"chat_id": {"$lt": 0}}):
- chats_list.append(chat)
- return chats_list
- async def add_served_chat(chat_id: int):
- is_served = await is_served_chat(chat_id)
- if is_served:
- return
- return await chatsdb.insert_one({"chat_id": chat_id})
- async def remove_served_chat(chat_id: int):
- is_served = await is_served_chat(chat_id)
- if not is_served:
- return
- return await chatsdb.delete_one({"chat_id": chat_id})
- async def is_served_user(user_id: int) -> bool:
- user = await usersdb.find_one({"user_id": user_id})
- if not user:
- return False
- return True
- async def get_served_users() -> list:
- users_list = []
- async for user in usersdb.find({"user_id": {"$gt": 0}}):
- users_list.append(user)
- return users_list
- async def add_served_user(user_id: int):
- is_served = await is_served_user(user_id)
- if is_served:
- return
- return await usersdb.insert_one({"user_id": user_id})
- async def get_gbans_count() -> int:
- return len([i async for i in gbansdb.find({"user_id": {"$gt": 0}})])
- async def is_gbanned_user(user_id: int) -> bool:
- user = await gbansdb.find_one({"user_id": user_id})
- if not user:
- return False
- return True
- async def add_gban_user(user_id: int):
- is_gbanned = await is_gbanned_user(user_id)
- if is_gbanned:
- return
- return await gbansdb.insert_one({"user_id": user_id})
- async def remove_gban_user(user_id: int):
- is_gbanned = await is_gbanned_user(user_id)
- if not is_gbanned:
- return
- return await gbansdb.delete_one({"user_id": user_id})
- async def _get_lovers(chat_id: int):
- lovers = await coupledb.find_one({"chat_id": chat_id})
- if not lovers:
- return {}
- return lovers["couple"]
- async def get_couple(chat_id: int, date: str):
- lovers = await _get_lovers(chat_id)
- if date in lovers:
- return lovers[date]
- return False
- async def save_couple(chat_id: int, date: str, couple: dict):
- lovers = await _get_lovers(chat_id)
- lovers[date] = couple
- await coupledb.update_one(
- {"chat_id": chat_id},
- {"$set": {"couple": lovers}},
- upsert=True,
- )
- async def is_captcha_on(chat_id: int) -> bool:
- settings = await get_managed_chat_settings(chat_id)
- return bool(settings.get("captcha_enabled", False))
- async def captcha_on(chat_id: int):
- await update_managed_chat_settings(chat_id, {"captcha_enabled": True})
- return await captchadb.delete_many({"chat_id": chat_id})
- async def captcha_off(chat_id: int):
- await update_managed_chat_settings(chat_id, {"captcha_enabled": False})
- return await captchadb.update_one(
- {"chat_id": chat_id}, {"$set": {"chat_id": chat_id}}, upsert=True
- )
- async def has_solved_captcha_once(chat_id: int, user_id: int):
- has_solved = await solved_captcha_db.find_one(
- {"chat_id": chat_id, "user_id": user_id}
- )
- return bool(has_solved)
- async def save_captcha_solved(chat_id: int, user_id: int):
- return await solved_captcha_db.update_one(
- {"chat_id": chat_id, "user_id": user_id},
- {"$set": {"chat_id": chat_id, "user_id": user_id}},
- upsert=True,
- )
- async def is_antiservice_on(chat_id: int) -> bool:
- chat = await antiservicedb.find_one({"chat_id": chat_id})
- if not chat:
- return True
- return False
- async def antiservice_on(chat_id: int):
- is_antiservice = await is_antiservice_on(chat_id)
- if is_antiservice:
- return
- return await antiservicedb.delete_one({"chat_id": chat_id})
- async def antiservice_off(chat_id: int):
- is_antiservice = await is_antiservice_on(chat_id)
- if not is_antiservice:
- return
- return await antiservicedb.insert_one({"chat_id": chat_id})
- async def is_pmpermit_approved(user_id: int) -> bool:
- user = await pmpermitdb.find_one({"user_id": user_id})
- if not user:
- return False
- return True
- async def approve_pmpermit(user_id: int):
- is_pmpermit = await is_pmpermit_approved(user_id)
- if is_pmpermit:
- return
- return await pmpermitdb.insert_one({"user_id": user_id})
- async def disapprove_pmpermit(user_id: int):
- is_pmpermit = await is_pmpermit_approved(user_id)
- if not is_pmpermit:
- return
- return await pmpermitdb.delete_one({"user_id": user_id})
- async def get_welcome(chat_id: int) -> (str, str, str):
- data = await welcomedb.find_one({"chat_id": chat_id})
- if not data:
- return "", "", ""
- welcome = data.get("welcome", "")
- raw_text = data.get("raw_text", "")
- file_id = data.get("file_id", "")
- return welcome, raw_text, file_id
- async def set_welcome(chat_id: int, welcome: str, raw_text: str, file_id: str):
- update_data = {
- "welcome": welcome,
- "raw_text": raw_text,
- "file_id": file_id,
- }
- return await welcomedb.update_one(
- {"chat_id": chat_id}, {"$set": update_data}, upsert=True
- )
- async def del_welcome(chat_id: int):
- return await welcomedb.delete_one({"chat_id": chat_id})
- async def update_captcha_cache(captcha_dict):
- pickle = obj_to_str(captcha_dict)
- await captcha_cachedb.delete_one({"captcha": "cache"})
- if not pickle:
- return
- await captcha_cachedb.update_one(
- {"captcha": "cache"},
- {"$set": {"pickled": pickle}},
- upsert=True,
- )
- async def get_captcha_cache():
- cache = await captcha_cachedb.find_one({"captcha": "cache"})
- if not cache:
- return []
- return str_to_obj(cache["pickled"])
- async def get_blacklist_filters_count() -> dict:
- chats_count = 0
- filters_count = 0
- async for chat in blacklist_filtersdb.find({"chat_id": {"$lt": 0}}):
- filters = await get_blacklisted_words(chat["chat_id"])
- filters_count += len(filters)
- chats_count += 1
- return {
- "chats_count": chats_count,
- "filters_count": filters_count,
- }
- async def get_blacklisted_words(chat_id: int) -> List[str]:
- _filters = await blacklist_filtersdb.find_one({"chat_id": chat_id})
- if not _filters:
- return []
- return _filters["filters"]
- async def save_blacklist_filter(chat_id: int, word: str):
- word = word.lower().strip()
- _filters = await get_blacklisted_words(chat_id)
- _filters.append(word)
- await blacklist_filtersdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"filters": _filters}},
- upsert=True,
- )
- async def delete_blacklist_filter(chat_id: int, word: str) -> bool:
- filtersd = await get_blacklisted_words(chat_id)
- word = word.lower().strip()
- if word in filtersd:
- filtersd.remove(word)
- await blacklist_filtersdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"filters": filtersd}},
- upsert=True,
- )
- return True
- return False
- async def activate_pipe(from_chat_id: int, to_chat_id: int, fetcher: str):
- pipes = await show_pipes()
- pipe = {
- "from_chat_id": from_chat_id,
- "to_chat_id": to_chat_id,
- "fetcher": fetcher,
- }
- pipes.append(pipe)
- return await pipesdb.update_one(
- {"pipe": "pipe"}, {"$set": {"pipes": pipes}}, upsert=True
- )
- async def deactivate_pipe(from_chat_id: int, to_chat_id: int):
- pipes = await show_pipes()
- if not pipes:
- return
- for pipe in pipes:
- if (
- pipe["from_chat_id"] == from_chat_id
- and pipe["to_chat_id"] == to_chat_id
- ):
- pipes.remove(pipe)
- return await pipesdb.update_one(
- {"pipe": "pipe"}, {"$set": {"pipes": pipes}}, upsert=True
- )
- async def is_pipe_active(from_chat_id: int, to_chat_id: int) -> bool:
- for pipe in await show_pipes():
- if (
- pipe["from_chat_id"] == from_chat_id
- and pipe["to_chat_id"] == to_chat_id
- ):
- return True
- async def show_pipes() -> list:
- pipes = await pipesdb.find_one({"pipe": "pipe"})
- if not pipes:
- return []
- return pipes["pipes"]
- async def get_sudoers() -> list:
- sudoers = await sudoersdb.find_one({"sudo": "sudo"})
- if not sudoers:
- return []
- return sudoers["sudoers"]
- async def add_sudo(user_id: int) -> bool:
- sudoers = await get_sudoers()
- sudoers.append(user_id)
- await sudoersdb.update_one(
- {"sudo": "sudo"}, {"$set": {"sudoers": sudoers}}, upsert=True
- )
- return True
- async def remove_sudo(user_id: int) -> bool:
- sudoers = await get_sudoers()
- sudoers.remove(user_id)
- await sudoersdb.update_one(
- {"sudo": "sudo"}, {"$set": {"sudoers": sudoers}}, upsert=True
- )
- return True
- async def blacklisted_chats() -> list:
- blacklist_chat = []
- async for chat in blacklist_chatdb.find({"chat_id": {"$lt": 0}}):
- blacklist_chat.append(chat["chat_id"])
- return blacklist_chat
- async def blacklist_chat(chat_id: int) -> bool:
- if not await blacklist_chatdb.find_one({"chat_id": chat_id}):
- await blacklist_chatdb.insert_one({"chat_id": chat_id})
- return True
- return False
- async def whitelist_chat(chat_id: int) -> bool:
- if await blacklist_chatdb.find_one({"chat_id": chat_id}):
- await blacklist_chatdb.delete_one({"chat_id": chat_id})
- return True
- return False
- async def start_restart_stage(chat_id: int, message_id: int):
- await restart_stagedb.update_one(
- {"something": "something"},
- {
- "$set": {
- "chat_id": chat_id,
- "message_id": message_id,
- }
- },
- upsert=True,
- )
- async def clean_restart_stage() -> dict:
- data = await restart_stagedb.find_one({"something": "something"})
- if not data:
- return {}
- await restart_stagedb.delete_one({"something": "something"})
- return {
- "chat_id": data["chat_id"],
- "message_id": data["message_id"],
- }
- async def is_flood_on(chat_id: int) -> bool:
- chat = await flood_toggle_db.find_one({"chat_id": chat_id})
- if not chat:
- return True
- return False
- async def flood_on(chat_id: int):
- is_flood = await is_flood_on(chat_id)
- if is_flood:
- return
- return await flood_toggle_db.delete_one({"chat_id": chat_id})
- async def flood_off(chat_id: int):
- is_flood = await is_flood_on(chat_id)
- if not is_flood:
- return
- return await flood_toggle_db.insert_one({"chat_id": chat_id})
- async def add_rss_feed(chat_id: int, url: str, last_title: str):
- return await rssdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"url": url, "last_title": last_title}},
- upsert=True,
- )
- async def remove_rss_feed(chat_id: int):
- return await rssdb.delete_one({"chat_id": chat_id})
- async def update_rss_feed(chat_id: int, last_title: str):
- return await rssdb.update_one(
- {"chat_id": chat_id},
- {"$set": {"last_title": last_title}},
- upsert=True,
- )
- async def is_rss_active(chat_id: int) -> bool:
- return await rssdb.find_one({"chat_id": chat_id})
- async def get_rss_feeds() -> list:
- data = []
- async for feed in rssdb.find({"chat_id": {"$exists": 1}}):
- data.append(
- dict(
- chat_id=feed["chat_id"],
- url=feed["url"],
- last_title=feed["last_title"],
- )
- )
- return data
- async def get_rss_feeds_count() -> int:
- return len([i async for i in rssdb.find({"chat_id": {"$exists": 1}})])
- async def check_chatbot():
- return await chatbotdb.find_one({"chatbot": "chatbot"}) or {
- "bot": [],
- "userbot": [],
- }
- async def add_chatbot(chat_id: int, is_userbot: bool = False):
- list_id = await check_chatbot()
- if is_userbot:
- list_id["userbot"].append(chat_id)
- else:
- list_id["bot"].append(chat_id)
- await chatbotdb.update_one(
- {"chatbot": "chatbot"}, {"$set": list_id}, upsert=True
- )
- async def rm_chatbot(chat_id: int, is_userbot: bool = False):
- list_id = await check_chatbot()
- if is_userbot:
- list_id["userbot"].remove(chat_id)
- else:
- list_id["bot"].remove(chat_id)
- await chatbotdb.update_one(
- {"chatbot": "chatbot"}, {"$set": list_id}, upsert=True
- )
|