Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new parameter getupdates_error_handler to Bot.run function #112

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kian-ahmadian
Copy link
Member

@kian-ahmadian kian-ahmadian commented Jul 7, 2024

  • Add new parameter getupdates_error_handler to Bot.run function
  • Add explanation for checking update_id
  • Modify the return value of the function default_getupdates_error_handler so that the updater continues.
  • Update docs

@kian-ahmadian kian-ahmadian self-assigned this Jul 7, 2024
@kian-ahmadian kian-ahmadian added bale bug Something isn't working (for bale servers) updater section PRs related to the updater section. labels Jul 7, 2024
@kian-ahmadian kian-ahmadian changed the title Add new parameter getupdates_error_handler to Bot.run function Add new parameter getupdates_error_handler to Bot.run function Jul 7, 2024
@@ -2309,7 +2311,7 @@
if updater := self._updater:
startup_functions.append(self.get_me)
startup_functions.append(updater.setup)
operation_coroutine.append(updater.start_polling())
operation_coroutine.append(updater.start_polling(getupdates_error_handler=getupdates_error_handler))

Check warning

Code scanning / Prospector (reported by Codacy)

Undefined variable 'getupdates_error_handler' (undefined-variable) Warning

Undefined variable 'getupdates_error_handler' (undefined-variable)
await self.bot.update_queue.put(update)
self._last_offset = updates[-1].update_id

return True

def getupdates_error(exc: Any) -> bool:
def default_getupdates_error_handler(exc: Any) -> bool:

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning

Missing function docstring
@@ -60,7 +61,7 @@

self.__stop_worker_event = asyncio.Event()

async def start_polling(self):
async def start_polling(self, getupdates_error_handler: Callable[[Any], bool] = None):

Check warning

Code scanning / Pylint (reported by Codacy)

Missing method docstring Warning

Missing method docstring
@@ -110,11 +114,15 @@
try:
work_task = asyncio.create_task(work_coroutine())

done = (await asyncio.wait([work_task, wait_stop_task], return_when=asyncio.FIRST_COMPLETED))[0]
done = (
await asyncio.wait([work_task, wait_stop_task], return_when=asyncio.FIRST_COMPLETED)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (104/100) Warning

Line too long (104/100)
if not self.current_offset or update.update_id > self.current_offset:
if (
not self.current_offset or
update.update_id > self.current_offset # This is due to a bug sometimes caused by the Bale servers.

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (128/100) Warning

Line too long (128/100)
@@ -110,11 +114,15 @@
try:
work_task = asyncio.create_task(work_coroutine())

done = (await asyncio.wait([work_task, wait_stop_task], return_when=asyncio.FIRST_COMPLETED))[0]
done = (
await asyncio.wait([work_task, wait_stop_task], return_when=asyncio.FIRST_COMPLETED)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (104/100) Warning

Line too long (104/100)
if not self.current_offset or update.update_id > self.current_offset:
if (
not self.current_offset or
update.update_id > self.current_offset # This is due to a bug sometimes caused by the Bale servers.

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (128/100) Warning

Line too long (128/100)
@@ -60,7 +61,7 @@

self.__stop_worker_event = asyncio.Event()

async def start_polling(self):
async def start_polling(self, getupdates_error_handler: Callable[[Any], bool] = None):

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning

Missing function or method docstring
@@ -2309,7 +2311,7 @@
if updater := self._updater:
startup_functions.append(self.get_me)
startup_functions.append(updater.setup)
operation_coroutine.append(updater.start_polling())
operation_coroutine.append(updater.start_polling(getupdates_error_handler=getupdates_error_handler))

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (112/100) Warning

Line too long (112/100)
@@ -2309,7 +2311,7 @@
if updater := self._updater:
startup_functions.append(self.get_me)
startup_functions.append(updater.setup)
operation_coroutine.append(updater.start_polling())
operation_coroutine.append(updater.start_polling(getupdates_error_handler=getupdates_error_handler))

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Undefined variable 'getupdates_error_handler' Warning

Undefined variable 'getupdates_error_handler'
@kian-ahmadian kian-ahmadian linked an issue Jul 7, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bale bug Something isn't working (for bale servers) updater section PRs related to the updater section.
Projects
None yet
2 participants