From a9fe0fffc69e7d6bf9a6f5854babd4fd1d2a2287 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 15 Oct 2018 10:48:07 +0200 Subject: [PATCH] Add InlineQuery type --- pyrogram/__init__.py | 3 +- pyrogram/client/types/__init__.py | 2 +- pyrogram/client/types/bots/__init__.py | 1 + pyrogram/client/types/bots/inline_query.py | 58 ++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 pyrogram/client/types/bots/inline_query.py diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 6fb6fff4..a741d9b0 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -31,7 +31,8 @@ from .client.types import ( InputMediaVideo, InputMediaDocument, InputMediaAudio, InputMediaAnimation, InputPhoneContact, Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, Update, User, UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply, - InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove + InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, + InlineQuery ) from .client import ( Client, ChatAction, ParseMode, Emoji, diff --git a/pyrogram/client/types/__init__.py b/pyrogram/client/types/__init__.py index 230d5e5d..fe8b8b65 100644 --- a/pyrogram/client/types/__init__.py +++ b/pyrogram/client/types/__init__.py @@ -18,7 +18,7 @@ from .bots import ( CallbackQuery, ForceReply, InlineKeyboardButton, InlineKeyboardMarkup, - KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove + KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineQuery ) from .bots import ( ForceReply, InlineKeyboardButton, InlineKeyboardMarkup, diff --git a/pyrogram/client/types/bots/__init__.py b/pyrogram/client/types/bots/__init__.py index 9f7cc7e6..43f7c0cb 100644 --- a/pyrogram/client/types/bots/__init__.py +++ b/pyrogram/client/types/bots/__init__.py @@ -20,6 +20,7 @@ from .callback_query import CallbackQuery from .force_reply import ForceReply from .inline_keyboard_button import InlineKeyboardButton from .inline_keyboard_markup import InlineKeyboardMarkup +from .inline_query import InlineQuery from .keyboard_button import KeyboardButton from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_remove import ReplyKeyboardRemove diff --git a/pyrogram/client/types/bots/inline_query.py b/pyrogram/client/types/bots/inline_query.py new file mode 100644 index 00000000..d90996de --- /dev/null +++ b/pyrogram/client/types/bots/inline_query.py @@ -0,0 +1,58 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2018 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +from pyrogram.api.core import Object + + +class InlineQuery(Object): + """This object represents an incoming inline query. + When the user sends an empty query, your bot could return some default or trending results + + Args: + id (``str``): + Unique identifier for this query. + + from_user (:obj:`User `): + Sender. + + query (``str``): + Text of the query (up to 512 characters). + + offset (``str``): + Offset of the results to be returned, can be controlled by the bot. + + location (:obj:`Location `. *optional*): + Sender location, only for bots that request user location. + """ + ID = 0xb0700024 + + def __init__( + self, + client, + id: str, + from_user, + query: str, + offset: str, + location=None, + ): + self._client = client + self.id = id + self.from_user = from_user + self.query = query + self.offset = offset + self.location = location