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

View File

@ -314,32 +314,12 @@ class Bot(davtelepot.bot.Bot):
) )
return return
async def handle_location(self, update): async def handle_location(self, *args, **kwargs):
"""Handle location sent by user.""" """Handle location sent by user.
user_id = update['from']['id'] if 'from' in update else None
answerer, answer = None, None This method is deprecated: use `location_message_handler` instead.
if self.maintenance: """
if update['chat']['id'] > 0: return await super().location_message_handler(*args, **kwargs)
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
def set_custom_parser(self, parser, update=None, user=None): def set_custom_parser(self, parser, update=None, user=None):
"""Set a custom parser for the user. """Set a custom parser for the user.