Mahesh0253 / Media-Search-bot

Inline bot for channels and groups
GNU General Public License v2.0
555 stars 1.15k forks source link

Update userbot.py #79

Closed Thajudecodes closed 1 year ago

Thajudecodes commented 1 year ago

I have cleared some of the main errors chek it out

Mahesh0253 commented 1 year ago

Which errors you have cleared in this pull request?

Thajudecodes commented 1 year ago
  1. Avoid using except Exception as e as it is too broad and catches too many exceptions, making it difficult to understand what went wrong.

  2. Use the with statement to automatically close the user-bot client instead of manually closing it.

3.Consider using async for to iterate over the chat history as it's an asynchronous operation.

4.Use the async with statement for lock instead of using a lock instance.

$ Sorry i cant tell that it is errors but i improved the code by a little bit . Condider , all into you

Mahesh0253 commented 1 year ago

If you check code properly, already async context manager is used for user-bot client and async lock. Also async for loop is used for get_history function.

Incase error occurs, except Exception will only call once and Python logging module will log error to track what is went wrong.

I don't see any functional improvement in this PR, thus closing it.