Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Mischa Krüger <https://github.com/Makman2>`_
- `naveenvhegde <https://github.com/naveenvhegde>`_
- `neurrone <https://github.com/neurrone>`_
- `NikitaPirate <https://github.com/NikitaPirate>`_
- `njittam <https://github.com/njittam>`_
- `Noam Meltzer <https://github.com/tsnoam>`_
- `Oleg Shlyazhko <https://github.com/ollmer>`_
Expand Down
18 changes: 9 additions & 9 deletions telegram/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Chat."""

from telegram import TelegramObject, ChatPhoto
from telegram import TelegramObject, ChatPhoto, constants
from .chatpermissions import ChatPermissions

from telegram.utils.types import JSONDict
Expand Down Expand Up @@ -92,14 +92,14 @@ class Chat(TelegramObject):

"""

PRIVATE: str = 'private'
""":obj:`str`: 'private'"""
GROUP: str = 'group'
""":obj:`str`: 'group'"""
SUPERGROUP: str = 'supergroup'
""":obj:`str`: 'supergroup'"""
CHANNEL: str = 'channel'
""":obj:`str`: 'channel'"""
PRIVATE: str = constants.CHAT_PRIVATE
""":const:`telegram.constants.CHAT_PRIVATE`"""
GROUP: str = constants.CHAT_GROUP
""":const:`telegram.constants.CHAT_GROUP`"""
SUPERGROUP: str = constants.CHAT_SUPERGROUP
""":const:`telegram.constants.CHAT_SUPERGROUP`"""
CHANNEL: str = constants.CHAT_CHANNEL
""":const:`telegram.constants.CHAT_CHANNEL`"""

def __init__(
self,
Expand Down
41 changes: 21 additions & 20 deletions telegram/chataction.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,29 @@
# 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 an object that represents a Telegram ChatAction."""
from telegram import constants


class ChatAction:
"""Helper class to provide constants for different chat actions."""

FIND_LOCATION: str = 'find_location'
""":obj:`str`: 'find_location'"""
RECORD_AUDIO: str = 'record_audio'
""":obj:`str`: 'record_audio'"""
RECORD_VIDEO: str = 'record_video'
""":obj:`str`: 'record_video'"""
RECORD_VIDEO_NOTE: str = 'record_video_note'
""":obj:`str`: 'record_video_note'"""
TYPING: str = 'typing'
""":obj:`str`: 'typing'"""
UPLOAD_AUDIO: str = 'upload_audio'
""":obj:`str`: 'upload_audio'"""
UPLOAD_DOCUMENT: str = 'upload_document'
""":obj:`str`: 'upload_document'"""
UPLOAD_PHOTO: str = 'upload_photo'
""":obj:`str`: 'upload_photo'"""
UPLOAD_VIDEO: str = 'upload_video'
""":obj:`str`: 'upload_video'"""
UPLOAD_VIDEO_NOTE: str = 'upload_video_note'
""":obj:`str`: 'upload_video_note'"""
FIND_LOCATION: str = constants.CHATACTION_FIND_LOCATION
""":const:`telegram.constants.CHATACTION_FIND_LOCATION`"""
RECORD_AUDIO: str = constants.CHATACTION_RECORD_AUDIO
""":const:`telegram.constants.CHATACTION_RECORD_AUDIO`"""
RECORD_VIDEO: str = constants.CHATACTION_RECORD_VIDEO
""":const:`telegram.constants.CHATACTION_RECORD_VIDEO`"""
RECORD_VIDEO_NOTE: str = constants.CHATACTION_RECORD_VIDEO_NOTE
""":const:`telegram.constants.CHATACTION_RECORD_VIDEO_NOTE`"""
TYPING: str = constants.CHATACTION_TYPING
""":const:`telegram.constants.CHATACTION_TYPING`"""
UPLOAD_AUDIO: str = constants.CHATACTION_UPLOAD_AUDIO
""":const:`telegram.constants.CHATACTION_UPLOAD_AUDIO`"""
UPLOAD_DOCUMENT: str = constants.CHATACTION_UPLOAD_DOCUMENT
""":const:`telegram.constants.CHATACTION_UPLOAD_DOCUMENT`"""
UPLOAD_PHOTO: str = constants.CHATACTION_UPLOAD_PHOTO
""":const:`telegram.constants.CHATACTION_UPLOAD_PHOTO`"""
UPLOAD_VIDEO: str = constants.CHATACTION_UPLOAD_VIDEO
""":const:`telegram.constants.CHATACTION_UPLOAD_VIDEO`"""
UPLOAD_VIDEO_NOTE: str = constants.CHATACTION_UPLOAD_VIDEO_NOTE
""":const:`telegram.constants.CHATACTION_UPLOAD_VIDEO_NOTE`"""
27 changes: 13 additions & 14 deletions telegram/chatmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""This module contains an object that represents a Telegram ChatMember."""
import datetime

from telegram import User, TelegramObject
from telegram import User, TelegramObject, constants
from telegram.utils.helpers import to_timestamp, from_timestamp

from telegram.utils.types import JSONDict
Expand Down Expand Up @@ -111,19 +111,18 @@ class ChatMember(TelegramObject):
may add web page previews to his messages.

"""

ADMINISTRATOR: str = 'administrator'
""":obj:`str`: 'administrator'"""
CREATOR: str = 'creator'
""":obj:`str`: 'creator'"""
KICKED: str = 'kicked'
""":obj:`str`: 'kicked'"""
LEFT: str = 'left'
""":obj:`str`: 'left'"""
MEMBER: str = 'member'
""":obj:`str`: 'member'"""
RESTRICTED: str = 'restricted'
""":obj:`str`: 'restricted'"""
ADMINISTRATOR: str = constants.CHATMEMBER_ADMINISTRATOR
""":const:`telegram.constants.CHATMEMBER_ADMINISTRATOR`"""
CREATOR: str = constants.CHATMEMBER_CREATOR
""":const:`telegram.constants.CHATMEMBER_CREATOR`"""
KICKED: str = constants.CHATMEMBER_KICKED
""":const:`telegram.constants.CHATMEMBER_KICKED`"""
LEFT: str = constants.CHATMEMBER_LEFT
""":const:`telegram.constants.CHATMEMBER_LEFT`"""
MEMBER: str = constants.CHATMEMBER_MEMBER
""":const:`telegram.constants.CHATMEMBER_MEMBER`"""
RESTRICTED: str = constants.CHATMEMBER_RESTRICTED
""":const:`telegram.constants.CHATMEMBER_RESTRICTED`"""

def __init__(
self,
Expand Down
158 changes: 158 additions & 0 deletions telegram/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,90 @@
MAX_MESSAGE_ENTITIES (:obj:`int`): 100 (Beyond this cap telegram will simply ignore further
formatting styles)

The following constants are related to specific classes and are also available
as attributes of those classes:

:class:`telegram.Chat`:

Attributes:
CHAT_PRIVATE (:obj:`str`): 'private'
CHAT_GROUP (:obj:`str`): 'group'
CHAT_SUPERGROUP (:obj:`str`): 'supergroup'
CHAT_CHANNEL (:obj:`str`): 'channel'

:class:`telegram.ChatAction`:

Attributes:
CHATACTION_FIND_LOCATION (:obj:`str`): 'find_location'
CHATACTION_RECORD_AUDIO (:obj:`str`): 'record_audio'
CHATACTION_RECORD_VIDEO (:obj:`str`): 'record_video'
CHATACTION_RECORD_VIDEO_NOTE (:obj:`str`): 'record_video_note'
CHATACTION_TYPING (:obj:`str`): 'typing'
CHATACTION_UPLOAD_AUDIO (:obj:`str`): 'upload_audio'
CHATACTION_UPLOAD_DOCUMENT (:obj:`str`): 'upload_document'
CHATACTION_UPLOAD_PHOTO (:obj:`str`): 'upload_photo'
CHATACTION_UPLOAD_VIDEO (:obj:`str`): 'upload_video'
CHATACTION_UPLOAD_VIDEO_NOTE (:obj:`str`): 'upload_video_note'

:class:`telegram.ChatMember`:

Attributes:
CHATMEMBER_ADMINISTRATOR (:obj:`str`): 'administrator'
CHATMEMBER_CREATOR (:obj:`str`): 'creator'
CHATMEMBER_KICKED (:obj:`str`): 'kicked'
CHATMEMBER_LEFT (:obj:`str`): 'left'
CHATMEMBER_MEMBER (:obj:`str`): 'member'
CHATMEMBER_RESTRICTED (:obj:`str`): 'restricted'

:class:`telegram.Dice`:

Attributes:
DICE_DICE (:obj:`str`): '🎲'
DICE_DARTS (:obj:`str`): '🎯'
DICE_BASKETBALL (:obj:`str`): '🏀'
DICE_ALL_EMOJI (List[:obj:`str`]): List of all supported base emoji.

:class:`telegram.MessageEntity`:

Attributes:
MESSAGEENTITY_MENTION (:obj:`str`): 'mention'
MESSAGEENTITY_HASHTAG (:obj:`str`): 'hashtag'
MESSAGEENTITY_CASHTAG (:obj:`str`): 'cashtag'
MESSAGEENTITY_PHONE_NUMBER (:obj:`str`): 'phone_number'
MESSAGEENTITY_BOT_COMMAND (:obj:`str`): 'bot_command'
MESSAGEENTITY_URL (:obj:`str`): 'url'
MESSAGEENTITY_EMAIL (:obj:`str`): 'email'
MESSAGEENTITY_BOLD (:obj:`str`): 'bold'
MESSAGEENTITY_ITALIC (:obj:`str`): 'italic'
MESSAGEENTITY_CODE (:obj:`str`): 'code'
MESSAGEENTITY_PRE (:obj:`str`): 'pre'
MESSAGEENTITY_TEXT_LINK (:obj:`str`): 'text_link'
MESSAGEENTITY_TEXT_MENTION (:obj:`str`): 'text_mention'
MESSAGEENTITY_UNDERLINE (:obj:`str`): 'underline'
MESSAGEENTITY_STRIKETHROUGH (:obj:`str`): 'strikethrough'
MESSAGEENTITY_ALL_TYPES (List[:obj:`str`]): List of all the types of message entity.

:class:`telegram.ParseMode`:

Attributes:
PARSEMODE_MARKDOWN (:obj:`str`): 'Markdown'
PARSEMODE_MARKDOWN_V2 (:obj:`str`): 'MarkdownV2'
PARSEMODE_HTML (:obj:`str`): 'HTML'

:class:`telegram.Poll`:

Attributes:
POLL_REGULAR (:obj:`str`): 'regular'
POLL_QUIZ (:obj:`str`): 'quiz'

:class:`telegram.files.MaskPosition`:

Attributes:
STICKER_FOREHEAD (:obj:`str`): 'forehead'
STICKER_EYES (:obj:`str`): 'eyes'
STICKER_MOUTH (:obj:`str`): 'mouth'
STICKER_CHIN (:obj:`str`): 'chin'

"""
from typing import List

Expand All @@ -56,3 +140,77 @@
MAX_MESSAGES_PER_MINUTE_PER_GROUP: int = 20
MAX_MESSAGE_ENTITIES: int = 100
MAX_INLINE_QUERY_RESULTS: int = 50

CHAT_PRIVATE: str = 'private'
CHAT_GROUP: str = 'group'
CHAT_SUPERGROUP: str = 'supergroup'
CHAT_CHANNEL: str = 'channel'

CHATACTION_FIND_LOCATION: str = 'find_location'
CHATACTION_RECORD_AUDIO: str = 'record_audio'
CHATACTION_RECORD_VIDEO: str = 'record_video'
CHATACTION_RECORD_VIDEO_NOTE: str = 'record_video_note'
CHATACTION_TYPING: str = 'typing'
CHATACTION_UPLOAD_AUDIO: str = 'upload_audio'
CHATACTION_UPLOAD_DOCUMENT: str = 'upload_document'
CHATACTION_UPLOAD_PHOTO: str = 'upload_photo'
CHATACTION_UPLOAD_VIDEO: str = 'upload_video'
CHATACTION_UPLOAD_VIDEO_NOTE: str = 'upload_video_note'

CHATMEMBER_ADMINISTRATOR: str = 'administrator'
CHATMEMBER_CREATOR: str = 'creator'
CHATMEMBER_KICKED: str = 'kicked'
CHATMEMBER_LEFT: str = 'left'
CHATMEMBER_MEMBER: str = 'member'
CHATMEMBER_RESTRICTED: str = 'restricted'

DICE_DICE: str = '🎲'
DICE_DARTS: str = '🎯'
DICE_BASKETBALL: str = '🏀'
DICE_ALL_EMOJI: List[str] = [DICE_DICE, DICE_DARTS, DICE_BASKETBALL]

MESSAGEENTITY_MENTION: str = 'mention'
MESSAGEENTITY_HASHTAG: str = 'hashtag'
MESSAGEENTITY_CASHTAG: str = 'cashtag'
MESSAGEENTITY_PHONE_NUMBER: str = 'phone_number'
MESSAGEENTITY_BOT_COMMAND: str = 'bot_command'
MESSAGEENTITY_URL: str = 'url'
MESSAGEENTITY_EMAIL: str = 'email'
MESSAGEENTITY_BOLD: str = 'bold'
MESSAGEENTITY_ITALIC: str = 'italic'
MESSAGEENTITY_CODE: str = 'code'
MESSAGEENTITY_PRE: str = 'pre'
MESSAGEENTITY_TEXT_LINK: str = 'text_link'
MESSAGEENTITY_TEXT_MENTION: str = 'text_mention'
MESSAGEENTITY_UNDERLINE: str = 'underline'
MESSAGEENTITY_STRIKETHROUGH: str = 'strikethrough'
MESSAGEENTITY_ALL_TYPES: List[str] = [
MESSAGEENTITY_MENTION,
MESSAGEENTITY_HASHTAG,
MESSAGEENTITY_CASHTAG,
MESSAGEENTITY_PHONE_NUMBER,
MESSAGEENTITY_BOT_COMMAND,
MESSAGEENTITY_URL,
MESSAGEENTITY_EMAIL,
MESSAGEENTITY_BOLD,
MESSAGEENTITY_ITALIC,
MESSAGEENTITY_CODE,
MESSAGEENTITY_PRE,
MESSAGEENTITY_TEXT_LINK,
MESSAGEENTITY_TEXT_MENTION,
MESSAGEENTITY_UNDERLINE,
MESSAGEENTITY_STRIKETHROUGH,
]

PARSEMODE_MARKDOWN: str = 'Markdown'
PARSEMODE_MARKDOWN_V2: str = 'MarkdownV2'
PARSEMODE_HTML: str = 'HTML'

POLL_REGULAR: str = 'regular'
POLL_QUIZ: str = 'quiz'


STICKER_FOREHEAD: str = 'forehead'
STICKER_EYES: str = 'eyes'
STICKER_MOUTH: str = 'mouth'
STICKER_CHIN: str = 'chin'
19 changes: 9 additions & 10 deletions telegram/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# 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 an object that represents a Telegram Dice."""
from telegram import TelegramObject
from telegram import TelegramObject, constants
from typing import Any, List


Expand Down Expand Up @@ -55,12 +55,11 @@ def __init__(self, value: int, emoji: str, **kwargs: Any):

self._id_attrs = (self.value, self.emoji)

DICE: str = '🎲'
""":obj:`str`: '🎲'"""
DARTS: str = '🎯'
""":obj:`str`: '🎯'"""
BASKETBALL = '🏀'
""":obj:`str`: '🏀'"""
ALL_EMOJI: List[str] = [DICE, DARTS, BASKETBALL]
"""List[:obj:`str`]: List of all supported base emoji. Currently :attr:`DICE`,
:attr:`DARTS` and :attr:`BASKETBALL`."""
DICE: str = constants.DICE_DICE
""":const:`telegram.constants.DICE_DICE`"""
DARTS: str = constants.DICE_DARTS
""":const:`telegram.constants.DICE_DARTS`"""
BASKETBALL: str = constants.DICE_BASKETBALL
""":const:`telegram.constants.DICE_BASKETBALL`"""
ALL_EMOJI: List[str] = constants.DICE_ALL_EMOJI
""":const:`telegram.constants.DICE_ALL_EMOJI`"""
18 changes: 9 additions & 9 deletions telegram/files/sticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains objects that represents stickers."""

from telegram import PhotoSize, TelegramObject
from telegram import PhotoSize, TelegramObject, constants
from telegram.utils.types import JSONDict
from typing import Any, Optional, List, TYPE_CHECKING

Expand Down Expand Up @@ -233,14 +233,14 @@ class MaskPosition(TelegramObject):

"""

FOREHEAD: str = 'forehead'
""":obj:`str`: 'forehead'"""
EYES: str = 'eyes'
""":obj:`str`: 'eyes'"""
MOUTH: str = 'mouth'
""":obj:`str`: 'mouth'"""
CHIN: str = 'chin'
""":obj:`str`: 'chin'"""
FOREHEAD: str = constants.STICKER_FOREHEAD
""":const:`telegram.constants.STICKER_FOREHEAD`"""
EYES: str = constants.STICKER_EYES
""":const:`telegram.constants.STICKER_EYES`"""
MOUTH: str = constants.STICKER_MOUTH
""":const:`telegram.constants.STICKER_MOUTH`"""
CHIN: str = constants.STICKER_CHIN
""":const:`telegram.constants.STICKER_CHIN`"""

def __init__(self, point: str, x_shift: float, y_shift: float, scale: float, **kwargs: Any):
self.point = point
Expand Down
Loading