2016-01-04 17:31:06 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# pylint: disable=R0902,R0912,R0913
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2018-01-04 16:16:06 +01:00
|
|
|
# Copyright (C) 2015-2018
|
2017-05-14 12:18:29 +02:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
2016-01-04 17:31:06 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2017-07-23 22:33:08 +02:00
|
|
|
"""This module contains an object that represents a Telegram ChosenInlineResult."""
|
2016-01-04 17:31:06 +01:00
|
|
|
|
2016-04-14 07:21:00 +02:00
|
|
|
from telegram import TelegramObject, User, Location
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ChosenInlineResult(TelegramObject):
|
2017-07-23 22:33:08 +02:00
|
|
|
"""
|
|
|
|
Represents a result of an inline query that was chosen by the user and sent to their chat
|
|
|
|
partner.
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
Note:
|
2017-07-23 22:33:08 +02:00
|
|
|
In Python `from` is a reserved word, use `from_user` instead.
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
Attributes:
|
2017-07-23 22:33:08 +02:00
|
|
|
result_id (:obj:`str`): The unique identifier for the result that was chosen.
|
|
|
|
from_user (:class:`telegram.User`): The user that chose the result.
|
|
|
|
location (:class:`telegram.Location`): Optional. Sender location.
|
|
|
|
inline_message_id (:obj:`str`): Optional. Identifier of the sent inline message.
|
|
|
|
query (:obj:`str`): The query that was used to obtain the result.
|
2016-01-04 17:31:06 +01:00
|
|
|
|
|
|
|
Args:
|
2017-07-23 22:33:08 +02:00
|
|
|
result_id (:obj:`str`): The unique identifier for the result that was chosen.
|
|
|
|
from_user (:class:`telegram.User`): The user that chose the result.
|
|
|
|
location (:class:`telegram.Location`, optional): Sender location, only for bots that
|
|
|
|
require user location.
|
|
|
|
inline_message_id (:obj:`str`, optional): Identifier of the sent inline message. Available
|
|
|
|
only if there is an inline keyboard attached to the message. Will be also received in
|
|
|
|
callback queries and can be used to edit the message.
|
|
|
|
query (:obj:`str`): The query that was used to obtain the result.
|
|
|
|
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
|
2017-09-01 08:43:08 +02:00
|
|
|
|
2016-01-04 17:31:06 +01:00
|
|
|
"""
|
|
|
|
|
2016-05-24 01:43:17 +02:00
|
|
|
def __init__(self,
|
|
|
|
result_id,
|
|
|
|
from_user,
|
|
|
|
query,
|
|
|
|
location=None,
|
|
|
|
inline_message_id=None,
|
|
|
|
**kwargs):
|
2016-01-04 17:31:06 +01:00
|
|
|
# Required
|
2016-02-07 23:26:38 +01:00
|
|
|
self.result_id = result_id
|
2016-01-04 17:31:06 +01:00
|
|
|
self.from_user = from_user
|
|
|
|
self.query = query
|
2016-04-14 07:21:00 +02:00
|
|
|
# Optionals
|
|
|
|
self.location = location
|
|
|
|
self.inline_message_id = inline_message_id
|
2016-01-04 17:31:06 +01:00
|
|
|
|
2017-05-14 23:29:31 +02:00
|
|
|
self._id_attrs = (self.result_id,)
|
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
@classmethod
|
|
|
|
def de_json(cls, data, bot):
|
2016-01-04 17:31:06 +01:00
|
|
|
if not data:
|
|
|
|
return None
|
2016-04-14 08:40:26 +02:00
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
data = super(ChosenInlineResult, cls).de_json(data, bot)
|
2016-12-19 23:07:35 +01:00
|
|
|
# Required
|
2016-09-20 06:36:55 +02:00
|
|
|
data['from_user'] = User.de_json(data.pop('from'), bot)
|
2016-04-14 08:40:26 +02:00
|
|
|
# Optionals
|
2016-09-20 06:36:55 +02:00
|
|
|
data['location'] = Location.de_json(data.get('location'), bot)
|
2016-02-07 23:26:38 +01:00
|
|
|
|
2017-07-23 21:14:38 +02:00
|
|
|
return cls(**data)
|