Skip to content

Commit

Permalink
Fix users data view /users
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Dec 15, 2023
1 parent d1ce4c1 commit 2f2793b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/db_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async def update_private_file(self, path):
async def update_user_data(self, user_id):
if self._err:
return
data = user_data[user_id]
data = user_data.get(user_id, {})
if data.get("thumb"):
del data["thumb"]
if data.get("rclone_config"):
Expand Down
13 changes: 9 additions & 4 deletions bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,13 @@ async def edit_user_settings(client, query):
await DbManger().update_user_data(user_id)
elif data[2] == "reset":
await query.answer()
if user_data.get(user_id, {}):
user_data[user_id].clear()
if ud := user_data.get(user_id, {}):
if ud and ('is_sudo' in ud or 'is_auth' in ud):
for k in list(ud.keys()):
if k not in ['is_sudo', 'is_auth']:
del user_data[user_id][k]
else:
user_data[user_id].clear()
await update_user_settings(query)
if DATABASE_URL:
await DbManger().update_user_data(user_id)
Expand All @@ -664,12 +669,12 @@ async def edit_user_settings(client, query):
await deleteMessage(message)


async def send_users_settings(client, message):
async def send_users_settings(_, message):
if user_data:
msg = ""
for u, d in user_data.items():
kmsg = f"\n<b>{u}:</b>\n"
if vmsg := "".join(f"{k}: <code>{v}</code>\n" for k, v in d.items() if v):
if vmsg := "".join(f"{k}: <code>{v}</code>\n" for k, v in d.items() if f"{v}"):
msg += kmsg + vmsg

msg_ecd = msg.encode()
Expand Down

0 comments on commit 2f2793b

Please sign in to comment.