diff --git a/davtelepot/api.py b/davtelepot/api.py index fb5ca78..b0ccd0d 100644 --- a/davtelepot/api.py +++ b/davtelepot/api.py @@ -208,15 +208,15 @@ class TelegramBot(object): try: certificate = open(certificate, 'r') except FileNotFoundError as e: - logging.error(f"{e}") + logging.error(f"{e}\nCertificate set to `None`") certificate = None - # certificate = dict( - # file=certificate - # ) - return await self.api_request( + result = await self.api_request( 'setWebhook', parameters=locals() ) + if certificate is not None: # Close certificate file, if it was open + certificate.close() + return result async def deleteWebhook(self): """Remove webhook integration and switch back to getUpdate.