mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
* ci: Update .deepsource.toml
* ci: Update .deepsource.toml
* style: format code with black and isort
Format code with black and isort
This commit fixes the style issues introduced in 0fb651a according to the output
from Black and isort.
Details: https://app.deepsource.com/gh/yasirarism/MissKatyPyro/transform/d8f2f66e-b496-4686-aca6-9830236eda12/
---------
Co-authored-by: deepsource-io[bot] <42547082+deepsource-io[bot]@users.noreply.github.com>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
#
|
|
# Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >.
|
|
#
|
|
# This file is part of < https://github.com/TeamYukki/YukkiAFKBot > project,
|
|
# and is released under the "GNU v3.0 License Agreement".
|
|
# Please see < https://github.com/TeamYukki/YukkiAFKBot/blob/master/LICENSE >
|
|
#
|
|
# All rights reserved.
|
|
#
|
|
|
|
from database import dbname
|
|
|
|
usersdb = dbname["users"]
|
|
cleandb = dbname["cleanmode"]
|
|
cleanmode = {}
|
|
|
|
|
|
async def is_cleanmode_on(chat_id: int) -> bool:
|
|
mode = cleanmode.get(chat_id)
|
|
if not mode:
|
|
user = await cleandb.find_one({"chat_id": chat_id})
|
|
if not user:
|
|
cleanmode[chat_id] = True
|
|
return True
|
|
cleanmode[chat_id] = False
|
|
return False
|
|
return mode
|
|
|
|
|
|
async def cleanmode_on(chat_id: int):
|
|
cleanmode[chat_id] = True
|
|
user = await cleandb.find_one({"chat_id": chat_id})
|
|
if user:
|
|
return await cleandb.delete_one({"chat_id": chat_id})
|
|
|
|
|
|
async def cleanmode_off(chat_id: int):
|
|
cleanmode[chat_id] = False
|
|
user = await cleandb.find_one({"chat_id": chat_id})
|
|
if not user:
|
|
return await cleandb.insert_one({"chat_id": chat_id})
|
|
|
|
|
|
async def is_afk(user_id: int) -> bool:
|
|
user = await usersdb.find_one({"user_id": user_id})
|
|
return (True, user["reason"]) if user else (False, {})
|
|
|
|
|
|
async def add_afk(user_id: int, mode):
|
|
await usersdb.update_one(
|
|
{"user_id": user_id}, {"$set": {"reason": mode}}, upsert=True
|
|
)
|
|
|
|
|
|
async def remove_afk(user_id: int):
|
|
user = await usersdb.find_one({"user_id": user_id})
|
|
if user:
|
|
return await usersdb.delete_one({"user_id": user_id})
|
|
|
|
|
|
async def get_afk_users() -> list:
|
|
users = usersdb.find({"user_id": {"$gt": 0}})
|
|
return list(await users.to_list(length=1000000000)) if users else []
|