Custom
- class grammers.custom.Channel(client, chat)
Bases:
TLObjectA broadcast channel.
In a broadcast channel, only administrators can broadcast messages to all the subscribers. The rest of users can only join and see messages.
Broadcast channels and megagroups both are treated as “channels” by Telegram’s API, but this variant will always represent a broadcast channel. The only difference between a broadcast channel and a megagroup are the permissions (default, and available).
- access_hash
- admin_rights
- autotranslation
- banned_rights
- bot_verification_icon
- broadcast
- broadcast_messages_allowed
- call_active
- call_not_empty
- client
- color
- creator
- date
- date_timestamp
- default_banned_rights
- emoji_status
- fake
- forum
- forum_tabs
- gigagroup
- has_geo
- has_link
- id
Return the unique identifier for this channel.
- is_gigagroup
- is_megagroup
- join_request
- join_to_send
- kind
Additional information about this channel.
- left
- level
- linked_monoforum_id
- megagroup
- min
- monoforum
- noforwards
- participants_count
- photo
Return the photo of this channel, if any.
- profile_color
- restricted
- restriction_reason
- scam
- send_paid_messages_stars
- signature_profiles
- signatures
- slowmode_enabled
- stories_max_id
- subscription_until_date
- subscription_until_date_timestamp
- title
Return the title of this channel.
- to_bytes()
- to_dict()
- to_ref()
Convert the channel to its reference.
This is only possible if the peer would be usable on all methods or if it is in the session cache.
- until_date
- until_date_timestamp
- username
Return the public @username of this channel, if any.
The returned username does not contain the “@” prefix.
Outside of the application, people may link to this user with one of Telegram’s URLs, such as https://t.me/username.
- usernames
Return collectible usernames of this channel, if any.
The returned usernames do not contain the “@” prefix.
Outside of the application, people may link to this user with one of its username, such as https://t.me/username.
- verified
- class grammers.custom.Group(client, chat)
Bases:
TLObjectA group chat.
Telegram’s API internally distinguishes between “small group chats” and “megagroups”, also known as “supergroups” in the UI of Telegram applications.
Small group chats are the default, and offer less features than megagroups, but you can join more of them. Certain actions in official clients, like setting a chat’s username, silently upgrade the chat to a megagroup.
- access_hash
- admin_rights
Return the permissions of the logged-in user in this channel.
- autotranslation
- banned_rights
- bot_verification_icon
- broadcast
Is this a channel, always false.
- broadcast_messages_allowed
- call_active
- call_not_empty
- client
- color
- creator
Whether the current user is the creator of this channel.
- date
Date when the user joined the supergroup/channel, or if the user isn’t a member, its creation date
- date_timestamp
- deactivated
- default_banned_rights
- emoji_status
- fake
- forum
- forum_tabs
- gigagroup
Whether this supergroup is a gigagroup.
- has_geo
- has_link
- id
Return the unique identifier for this group.
Note that if this group is migrated to a megagroup, both this group and the new one will exist as separate chats, with different identifiers.
- is_broadcast
- is_gigagroup
- is_megagroup
Returns true if this group is a megagroup (also known as supergroups).
In case inner type of group is Channel, that means it’s a megagroup.
- join_request
- join_to_send
Whether a user needs to join the supergroup before they can send messages: can be false only for discussion groups. toggle using channels.toggleJoinToSend
- kind
- left
Whether the current user has left or is not a member of this channel.
- level
- linked_monoforum_id
- megagroup
Whether this is a supergroup, always true.
- migrated_to
- min
- monoforum
- noforwards
Whether this channel or group is protected, thus does not allow forwarding messages from it.
- participants_count
- photo
- profile_color
- raw_type
- restricted
- restriction_reason
- scam
- send_paid_messages_stars
- signature_profiles
- signatures
- slowmode_enabled
- stories_max_id
- subscription_until_date
Expiration date of the Telegram Star subscription the current user has bought to gain access to this channel.
- subscription_until_date_timestamp
- title
Return the title of this group.
The title may be the empty string if the group is not accessible.
- to_bytes()
- to_dict()
- to_ref()
Convert the group to its reference.
This is only possible if the peer would be usable on all methods or if it is in the session cache.
- until_date
The ban is valid until the specified date.
- until_date_timestamp
- username
Return the public @username of this group, if any.
The returned username does not contain the “@” prefix.
Outside of the application, people may link to this user with one of Telegram’s URLs, such as https://t.me/username.
- usernames
Return collectible usernames of this group, if any.
The returned usernames do not contain the “@” prefix.
Outside of the application, people may link to this user with one of its username, such as https://t.me/username.
- verified
Whether this channel is verified by telegram.
- version
- class grammers.custom.HistoryMessageIter(client, peer, limit=None, *, offset_id=0, offset_date=0, add_offset=0, page_limit=0, max_id=0, min_id=0)
Bases:
object- init()
- next()
Returns the next Message from the internal buffer, filling the buffer previously if it’s empty.
Returns None if the limit is reached or there are no messages left.
- total()
Determines how many messages there are in total.
This only performs a network call if next has not been called before.
- exception grammers.custom.InvalidCodeError
Bases:
SignInErrorThe code used to complete login was not valid.
- exception grammers.custom.InvalidPasswordError
Bases:
SignInErrorThe 2FA password used to complete login was not valid.
- class grammers.custom.LoginToken(phone, phone_code_hash)
Bases:
objectLogin token needed to continue the login process after sending the code.
- phone
- phone_code_hash
- class grammers.custom.Message(client, message, peers)
Bases:
TLObjectRepresents a Telegram message, which includes text messages, messages with media, and service messages.
This message should be treated as a snapshot in time, that is, if the message is edited while using this object, those changes won’t alter this structure.
- action
Event connected with the service message.
MessageService only.
- client
- date
The date when this message was produced.
- date_timestamp
- edit_date
The date when this message was last edited.
- edit_hide
Whether the edited mark of this message is edited should be hidden (e.g. in GUI clients) or shown.
- effect
- entities
- factcheck
- forwards
How many times has this message been forwarded, when applicable.
- from_boosts_applied
Supergroups only, contains the number of boosts this user has given the current supergroup.
- from_id
Raw from_id, generally use sender_id instead.
- from_rank
the rank of the sender in the group.
- from_scheduled
Whether this message was originated from a previously-scheduled message or not.
- fwd_from
Info about forwarded messages.
- get_reply_to()
Fetch the message that this message is replying to, or None if this message is not a reply to a previous message.
Shorthand for Client.get_reply_to_message.
- grouped_id
If this message belongs to a group of messages, return the unique identifier for that group.
This applies to albums of media, such as multiple photos grouped together.
Note that there may be messages sent in between the messages forming a group.
- guestchat_via_from
- guestchat_via_from_id
- id
The ID of this message.
Message identifiers are counters that start at 1 and grow by 1 for each message produced.
Every channel has its own unique message counter. This counter is the same for all users, but unique to each channel.
Every account has another unique message counter which is used for private conversations and small group chats. This means different accounts will likely have different message identifiers for the same message in a private conversation or small group chat. This also implies that the message identifier alone is enough to uniquely identify the message, without the need to know the chat ID.
You cannot use the message ID of User A when running as User B, unless this message belongs to a megagroup or broadcast channel. Beware of this when using methods like [Client::delete_messages], which cannot validate the peer where the message should be deleted for those cases.
- invert_media
If set, any eventual webpage preview will be shown on top of the message instead of at the bottom.
- legacy
it has to be refetched with the new layer.
- Type:
Whether this is a legacy message
- media
The media displayed by this message, if any.
This not only includes photos or videos, but also contacts, polls, documents, locations and many other types.
- media_unread
Whether you have read the media in this message or not.
Most commonly, these are voice notes that you have not played yet.
- mentioned
Whether you were mentioned in this message or not.
This includes @username mentions, text mentions, and messages replying to one of your previous messages (even if it contains no mention in the message text).
- message
The message’s text.
For service or empty messages, this will be None.
If the message has media, this text is the caption commonly displayed underneath it.
- noforwards
Whether this message is protected and thus cannot be forwarded; clients should also prevent users from saving attached media (i.e. videos should only be streamed, photos should be kept in RAM, et cetera).
- offline
If set, the message was sent because of a scheduled action by the message sender, for example, as away, or a greeting service message.
- out
Whether the message is outgoing (i.e. you sent this message to some other peer) or incoming (i.e. someone else sent it to you or the peer).
- paid_message_stars
- paid_suggested_post_stars
Set if this is a suggested channel post that was paid using Telegram Stars.
- paid_suggested_post_ton
Set if this is a suggested channel post that was paid using Toncoins.
- peer
The peer where this message was sent to.
This might be the user you’re talking to for private conversations, or the group or channel where the message was sent.
- peer_id
The [Self::peer]’s identifier.
- pinned
Whether this message is currently pinned or not.
- post
Whether this message is a post in a broadcast channel or not.
- post_author
If this message was sent to a channel, return the name used by the author to post it.
- quick_reply_shortcut_id
- reactions
- reactions_are_possible
Whether you can react to this message.
MessageService only.
- replies
How many replies does this message have, when applicable.
- reply_markup
If the message has a reply markup (which can happen for messages produced by bots), returns said markup.
- reply_to
If this message is replying to a previous message, return the header with information about that reply.
- report_delivery_until_date
- restriction_reason
A list of reasons on why this message is restricted.
The message is not restricted if the return value is None.
- saved_peer_id
- schedule_repeat_period
- sender
The sender of this message, if there is a sender and the sender is in cache.
- sender_id
The [Self::sender]’s identifier, if there is a sender.
- silent
Whether the message should notify people with sound or not.
- suggested_post
- summary_from_language
- to_bytes()
- to_dict()
- ttl_period
- via_bot
- via_bot_id
If this message was sent @via some inline bot, return the bot’s user identifier.
- via_business_bot
- via_business_bot_id
- video_processing_pending
The video contained in the message is currently being processed by the server (i.e. to generate alternative qualities, that will be contained in the final messageMediaDocument.alt_document)
- views
How many views does this message have, when applicable.
The same user account can contribute to increment this counter indefinitedly, however there is a server-side cooldown limitting how fast it can happen (several hours).
- exception grammers.custom.PasswordRequiredError
Bases:
SignInErrorThe account has 2FA enabled, and the password is required.
- exception grammers.custom.PaymentRequiredError
Bases:
SignInErrorIndicating that due to the high cost of SMS verification codes for the user’s country/provider, the user must purchase a Telegram Premium subscription in order to proceed with the login/signup.
- class grammers.custom.PeerMap
Bases:
objectHelper structure to efficiently retrieve peers via their peer.
A lot of responses include the peers related to them in the form of a list of users and peers, making it annoying to extract a specific peer. This structure lets you save those separate vectors in a single place and query them by using a Peer.
While this type derives Clone for convenience, it is recommended to use [PeerMap::handle] instead to signal that it is a cheap clone.
- class grammers.custom.Platform
Bases:
objectPlatform Identifier referenced only by [RestrictionReason].
- class grammers.custom.RestrictionReason(reason)
Bases:
objectReason why a user is globally restricted.
- exception grammers.custom.SignInError
Bases:
ExceptionLogin-related errors.
- exception grammers.custom.SignUpRequiredError
Bases:
SignInErrorSign-up with an official client is required. (Third-party applications cannot be used to register new accounts.)
- class grammers.custom.User(client, user)
Bases:
TLObjectA user.
Users include your contacts, members of a group, bot accounts created by [@BotFather], or anyone with a Telegram account.
A “normal” (non-bot) user may also behave like a “bot” without actually being one, for example, when controlled with a program as opposed to being controlled by a human through a Telegram application. These are commonly known as “userbots”, and some people use them to enhance their Telegram experience (for example, creating “commands” so that the program automatically reacts to them, like translating messages).
[@BotFather]: https://t.me/BotFather
- access_hash
- apply_min_photo
- bot
- bot_active_users
- bot_business
- bot_can_edit
- bot_chat_history
- bot_forum_view
- bot_has_main_app
- bot_info_version
- bot_inline_geo
- bot_inline_placeholder
- bot_nochats
- bot_verification_icon
- client
- close_friend
- color
- contact
- deleted
- emoji_status
- fake
- first_name
- id
- is_self
- lang_code
- last_name
- min
- mutual_contact
- phone
- photo
- profile_color
- restricted
- restriction_reason
- scam
- send_paid_messages_stars
- status
- stories_max_id
- support
- to_bytes()
- to_dict()
- to_ref()
Convert the group to its reference.
This is only possible if the peer would be usable on all methods or if it is in the session cache.
- username
- usernames
- verified