handle_location method deprecated

This commit is contained in:
Davte 2019-07-22 18:23:39 +02:00
parent c1c9f7dd78
commit 637dca7af2
2 changed files with 7 additions and 27 deletions

View File

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0"
__version__ = "2.1.29"
__version__ = "2.1.30"
__maintainer__ = "Davide Testa"
__contact__ = "t.me/davte"

View File

@ -314,32 +314,12 @@ class Bot(davtelepot.bot.Bot):
)
return
async def handle_location(self, update):
"""Handle location sent by user."""
user_id = update['from']['id'] if 'from' in update else None
answerer, answer = None, None
if self.maintenance:
if update['chat']['id'] > 0:
answer = self.maintenance_message
elif user_id in self.custom_location_parsers:
answerer = self.custom_location_parsers[user_id]
del self.custom_location_parsers[user_id]
if answerer:
if asyncio.iscoroutinefunction(answerer):
answer = await answerer(update)
else:
answer = answerer(update)
if answer:
try:
return await self.send_message(answer=answer, chat_id=update)
except Exception as e:
logging.error(
"Failed to process answer:\n{}".format(
e
),
exc_info=True
)
return
async def handle_location(self, *args, **kwargs):
"""Handle location sent by user.
This method is deprecated: use `location_message_handler` instead.
"""
return await super().location_message_handler(*args, **kwargs)
def set_custom_parser(self, parser, update=None, user=None):
"""Set a custom parser for the user.