mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-17 04:39:55 +01:00
Adding MessageEntity and Venue classes #232
This commit is contained in:
parent
0e21609382
commit
b9305ca7ac
3 changed files with 75 additions and 0 deletions
|
@ -44,6 +44,7 @@ from .nullhandler import NullHandler
|
|||
from .emoji import Emoji
|
||||
from .parsemode import ParseMode
|
||||
from .message import Message
|
||||
from .messageentity import MessageEntity
|
||||
from .callbackquery import CallbackQuery
|
||||
from .choseninlineresult import ChosenInlineResult
|
||||
from .inlinekeyboardbutton import InlineKeyboardButton
|
||||
|
@ -74,6 +75,7 @@ from .inputtextmessagecontent import InputTextMessageContent
|
|||
from .inputlocationmessagecontent import InputLocationMessageContent
|
||||
from .inputvenuemessagecontent import InputVenueMessageContent
|
||||
from .inputcontactmessagecontent import InputContactMessageContent
|
||||
from .venue import Venue
|
||||
from .update import Update
|
||||
from .bot import Bot
|
||||
|
||||
|
@ -157,6 +159,7 @@ __all__ = ['Audio',
|
|||
'KeyboardButton',
|
||||
'Location',
|
||||
'Message',
|
||||
'MessageEntity',
|
||||
'NullHandler',
|
||||
'ParseMode',
|
||||
'PhotoSize',
|
||||
|
@ -169,5 +172,6 @@ __all__ = ['Audio',
|
|||
'Update',
|
||||
'User',
|
||||
'UserProfilePhotos',
|
||||
'Venue',
|
||||
'Video',
|
||||
'Voice']
|
||||
|
|
|
@ -16,3 +16,38 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents a Telegram MessageEntity."""
|
||||
|
||||
from telegram import TelegramObject
|
||||
|
||||
|
||||
class MessageEntity(TelegramObject):
|
||||
"""
|
||||
This object represents one special entity in a text message. For example,
|
||||
hashtags, usernames, URLs, etc.
|
||||
|
||||
Args:
|
||||
type (str):
|
||||
offset (int):
|
||||
length (int):
|
||||
url (Optional[str]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
type,
|
||||
offset,
|
||||
length,
|
||||
url=None):
|
||||
# Required
|
||||
self.type = type
|
||||
self.offset = offset
|
||||
self.length = length
|
||||
# Optionals
|
||||
self.url = url
|
||||
|
||||
@staticmethod
|
||||
def de_json(self):
|
||||
data = super(MessageEntity, MessageEntity).de_json(data)
|
||||
|
||||
return MessageEntity(**data)
|
|
@ -16,3 +16,39 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents a Telegram Venue."""
|
||||
|
||||
from telegram import TelegramObject, Location
|
||||
|
||||
|
||||
class Venue(TelegramObject):
|
||||
"""
|
||||
This object represents a venue.
|
||||
|
||||
Args:
|
||||
location (:class:`telegram.Location`):
|
||||
title (str):
|
||||
address (str):
|
||||
foursquare_id (Optional[str]):
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
location,
|
||||
title,
|
||||
address,
|
||||
foursquare_id=None):
|
||||
# Required
|
||||
self.location = location
|
||||
self.title = title
|
||||
self.address = address
|
||||
# Optionals
|
||||
self.foursquare_id = foursquare_id
|
||||
|
||||
@staticmethod
|
||||
def de_json(self):
|
||||
data = super(Venue, Venue).de_json(data)
|
||||
|
||||
data['location'] = Location.de_json(data.get('location'))
|
||||
|
||||
return Venue(**data)
|
Loading…
Add table
Reference in a new issue