Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from . import base
from . import fields
from ..utils import markdown
class User(base.TelegramObject):
"""
This object represents a Telegram user or bot.
https://core.telegram.org/bots/api#user
"""
id: base.Integer = fields.Field()
is_bot: base.Boolean = fields.Field()
first_name: base.String = fields.Field()
last_name: base.String = fields.Field()
username: base.String = fields.Field()
language_code: base.String = fields.Field()
@property
def full_name(self):
"""
You can get full name of user.
:return: str
"""
full_name = self.first_name
if self.last_name:
full_name += ' ' + self.last_name
return full_name
@property
import typing
from . import base
from . import fields
class ReplyKeyboardMarkup(base.TelegramObject):
"""
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
https://core.telegram.org/bots/api#replykeyboardmarkup
"""
keyboard: 'typing.List[typing.List[KeyboardButton]]' = fields.ListOfLists(base='KeyboardButton', default=[])
resize_keyboard: base.Boolean = fields.Field()
one_time_keyboard: base.Boolean = fields.Field()
selective: base.Boolean = fields.Field()
def __init__(self, keyboard: 'typing.List[typing.List[KeyboardButton]]' = None,
resize_keyboard: base.Boolean = None,
one_time_keyboard: base.Boolean = None,
selective: base.Boolean = None,
row_width: base.Integer = 3):
super(ReplyKeyboardMarkup, self).__init__(keyboard=keyboard, resize_keyboard=resize_keyboard,
one_time_keyboard=one_time_keyboard, selective=selective,
conf={'row_width': row_width})
@property
def row_width(self):
return self.conf.get('row_width', 3)
@row_width.setter
from . import base
from . import fields
from . import mixins
class Voice(base.TelegramObject, mixins.Downloadable):
"""
This object represents a voice note.
https://core.telegram.org/bots/api#voice
"""
file_id: base.String = fields.Field()
duration: base.Integer = fields.Field()
mime_type: base.String = fields.Field()
file_size: base.Integer = fields.Field()
import typing
from . import base
from . import fields
class PollOption(base.TelegramObject):
text: base.String = fields.Field()
voter_count: base.Integer = fields.Field()
class Poll(base.TelegramObject):
id: base.String = fields.Field()
question: base.String = fields.Field()
options: typing.List[PollOption] = fields.ListField(base=PollOption)
is_closed: base.Boolean = fields.Field()
from .user import User
from .venue import Venue
from .video import Video
from .video_note import VideoNote
from .voice import Voice
from ..utils import helper
from ..utils import markdown as md
class Message(base.TelegramObject):
"""
This object represents a message.
https://core.telegram.org/bots/api#message
"""
message_id: base.Integer = fields.Field()
from_user: User = fields.Field(alias='from', base=User)
date: datetime.datetime = fields.DateTimeField()
chat: Chat = fields.Field(base=Chat)
forward_from: User = fields.Field(base=User)
forward_from_chat: Chat = fields.Field(base=Chat)
forward_from_message_id: base.Integer = fields.Field()
forward_signature: base.String = fields.Field()
forward_date: datetime.datetime = fields.DateTimeField()
reply_to_message: 'Message' = fields.Field(base='Message')
edit_date: datetime.datetime = fields.DateTimeField()
media_group_id: base.String = fields.Field()
author_signature: base.String = fields.Field()
text: base.String = fields.Field()
entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
caption_entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
audio: Audio = fields.Field(base=Audio)
from . import base
from . import fields
class LabeledPrice(base.TelegramObject):
"""
This object represents a portion of the price for goods or services.
https://core.telegram.org/bots/api#labeledprice
"""
label: base.String = fields.Field()
amount: base.Integer = fields.Field()
def __init__(self, label: base.String, amount: base.Integer):
super(LabeledPrice, self).__init__(label=label, amount=amount)
import sys
from . import base
from . import fields
from .user import User
from ..utils import helper, markdown
class MessageEntity(base.TelegramObject):
"""
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
https://core.telegram.org/bots/api#messageentity
"""
type: base.String = fields.Field()
offset: base.Integer = fields.Field()
length: base.Integer = fields.Field()
url: base.String = fields.Field()
user: User = fields.Field(base=User)
def get_text(self, text):
"""
Get value of entity
:param text: full text
:return: part of text
"""
if sys.maxunicode == 0xFFFF:
return text[self.offset : self.offset + self.length]
if not isinstance(text, bytes):
from . import base
from . import fields
from .shipping_address import ShippingAddress
from .user import User
class ShippingQuery(base.TelegramObject):
"""
This object contains information about an incoming shipping query.
https://core.telegram.org/bots/api#shippingquery
"""
id: base.String = fields.Field()
from_user: User = fields.Field(alias='from', base=User)
invoice_payload: base.String = fields.Field()
shipping_address: ShippingAddress = fields.Field(base=ShippingAddress)
def __hash__(self):
return self.id
def __eq__(self, other):
if isinstance(other, type(self)):
return other.id == self.id
return self.id == other