Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return some default or trending results.
:param id: string Unique identifier for this query
:param from_user: User Sender
:param location: Sender location, only for bots that request user location
:param query: String Text of the query
:param offset: String Offset of the results to be returned, can be controlled by the bot
:return: InlineQuery Object
"""
self.id = id
self.from_user = from_user
self.location = location
self.query = query
self.offset = offset
class InputTextMessageContent(Dictionaryable):
def __init__(self, message_text, parse_mode=None, disable_web_page_preview=None):
self.message_text = message_text
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
def to_dic(self):
json_dic = {'message_text': self.message_text}
if self.parse_mode:
json_dic['parse_mode'] = self.parse_mode
if self.disable_web_page_preview:
json_dic['disable_web_page_preview'] = self.disable_web_page_preview
return json_dic
class InputLocationMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, live_period=None):
class InputLocationMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, live_period=None):
self.latitude = latitude
self.longitude = longitude
self.live_period = live_period
def to_dic(self):
json_dic = {'latitude': self.latitude, 'longitude': self.longitude}
if self.live_period:
json_dic['live_period'] = self.live_period
return json_dic
class InputVenueMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, title, address, foursquare_id=None):
self.latitude = latitude
self.longitude = longitude
self.title = title
self.address = address
self.foursquare_id = foursquare_id
def to_dic(self):
json_dic = {'latitude': self.latitude, 'longitude': self.longitude, 'title': self.title,
'address': self.address}
if self.foursquare_id:
json_dic['foursquare_id'] = self.foursquare_id
return json_dic
class InputContactMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, title, address, foursquare_id=None):
self.latitude = latitude
self.longitude = longitude
self.title = title
self.address = address
self.foursquare_id = foursquare_id
def to_dic(self):
json_dic = {'latitude': self.latitude, 'longitude': self.longitude, 'title': self.title,
'address': self.address}
if self.foursquare_id:
json_dic['foursquare_id'] = self.foursquare_id
return json_dic
class InputContactMessageContent(Dictionaryable):
def __init__(self, phone_number, first_name, last_name=None):
self.phone_number = phone_number
self.first_name = first_name
self.last_name = last_name
def to_dic(self):
json_dic = {'phone_numbe': self.phone_number, 'first_name': self.first_name}
if self.last_name:
json_dic['last_name'] = self.last_name
return json_dic
class ChosenInlineResult(JsonDeserializable):
@classmethod
def de_json(cls, json_type):
obj = cls.check_json(json_type)
class InputTextMessageContent(Dictionaryable):
def __init__(self, message_text, parse_mode=None, disable_web_page_preview=None):
self.message_text = message_text
self.parse_mode = parse_mode
self.disable_web_page_preview = disable_web_page_preview
def to_dic(self):
json_dic = {'message_text': self.message_text}
if self.parse_mode:
json_dic['parse_mode'] = self.parse_mode
if self.disable_web_page_preview:
json_dic['disable_web_page_preview'] = self.disable_web_page_preview
return json_dic
class InputLocationMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, live_period=None):
self.latitude = latitude
self.longitude = longitude
self.live_period = live_period
def to_dic(self):
json_dic = {'latitude': self.latitude, 'longitude': self.longitude}
if self.live_period:
json_dic['live_period'] = self.live_period
return json_dic
class InputVenueMessageContent(Dictionaryable):
def __init__(self, latitude, longitude, title, address, foursquare_id=None):
self.latitude = latitude
self.longitude = longitude
self.request_contact = request_contact
self.request_location = request_location
def to_json(self):
return json.dumps(self.to_dic())
def to_dic(self):
json_dic = {'text': self.text}
if self.request_contact:
json_dic['request_contact'] = self.request_contact
if self.request_location:
json_dic['request_location'] = self.request_location
return json_dic
class InlineKeyboardMarkup(Dictionaryable, JsonSerializable):
def __init__(self, row_width=3):
self.row_width = row_width
self.keyboard = []
def add(self, *args):
"""
This function adds strings to the keyboard, while not exceeding row_width.
E.g. ReplyKeyboardMarkup#add("A", "B", "C") yields the json result {keyboard: [["A"], ["B"], ["C"]]}
when row_width is set to 1.
When row_width is set to 2, the following is the result of this function: {keyboard: [["A", "B"], ["C"]]}
See https://core.telegram.org/bots/api#replykeyboardmarkup
:param args: KeyboardButton to append to the keyboard
"""
i = 1
row = []
:return:
"""
json_dict = {'keyboard': self.keyboard}
if self.one_time_keyboard:
json_dict['one_time_keyboard'] = True
if self.resize_keyboard:
json_dict['resize_keyboard'] = True
if self.selective:
json_dict['selective'] = True
return json.dumps(json_dict)
class KeyboardButton(Dictionaryable, JsonSerializable):
def __init__(self, text, request_contact=None, request_location=None):
self.text = text
self.request_contact = request_contact
self.request_location = request_location
def to_json(self):
return json.dumps(self.to_dic())
def to_dic(self):
json_dic = {'text': self.text}
if self.request_contact:
json_dic['request_contact'] = self.request_contact
if self.request_location:
json_dic['request_location'] = self.request_location
return json_dic