python-telegram-bot/telegram/_inline/inlinequeryresult.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.4 KiB
Python
Raw Normal View History

2016-01-04 17:31:06 +01:00
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
2022-01-03 08:15:18 +01:00
# Copyright (C) 2015-2022
# 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/].
# pylint: disable=redefined-builtin
2017-09-01 08:43:08 +02:00
"""This module contains the classes that represent Telegram InlineQueryResult."""
2016-01-04 17:31:06 +01:00
2020-10-06 19:28:40 +02:00
from typing import Any
2016-01-04 17:31:06 +01:00
from telegram._telegramobject import TelegramObject
from telegram._utils.types import JSONDict
2016-01-04 17:31:06 +01:00
class InlineQueryResult(TelegramObject):
2017-09-01 08:43:08 +02:00
"""Baseclass for the InlineQueryResult* classes.
2016-01-04 17:31:06 +01:00
Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`id` is equal.
API 5.1 (#2424) * Feat: New invite links * Fix: doc strings Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> * new dice, new admin privilege, revoke_messages, update and fix some docs * add missing param to shortcut * Add ChatMemberUpdated * Add voicechat related objects Signed-off-by: starry69 <starry369126@outlook.com> * add versionadd tags Signed-off-by: starry69 <starry369126@outlook.com> * Fix filter tests * Update tg.Update * ChatMemberHandler * Add versioning directives * add can_manage_voice_chats attr and fix docs Signed-off-by: starry69 <starry369126@outlook.com> * fix chat shortcut Signed-off-by: starry69 <starry369126@outlook.com> * address review * MADTC * Chat.message_auto_delete_time * Some doc fixes * address review Signed-off-by: starry69 <starry369126@outlook.com> * welp Signed-off-by: starry69 <starry369126@outlook.com> * Add voicechat related filters Signed-off-by: starry69 <starry369126@outlook.com> * Fix: Addressing review change place of version adding, added obj:True as doc string, changing how member limit is initiated * feat: adding chat shortcuts for invite links * fix: changing equality of chatinviteobjects * Non-test comments * Some test fixes * A bit more tests * Bump API version in both readmes * Increase coverage * Add Bot API Version in telegram.constants (#2429) * add bot api version in constants Signed-off-by: starry69 <starry369126@outlook.com> * addressing review Signed-off-by: starry69 <starry369126@outlook.com> * add versioning directive Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> * pre-commit & coverage Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> Co-authored-by: Harshil <ilovebhagwan@gmail.com> Co-authored-by: starry69 <starry369126@outlook.com>
2021-03-14 16:41:35 +01:00
Note:
All URLs passed in inline query results will be available to end users and therefore must
be assumed to be *public*.
API 5.1 (#2424) * Feat: New invite links * Fix: doc strings Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> * new dice, new admin privilege, revoke_messages, update and fix some docs * add missing param to shortcut * Add ChatMemberUpdated * Add voicechat related objects Signed-off-by: starry69 <starry369126@outlook.com> * add versionadd tags Signed-off-by: starry69 <starry369126@outlook.com> * Fix filter tests * Update tg.Update * ChatMemberHandler * Add versioning directives * add can_manage_voice_chats attr and fix docs Signed-off-by: starry69 <starry369126@outlook.com> * fix chat shortcut Signed-off-by: starry69 <starry369126@outlook.com> * address review * MADTC * Chat.message_auto_delete_time * Some doc fixes * address review Signed-off-by: starry69 <starry369126@outlook.com> * welp Signed-off-by: starry69 <starry369126@outlook.com> * Add voicechat related filters Signed-off-by: starry69 <starry369126@outlook.com> * Fix: Addressing review change place of version adding, added obj:True as doc string, changing how member limit is initiated * feat: adding chat shortcuts for invite links * fix: changing equality of chatinviteobjects * Non-test comments * Some test fixes * A bit more tests * Bump API version in both readmes * Increase coverage * Add Bot API Version in telegram.constants (#2429) * add bot api version in constants Signed-off-by: starry69 <starry369126@outlook.com> * addressing review Signed-off-by: starry69 <starry369126@outlook.com> * add versioning directive Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> * pre-commit & coverage Co-authored-by: Bibo-Joshi <hinrich.mahler@freenet.de> Co-authored-by: Harshil <ilovebhagwan@gmail.com> Co-authored-by: starry69 <starry369126@outlook.com>
2021-03-14 16:41:35 +01:00
Args:
type (:obj:`str`): Type of the result.
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
2016-01-04 17:31:06 +01:00
Attributes:
type (:obj:`str`): Type of the result.
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
2017-09-01 08:43:08 +02:00
2016-01-04 17:31:06 +01:00
"""
__slots__ = ("type", "id")
def __init__(self, type: str, id: str, **_kwargs: Any): # pylint: disable=invalid-name
2016-01-04 17:31:06 +01:00
# Required
self.type = type
self.id = str(id) # pylint: disable=invalid-name
2016-01-04 17:31:06 +01:00
self._id_attrs = (self.id,)
def to_dict(self) -> JSONDict:
"""See :meth:`telegram.TelegramObject.to_dict`."""
data = super().to_dict()
# pylint: disable=no-member
if (
hasattr(self, "caption_entities")
and self.caption_entities # type: ignore[attr-defined]
):
data["caption_entities"] = [
ce.to_dict() for ce in self.caption_entities # type: ignore[attr-defined]
]
return data