File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020"""This module contains a object that represents a Telegram InlineQuery"""
2121
22- from telegram import TelegramObject , User
22+ from telegram import TelegramObject , User , Location
2323
2424
2525class InlineQuery (TelegramObject ):
@@ -39,6 +39,10 @@ class InlineQuery(TelegramObject):
3939 from_user (:class:`telegram.User`):
4040 query (str):
4141 offset (str):
42+ **kwargs: Arbitrary keyword arguments.
43+
44+ Keyword Args:
45+ location (optional[:class:`telegram.Location`]):
4246 """
4347
4448 def __init__ (self ,
@@ -53,6 +57,9 @@ def __init__(self,
5357 self .query = query
5458 self .offset = offset
5559
60+ # Optional
61+ self .location = kwargs .get ('location' )
62+
5663 @staticmethod
5764 def de_json (data ):
5865 """
@@ -68,6 +75,7 @@ def de_json(data):
6875 return None
6976
7077 data ['from_user' ] = User .de_json (data .get ('from' ))
78+ data ['location' ] = Location .de_json (data .get ('location' ))
7179
7280 return InlineQuery (** data )
7381
Original file line number Diff line number Diff line change @@ -37,17 +37,20 @@ class InlineQueryTest(BaseTest, unittest.TestCase):
3737
3838 def setUp (self ):
3939 user = telegram .User (1 , 'First name' )
40+ location = telegram .Location (8.8 , 53.1 )
4041
4142 self .id = 'id'
4243 self .from_user = user
4344 self .query = 'query text'
4445 self .offset = 'offset'
46+ self .location = location
4547
4648 self .json_dict = {
4749 'id' : self .id ,
4850 'from' : self .from_user .to_dict (),
4951 'query' : self .query ,
50- 'offset' : self .offset
52+ 'offset' : self .offset ,
53+ 'location' : self .location .to_dict ()
5154 }
5255
5356 def test_inlinequery_de_json (self ):
@@ -56,6 +59,8 @@ def test_inlinequery_de_json(self):
5659 self .assertEqual (inlinequery .id , self .id )
5760 self .assertDictEqual (inlinequery .from_user .to_dict (),
5861 self .from_user .to_dict ())
62+ self .assertDictEqual (inlinequery .location .to_dict (),
63+ self .location .to_dict ())
5964 self .assertEqual (inlinequery .query , self .query )
6065 self .assertEqual (inlinequery .offset , self .offset )
6166
You can’t perform that action at this time.
0 commit comments