Skip to content

Commit 6e5c696

Browse files
committed
2 parents c1fbed2 + 2017e65 commit 6e5c696

12 files changed

+67
-31
lines changed

telegram/bot.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,14 @@ def send_venue(self,
11521152
reply_markup=None,
11531153
timeout=None,
11541154
venue=None,
1155+
foursquare_type=None,
11551156
**kwargs):
11561157
"""Use this method to send information about a venue.
11571158
11581159
Note:
11591160
you can either supply :obj:`venue`, or :obj:`latitude`, :obj:`longitude`,
1160-
:obj:`title` and :obj:`address` and optionally :obj:`foursquare_id`.
1161+
:obj:`title` and :obj:`address` and optionally :obj:`foursquare_id` and optionally
1162+
:obj:`foursquare_type`.
11611163
11621164
Args:
11631165
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
@@ -1167,6 +1169,9 @@ def send_venue(self,
11671169
title (:obj:`str`, optional): Name of the venue.
11681170
address (:obj:`str`, optional): Address of the venue.
11691171
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue.
1172+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
1173+
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
1174+
"food/icecream".)
11701175
venue (:class:`telegram.Venue`, optional): The venue to send.
11711176
disable_notification (:obj:`bool`, optional): Sends the message silently. Users will
11721177
receive a notification with no sound.
@@ -1199,6 +1204,7 @@ def send_venue(self,
11991204
address = venue.address
12001205
title = venue.title
12011206
foursquare_id = venue.foursquare_id
1207+
foursquare_type = venue.foursquare_type
12021208

12031209
data = {
12041210
'chat_id': chat_id,
@@ -1210,6 +1216,8 @@ def send_venue(self,
12101216

12111217
if foursquare_id:
12121218
data['foursquare_id'] = foursquare_id
1219+
if foursquare_type:
1220+
data['foursquare_type'] = foursquare_type
12131221

12141222
return url, data
12151223

@@ -1231,7 +1239,7 @@ def send_contact(self,
12311239
12321240
Note:
12331241
You can either supply :obj:`contact` or :obj:`phone_number` and :obj:`first_name`
1234-
with optionally :obj:`last_name`.
1242+
with optionally :obj:`last_name` and optionally :obj:`vcard`.
12351243
12361244
Args:
12371245
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username

telegram/files/venue.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,29 @@ class Venue(TelegramObject):
2929
title (:obj:`str`): Name of the venue.
3030
address (:obj:`str`): Address of the venue.
3131
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue.
32+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue. (For example,
33+
"arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
3234
3335
Args:
3436
location (:class:`telegram.Location`): Venue location.
3537
title (:obj:`str`): Name of the venue.
3638
address (:obj:`str`): Address of the venue.
3739
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue.
40+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue. (For example,
41+
"arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
3842
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
3943
4044
"""
4145

42-
def __init__(self, location, title, address, foursquare_id=None, **kwargs):
46+
def __init__(self, location, title, address, foursquare_id=None, foursquare_type=None,
47+
**kwargs):
4348
# Required
4449
self.location = location
4550
self.title = title
4651
self.address = address
4752
# Optionals
4853
self.foursquare_id = foursquare_id
54+
self.foursquare_type = foursquare_type
4955

5056
self._id_attrs = (self.location, self.title)
5157

telegram/inline/inlinequeryresultcontact.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self,
6666
phone_number,
6767
first_name,
6868
last_name=None,
69+
vcard=None,
6970
reply_markup=None,
7071
input_message_content=None,
7172
thumb_url=None,

telegram/inline/inlinequeryresultvenue.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class InlineQueryResultVenue(InlineQueryResult):
3535
title (:obj:`str`): Title of the venue.
3636
address (:obj:`str`): Address of the venue.
3737
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue if known.
38+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue, if known.
39+
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
40+
"food/icecream".)
3841
reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
3942
to the message.
4043
input_message_content (:class:`telegram.InputMessageContent`): Optional. Content of the
@@ -50,6 +53,9 @@ class InlineQueryResultVenue(InlineQueryResult):
5053
title (:obj:`str`): Title of the venue.
5154
address (:obj:`str`): Address of the venue.
5255
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue if known.
56+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
57+
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
58+
"food/icecream".)
5359
reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
5460
to the message.
5561
input_message_content (:class:`telegram.InputMessageContent`, optional): Content of the
@@ -68,6 +74,7 @@ def __init__(self,
6874
title,
6975
address,
7076
foursquare_id=None,
77+
foursquare_type=None,
7178
reply_markup=None,
7279
input_message_content=None,
7380
thumb_url=None,
@@ -85,6 +92,8 @@ def __init__(self,
8592
# Optional
8693
if foursquare_id:
8794
self.foursquare_id = foursquare_id
95+
if foursquare_type:
96+
self.foursquare_type = foursquare_type
8897
if reply_markup:
8998
self.reply_markup = reply_markup
9099
if input_message_content:

telegram/inline/inputvenuemessagecontent.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,30 @@ class InputVenueMessageContent(InputMessageContent):
3030
title (:obj:`str`): Name of the venue.
3131
address (:obj:`str`): Address of the venue.
3232
foursquare_id (:obj:`str`): Optional. Foursquare identifier of the venue, if known.
33+
foursquare_type (:obj:`str`): Optional. Foursquare type of the venue, if known.
34+
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
35+
"food/icecream".)
3336
3437
Args:
3538
latitude (:obj:`float`): Latitude of the location in degrees.
3639
longitude (:obj:`float`): Longitude of the location in degrees.
3740
title (:obj:`str`): Name of the venue.
3841
address (:obj:`str`): Address of the venue.
3942
foursquare_id (:obj:`str`, optional): Foursquare identifier of the venue, if known.
43+
foursquare_type (:obj:`str`, optional): Foursquare type of the venue, if known.
44+
(For example, "arts_entertainment/default", "arts_entertainment/aquarium" or
45+
"food/icecream".)
4046
**kwargs (:obj:`dict`): Arbitrary keyword arguments.
4147
4248
"""
4349

44-
def __init__(self, latitude, longitude, title, address, foursquare_id=None, **kwargs):
50+
def __init__(self, latitude, longitude, title, address, foursquare_id=None,
51+
foursquare_type=None, **kwargs):
4552
# Required
4653
self.latitude = latitude
4754
self.longitude = longitude
4855
self.title = title
4956
self.address = address
5057
# Optionals
5158
self.foursquare_id = foursquare_id
59+
self.foursquare_type = foursquare_type

tests/test_bot.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,19 @@ def test_send_venue(self, bot, chat_id):
115115
latitude = -23.691288
116116
title = 'title'
117117
address = 'address'
118+
foursquare_id = 'foursquare id'
119+
foursquare_type = 'foursquare type'
118120
message = bot.send_venue(chat_id=chat_id, title=title, address=address, latitude=latitude,
119-
longitude=longitude)
121+
longitude=longitude, foursquare_id=foursquare_id,
122+
foursquare_type=foursquare_type)
120123

121124
assert message.venue
122125
assert message.venue.title == title
123126
assert message.venue.address == address
124127
assert message.venue.location.latitude == latitude
125128
assert message.venue.location.longitude == longitude
129+
assert message.venue.foursquare_id == foursquare_id
130+
assert message.venue.foursquare_type == foursquare_type
126131

127132
@flaky(3, 1)
128133
@pytest.mark.timeout(10)
@@ -133,15 +138,13 @@ def test_send_contact(self, bot, chat_id):
133138
phone_number = '+11234567890'
134139
first_name = 'Leandro'
135140
last_name = 'Toledo'
136-
vcard = 'vCard'
137141
message = bot.send_contact(chat_id=chat_id, phone_number=phone_number,
138-
first_name=first_name, last_name=last_name, vcard=vcard)
142+
first_name=first_name, last_name=last_name)
139143

140144
assert message.contact
141145
assert message.contact.phone_number == phone_number
142146
assert message.contact.first_name == first_name
143147
assert message.contact.last_name == last_name
144-
assert message.contact.vcard == vcard
145148

146149
@pytest.mark.skipif(os.getenv('APPVEYOR'), reason='No game made for Appveyor bot (''yet)')
147150
@flaky(3, 1)

tests/test_contact.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
@pytest.fixture(scope='class')
2626
def contact():
2727
return Contact(TestContact.phone_number, TestContact.first_name, TestContact.last_name,
28-
TestContact.user_id, TestContact.vcard)
28+
TestContact.user_id)
2929

3030

3131
class TestContact(object):
3232
phone_number = '+11234567890'
3333
first_name = 'Leandro'
3434
last_name = 'Toledo'
3535
user_id = 23
36-
vcard = 'vCard'
3736

3837
def test_de_json_required(self, bot):
3938
json_dict = {'phone_number': self.phone_number, 'first_name': self.first_name}
@@ -44,23 +43,20 @@ def test_de_json_required(self, bot):
4443

4544
def test_de_json_all(self, bot):
4645
json_dict = {'phone_number': self.phone_number, 'first_name': self.first_name,
47-
'last_name': self.last_name, 'user_id': self.user_id,
48-
'vcard': self.vcard}
46+
'last_name': self.last_name, 'user_id': self.user_id}
4947
contact = Contact.de_json(json_dict, bot)
5048

5149
assert contact.phone_number == self.phone_number
5250
assert contact.first_name == self.first_name
5351
assert contact.last_name == self.last_name
5452
assert contact.user_id == self.user_id
55-
assert contact.vcard == self.vcard
5653

5754
def test_send_with_contact(self, monkeypatch, bot, chat_id, contact):
5855
def test(_, url, data, **kwargs):
5956
phone = data['phone_number'] == contact.phone_number
6057
first = data['first_name'] == contact.first_name
6158
last = data['last_name'] == contact.last_name
62-
vcard = data['vcard'] == contact.vcard
63-
return phone and first and last and vcard
59+
return phone and first and last
6460

6561
monkeypatch.setattr('telegram.utils.request.Request.post', test)
6662
message = bot.send_contact(contact=contact, chat_id=chat_id)
@@ -78,7 +74,6 @@ def test_to_dict(self, contact):
7874
assert contact_dict['first_name'] == contact.first_name
7975
assert contact_dict['last_name'] == contact.last_name
8076
assert contact_dict['user_id'] == contact.user_id
81-
assert contact_dict['vcard'] == contact.vcard
8277

8378
def test_equality(self):
8479
a = Contact(self.phone_number, self.first_name)

tests/test_inlinequeryresultcontact.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def inline_query_result_contact():
3030
TestInlineQueryResultContact.phone_number,
3131
TestInlineQueryResultContact.first_name,
3232
last_name=TestInlineQueryResultContact.last_name,
33-
vcard=TestInlineQueryResultContact.vcard,
3433
thumb_url=TestInlineQueryResultContact.thumb_url,
3534
thumb_width=TestInlineQueryResultContact.thumb_width,
3635
thumb_height=TestInlineQueryResultContact.thumb_height,
@@ -44,7 +43,6 @@ class TestInlineQueryResultContact(object):
4443
phone_number = 'phone_number'
4544
first_name = 'first_name'
4645
last_name = 'last_name'
47-
vcard = 'vCard'
4846
thumb_url = 'thumb url'
4947
thumb_width = 10
5048
thumb_height = 15
@@ -57,7 +55,6 @@ def test_expected_values(self, inline_query_result_contact):
5755
assert inline_query_result_contact.phone_number == self.phone_number
5856
assert inline_query_result_contact.first_name == self.first_name
5957
assert inline_query_result_contact.last_name == self.last_name
60-
assert inline_query_result_contact.vcard == self.vcard
6158
assert inline_query_result_contact.thumb_url == self.thumb_url
6259
assert inline_query_result_contact.thumb_width == self.thumb_width
6360
assert inline_query_result_contact.thumb_height == self.thumb_height
@@ -77,8 +74,6 @@ def test_to_dict(self, inline_query_result_contact):
7774
inline_query_result_contact.first_name)
7875
assert (inline_query_result_contact_dict['last_name'] ==
7976
inline_query_result_contact.last_name)
80-
assert (inline_query_result_contact_dict['vcard'] ==
81-
inline_query_result_contact.vcard)
8277
assert (inline_query_result_contact_dict['thumb_url'] ==
8378
inline_query_result_contact.thumb_url)
8479
assert (inline_query_result_contact_dict['thumb_width'] ==

tests/test_inlinequeryresultvenue.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def inline_query_result_venue():
3232
TestInlineQueryResultVenue.title,
3333
TestInlineQueryResultVenue.address,
3434
foursquare_id=TestInlineQueryResultVenue.foursquare_id,
35+
foursquare_type=TestInlineQueryResultVenue.foursquare_type,
3536
thumb_url=TestInlineQueryResultVenue.thumb_url,
3637
thumb_width=TestInlineQueryResultVenue.thumb_width,
3738
thumb_height=TestInlineQueryResultVenue.thumb_height,
@@ -47,6 +48,7 @@ class TestInlineQueryResultVenue(object):
4748
title = 'title'
4849
address = 'address'
4950
foursquare_id = 'foursquare id'
51+
foursquare_type = 'foursquare type'
5052
thumb_url = 'thumb url'
5153
thumb_width = 10
5254
thumb_height = 15
@@ -61,6 +63,7 @@ def test_expected_values(self, inline_query_result_venue):
6163
assert inline_query_result_venue.title == self.title
6264
assert inline_query_result_venue.address == self.address
6365
assert inline_query_result_venue.foursquare_id == self.foursquare_id
66+
assert inline_query_result_venue.foursquare_type == self.foursquare_type
6467
assert inline_query_result_venue.thumb_url == self.thumb_url
6568
assert inline_query_result_venue.thumb_width == self.thumb_width
6669
assert inline_query_result_venue.thumb_height == self.thumb_height
@@ -80,6 +83,8 @@ def test_to_dict(self, inline_query_result_venue):
8083
assert inline_query_result_venue_dict['address'] == inline_query_result_venue.address
8184
assert (inline_query_result_venue_dict['foursquare_id'] ==
8285
inline_query_result_venue.foursquare_id)
86+
assert (inline_query_result_venue_dict['foursquare_type'] ==
87+
inline_query_result_venue.foursquare_type)
8388
assert inline_query_result_venue_dict['thumb_url'] == inline_query_result_venue.thumb_url
8489
assert (inline_query_result_venue_dict['thumb_width'] ==
8590
inline_query_result_venue.thumb_width)

tests/test_inputcontactmessagecontent.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,18 @@
2626
def input_contact_message_content():
2727
return InputContactMessageContent(TestInputContactMessageContent.phone_number,
2828
TestInputContactMessageContent.first_name,
29-
last_name=TestInputContactMessageContent.last_name,
30-
vcard=TestInputContactMessageContent.vcard)
29+
last_name=TestInputContactMessageContent.last_name)
3130

3231

3332
class TestInputContactMessageContent(object):
3433
phone_number = 'phone number'
3534
first_name = 'first name'
3635
last_name = 'last name'
37-
vcard = 'vCard'
3836

3937
def test_expected_values(self, input_contact_message_content):
4038
assert input_contact_message_content.first_name == self.first_name
4139
assert input_contact_message_content.phone_number == self.phone_number
4240
assert input_contact_message_content.last_name == self.last_name
43-
assert input_contact_message_content.vcard == self.vcard
4441

4542
def test_to_dict(self, input_contact_message_content):
4643
input_contact_message_content_dict = input_contact_message_content.to_dict()
@@ -52,5 +49,3 @@ def test_to_dict(self, input_contact_message_content):
5249
input_contact_message_content.first_name)
5350
assert (input_contact_message_content_dict['last_name'] ==
5451
input_contact_message_content.last_name)
55-
assert (input_contact_message_content_dict['vcard'] ==
56-
input_contact_message_content.vcard)

0 commit comments

Comments
 (0)