Skip to content

Commit d209074

Browse files
committed
Add InlineQueryResultVenue
1 parent 13e26ca commit d209074

File tree

2 files changed

+134
-1
lines changed

2 files changed

+134
-1
lines changed

pyrogram/types/inline_mode/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
from .inline_query_result_document import InlineQueryResultDocument
2727
from .inline_query_result_location import InlineQueryResultLocation
2828
from .inline_query_result_photo import InlineQueryResultPhoto
29+
from .inline_query_result_venue import InlineQueryResultVenue
2930
from .inline_query_result_video import InlineQueryResultVideo
3031
from .inline_query_result_voice import InlineQueryResultVoice
3132

3233
__all__ = [
3334
"InlineQuery", "InlineQueryResult", "InlineQueryResultArticle", "InlineQueryResultPhoto",
3435
"InlineQueryResultAnimation", "InlineQueryResultAudio", "InlineQueryResultVideo", "ChosenInlineResult",
35-
"InlineQueryResultContact", "InlineQueryResultDocument", "InlineQueryResultVoice", "InlineQueryResultLocation"
36+
"InlineQueryResultContact", "InlineQueryResultDocument", "InlineQueryResultVoice", "InlineQueryResultLocation",
37+
"InlineQueryResultVenue"
3638
]
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
import pyrogram
20+
from pyrogram import raw, types
21+
from .inline_query_result import InlineQueryResult
22+
23+
24+
class InlineQueryResultVenue(InlineQueryResult):
25+
"""A venue.
26+
27+
By default, the venue will be sent by the user. Alternatively, you can use *input_message_content* to send a message
28+
with the specified content instead of the venue.
29+
30+
Parameters:
31+
title (``str``):
32+
Title for the result.
33+
34+
address (``str``):
35+
Address of the venue.
36+
37+
latitude (``float``):
38+
Location latitude in degrees.
39+
40+
longitude (``float``):
41+
Location longitude in degrees.
42+
43+
id (``str``, *optional*):
44+
Unique identifier for this result, 1-64 bytes.
45+
Defaults to a randomly generated UUID4.
46+
47+
foursquare_id (``str``, *optional*):
48+
Foursquare identifier of the venue if known.
49+
50+
foursquare_type (``str``, *optional*):
51+
Foursquare type of the venue, if known.
52+
53+
google_place_id (``str``, *optional*):
54+
Google Places identifier of the venue.
55+
56+
google_place_type (``str``, *optional*):
57+
Google Places type of the venue.
58+
59+
reply_markup (:obj:`~pyrogram.types.InlineKeyboardMarkup`, *optional*):
60+
Inline keyboard attached to the message.
61+
62+
input_message_content (:obj:`~pyrogram.types.InputMessageContent`):
63+
Content of the message to be sent instead of the file.
64+
65+
thumb_url (``str``, *optional*):
66+
Url of the thumbnail for the result.
67+
68+
thumb_width (``int``, *optional*):
69+
Thumbnail width.
70+
71+
thumb_height (``int``, *optional*):
72+
Thumbnail height.
73+
"""
74+
75+
def __init__(
76+
self,
77+
title: str,
78+
address: str,
79+
latitude: float,
80+
longitude: float,
81+
id: str = None,
82+
foursquare_id: str = None,
83+
foursquare_type: str = None,
84+
google_place_id: str = None,
85+
google_place_type: str = None,
86+
reply_markup: "types.InlineKeyboardMarkup" = None,
87+
input_message_content: "types.InputMessageContent" = None,
88+
thumb_url: str = None,
89+
thumb_width: int = 0,
90+
thumb_height: int = 0
91+
):
92+
super().__init__("venue", id, input_message_content, reply_markup)
93+
94+
self.title = title
95+
self.address = address
96+
self.latitude = latitude
97+
self.longitude = longitude
98+
self.foursquare_id = foursquare_id
99+
self.foursquare_type = foursquare_type
100+
self.google_place_id = google_place_id
101+
self.google_place_type = google_place_type
102+
self.thumb_url = thumb_url
103+
self.thumb_width = thumb_width
104+
self.thumb_height = thumb_height
105+
106+
async def write(self, client: "pyrogram.Client"):
107+
return raw.types.InputBotInlineResult(
108+
id=self.id,
109+
type=self.type,
110+
title=self.title,
111+
send_message=(
112+
await self.input_message_content.write(client, self.reply_markup)
113+
if self.input_message_content
114+
else raw.types.InputBotInlineMessageMediaVenue(
115+
geo_point=raw.types.InputGeoPoint(
116+
lat=self.latitude,
117+
long=self.longitude
118+
),
119+
title=self.title,
120+
address=self.address,
121+
provider=(
122+
"foursquare" if self.foursquare_id or self.foursquare_type
123+
else "google" if self.google_place_id or self.google_place_type
124+
else ""
125+
),
126+
venue_id=self.foursquare_id or self.google_place_id or "",
127+
venue_type=self.foursquare_type or self.google_place_type or "",
128+
reply_markup=await self.reply_markup.write(client) if self.reply_markup else None
129+
)
130+
)
131+
)

0 commit comments

Comments
 (0)