|
1 | 1 | # -*- coding: utf-8 -*- |
2 | | -""" |
3 | | -Available types |
4 | | -
|
5 | | -User |
6 | | -GroupChat |
7 | | -Message |
8 | | -PhotoSize |
9 | | -Audio |
10 | | -Document |
11 | | -Sticker |
12 | | -Video |
13 | | -Contact |
14 | | -Location |
15 | | -Update |
16 | | -InputFile |
17 | | -UserProfilePhotos |
18 | | -ReplyKeyboardMarkup |
19 | | -ReplyKeyboardHide |
20 | | -ForceReply |
21 | | -""" |
| 2 | + |
| 3 | +# TODO InlineQueryResultArticle, InlineQueryResultPhoto, InlineQueryResultGif, InlineQueryResultMpeg4Gif, InlineQueryResultVideo |
22 | 4 |
|
23 | 5 | import json |
24 | 6 | import six |
@@ -575,3 +557,39 @@ def __init__(self, result_id, from_user, query): |
575 | 557 | self.result_id = result_id |
576 | 558 | self.from_user = from_user |
577 | 559 | self.query = query |
| 560 | + |
| 561 | + |
| 562 | +class InlineQueryResultArticle(JsonSerializable): |
| 563 | + def __init__(self, id, title, message_text, parse_mode=None, disable_web_page_preview=None, url=None, |
| 564 | + hide_url=None, description=None, thumb_url=None, thumb_width=None, thumb_height=None): |
| 565 | + self.type = 'article' |
| 566 | + self.title = title |
| 567 | + self.message_text = message_text |
| 568 | + self.parse_mode = parse_mode |
| 569 | + self.disable_web_page_preview = disable_web_page_preview |
| 570 | + self.url = url |
| 571 | + self.hide_url = hide_url |
| 572 | + self.description = description |
| 573 | + self.thumb_url = thumb_url |
| 574 | + self.thumb_width = thumb_width |
| 575 | + self.thumb_height = thumb_height |
| 576 | + |
| 577 | + def to_json(self): |
| 578 | + json_dict = {'id': self.type, 'title': self.title, 'message_text': self.message_text} |
| 579 | + if self.parse_mode: |
| 580 | + json_dict['parse_mode'] = self.parse_mode |
| 581 | + if self.disable_web_page_preview: |
| 582 | + json_dict['disable_web_page_preview'] = self.disable_web_page_preview |
| 583 | + if self.url: |
| 584 | + json_dict['url'] = self.url |
| 585 | + if self.hide_url: |
| 586 | + json_dict['hide_url'] = self.hide_url |
| 587 | + if self.description: |
| 588 | + json_dict['description'] = self.description |
| 589 | + if self.thumb_url: |
| 590 | + json_dict['thumb_url'] = self.thumb_url |
| 591 | + if self.thumb_width: |
| 592 | + json_dict['thumb_width'] = self.thumb_width |
| 593 | + if self.thumb_height: |
| 594 | + json_dict['thumb_height'] = self.thumb_height |
| 595 | + return json.dumps(json_dict) |
0 commit comments