Skip to content

Commit

Permalink
user settings fix
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <[email protected]>
  • Loading branch information
anasty17 committed Oct 4, 2022
1 parent 3e5281f commit 195d60d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_content_type(link: str) -> str:
content_type = None
return content_type

def update_user_ldata(id_: str, key, value):
def update_user_ldata(id_: int, key, value):
if id_ in user_data:
user_data[id_][key] = value
else:
Expand Down
11 changes: 6 additions & 5 deletions bot/modules/users_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def getleechinfo(from_user):
name = from_user.full_name
buttons = button_build.ButtonMaker()
thumbpath = f"Thumbnails/{user_id}.jpg"
if user_id in user_data and (user_data[user_id].get('as_doc') or (not user_data[user_id].get('as_media') \
and AS_DOCUMENT)):
user_dict = user_data.get(user_id, False)
if not user_dict and AS_DOCUMENT or user_dict and (user_dict.get('as_doc') or \
(not user_dict.get('as_media') and AS_DOCUMENT)):
ltype = "DOCUMENT"
buttons.sbutton("Send As Media", f"leechset {user_id} med")
else:
Expand All @@ -33,7 +34,7 @@ def getleechinfo(from_user):

buttons.sbutton("Close", f"leechset {user_id} close")
button = buttons.build_menu(1)
text = f"<u>Leech Settings for <a href='tg://user?id={user_id}'>{name}</a></u>\n"\
text = f"<u>Settings for <a href='tg://user?id={user_id}'>{name}</a></u>\n"\
f"Leech Type <b>{ltype}</b>\n"\
f"Custom Thumbnail <b>{thumbmsg}</b>"
return text, button
Expand All @@ -57,15 +58,15 @@ def setLeechType(update, context):
query.answer(text="Not Yours!", show_alert=True)
elif data[2] == "doc":
if user_id in user_data and user_data[user_id].get('as_media'):
update_user_ldata(user_id, 'as_media', False)
user_data[user_id]['as_media'] = False
update_user_ldata(user_id, 'as_doc', True)
if DB_URI is not None:
DbManger().update_user_data(user_id)
query.answer(text="Your File Will Deliver As Document!", show_alert=True)
editLeechType(message, query)
elif data[2] == "med":
if user_id in user_data and user_data[user_id].get('as_doc'):
update_user_ldata(user_id, 'as_doc', False)
user_data[user_id]['as_doc'] = False
update_user_ldata(user_id, 'as_media', True)
if DB_URI is not None:
DbManger().update_user_data(user_id)
Expand Down

0 comments on commit 195d60d

Please sign in to comment.