Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Client Methods: Full Reference

All methods on Client. Every method is async and returns Result<T, InvocationError> unless noted.


Connection & Session

async Client::connect(config: Config) → Result<(Client, ShutdownToken), InvocationError>
Opens a TCP connection to Telegram, performs the full 3-step DH key exchange, and loads any existing session. Returns both the client handle and a ShutdownToken for graceful shutdown.
sync Config::with_string_session(s: impl Into<String>) → Config New 0.2.0
Convenience constructor that builds a Config pre-wired with a StringSessionBackend. Pass the string exported by export_session_string(), or an empty string to start a fresh session. All other Config fields default to their standard values.
let cfg = Config {
    api_id:   12345,
    api_hash: "abc".into(),
    catch_up: true,
    ..Config::with_string_session(std::env::var("SESSION").unwrap_or_default())
};
let (client, _token) = Client::connect(cfg).await?;
async client.is_authorized() → Result<bool, InvocationError>
Returns true if the session has a logged-in user or bot. Use this to skip the login flow on subsequent runs.
async client.save_session() → Result<(), InvocationError>
Writes the current session (auth key + DC info + peer cache) to the backend. Call after a successful login.
async client.export_session_string() → Result<String, InvocationError> New 0.2.0
Serialises the current session to a portable base64 string. Store it in an env var, DB column, or CI secret. Restore with Client::with_string_session() or StringSessionBackend.
let s = client.export_session_string().await?;
std::env::set_var("TG_SESSION", &s);
async client.sign_out() → Result<bool, InvocationError>
Revokes the auth key on Telegram's servers and deletes the local session. The bool indicates whether teardown was confirmed server-side.
sync client.disconnect()
Immediately closes the TCP connection and stops the reader task without waiting for pending RPCs to drain. For graceful shutdown that waits for pending calls, use ShutdownToken::cancel() instead.
async client.sync_update_state() New 0.2.0
Forces an immediate updates.getState round-trip and reconciles local pts/seq/qts counters. Useful after a long disconnect or when you suspect a gap but don't want to wait for the gap-detection timer.
sync client.signal_network_restored()
Signals to the reconnect logic that the network is available. Skips the exponential backoff and triggers an immediate reconnect attempt. Call from Android ConnectivityManager or iOS NWPathMonitor callbacks.

Authentication

async client.request_login_code(phone: &str) → Result<LoginToken, InvocationError>
Sends a verification code to phone via SMS or Telegram app. Returns a LoginToken to pass to sign_in. Phone must be in E.164 format: "+12345678900".
async client.sign_in(token: &LoginToken, code: &str) → Result<String, SignInError>
Submits the verification code. Returns the user's full name on success, or SignInError::PasswordRequired(PasswordToken) when 2FA is enabled. The PasswordToken carries the hint set by the user.
async client.check_password(token: PasswordToken, password: &str) → Result<(), InvocationError>
Completes the SRP 2FA verification. The password is never transmitted in plain text: only a zero-knowledge cryptographic proof is sent.
async client.bot_sign_in(token: &str) → Result<String, InvocationError>
Logs in using a bot token from @BotFather. Returns the bot's username on success.
async client.get_me() → Result<tl::types::User, InvocationError>
Fetches the full User object for the logged-in account. Contains id, username, first_name, last_name, phone, bot flag, verified flag, and more.

Updates

sync client.stream_updates() → UpdateStream
Returns an UpdateStream: an async iterator that yields typed Update values. Call .next().await in a loop to process events. The stream runs until the connection is closed.
let mut updates = client.stream_updates();
while let Some(update) = updates.next().await {
    match update {
        Update::NewMessage(msg) => { /* … */ }
        _ => {}
    }
}

Messaging

async client.send_message(peer: &str, text: &str) → Result<IncomingMessage, InvocationError>
Send a plain-text message. peer can be "me", "@username", or a numeric ID string. Pass an InputMessage for rich formatting, keyboard, or media.
async client.send_to_self(text: &str) → Result<IncomingMessage, InvocationError>
Sends a message to your own Saved Messages. Shorthand for send_message("me", text).
async client.send_message(peer: Peer, text: &str) → Result<IncomingMessage, InvocationError>
Send a plain text message to a resolved tl::enums::Peer.
async client.send_message(peer: impl Into<PeerRef>, msg: impl Into<InputMessage>) → Result<IncomingMessage, InvocationError>
Full-featured send with the InputMessage builder: supports markdown entities, reply-to, inline keyboard, scheduled date, silent flag, and more. A bare &str or String is accepted as a shorthand for plain text.
async client.edit_message(peer: Peer, message_id: i32, new_text: &str) → Result<(), InvocationError>
Edit the text of a previously sent message. Only works on messages sent by the logged-in account (or bot).
async client.edit_inline_message(inline_msg_id: tl::enums::InputBotInlineMessageId, text: &str) → Result<(), InvocationError>
Edit the text of a message that was sent via inline mode. The inline_msg_id is provided in Update::InlineSend.
async client.forward_messages(from_peer: Peer, to_peer: Peer, ids: Vec<i32>) → Result<(), InvocationError>
Forward one or more messages from from_peer into to_peer.
async client.delete_messages(ids: Vec<i32>, revoke: bool) → Result<(), InvocationError>
revoke: true deletes for everyone; false deletes only for the current account.
async client.get_messages(peer: Peer, ids: &[i32]) → Result<Vec<IncomingMessage>, InvocationError>
Fetch specific messages by their IDs from a peer. Returns messages in the same order as the input IDs.
async client.pin_message(peer: Peer, message_id: i32, silent: bool) → Result<(), InvocationError>
Pin a message. silent: true pins without notifying members.
async client.pin_message(peer: impl Into<PeerRef>, id: i32, pin: bool) → Result<(), InvocationError>
Unpin a specific message.
async client.unpin_all_messages(peer: Peer) → Result<(), InvocationError>
Unpin all pinned messages in a chat.
async client.get_pinned_message(peer: Peer) → Result<Option<IncomingMessage>, InvocationError>
Fetch the currently pinned message, or None if nothing is pinned.

Reactions

async client.send_reaction(peer: Peer, msg_id: i32, reaction: impl Into<InputReactions>) → Result<(), InvocationError>
Send a reaction to a message. Build reactions using the Reaction helper:
use ferogram::reactions::InputReactions;

client.send_reaction(peer, msg_id, InputReactions::emoticon(“👍”)).await?; client.send_reaction(peer, msg_id, InputReactions::remove()).await?; // remove all client.send_reaction(peer, msg_id, InputReactions::emoticon(“🔥”).big()).await?; See Reactions for the full guide.

async client.get_reactions(peer: impl Into<PeerRef>, msg_ids: Vec<i32>) → Result<(), InvocationError>
Trigger a server push of the current reaction counters for the given message IDs. The server responds with updateMessageReactions updates in the stream.
async client.iter_reaction_users(peer: impl Into<PeerRef>, msg_id: i32, reaction: Option<tl::enums::Reaction>, limit: i32, offset: Option<String>) → Result<tl::types::messages::MessageReactionsList, InvocationError>
Get the list of users who reacted to a message. Pass reaction = None for all reactions. limit max 100; use offset from the previous response to paginate.
async client.send_paid_reaction(peer: impl Into<PeerRef>, msg_id: i32, count: i32) → Result<(), InvocationError>
Send a paid (Stars) reaction to a message. count is the number of Stars to spend.
async client.read_reactions(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Mark all unread reactions in a chat as seen (clears reaction badges).
async client.clear_recent_reactions() → Result<(), InvocationError>
Clear the recent reactions list shown in the reaction picker.

Sending chat actions

async client.send_chat_action(peer: Peer, action: SendMessageAction) → Result<(), InvocationError>
Send a one-shot typing / uploading / recording indicator. Expires after ~5 seconds. Use TypingGuard to keep it alive for longer operations. top_msg_id restricts the indicator to a forum topic.

sync client.search(peer: impl Into<PeerRef>, query: &str) → SearchBuilder
Returns a SearchBuilder for per-peer message search with date filters, sender filter, media type filter, and pagination.
sync client.search_global_builder(query: &str) → GlobalSearchBuilder
Returns a GlobalSearchBuilder for searching across all dialogs simultaneously.
async client.search(peer: impl Into<PeerRef>) → SearchBuilder
Build a message search for a peer. Chain .query(), .limit(), .filter(), etc., then call .collect(&client).await? to run it. For a one-shot query, use client.search().query("text").collect(&client).await?.
async client.search_global(query: &str, limit: i32) → Result<Vec<IncomingMessage>, InvocationError>
Simple one-shot global search. For advanced options use client.search_global_builder().

Dialogs & History

async client.get_dialogs(limit: i32) → Result<Vec<Dialog>, InvocationError>
Fetch the most recent limit dialogs. Each Dialog has title(), peer(), unread_count(), and top_message().
sync client.iter_dialogs() → DialogIter
Lazy iterator that pages through all dialogs automatically. Call iter.next(&client).await?. iter.total() returns the server-reported count after the first page.
sync client.iter_messages(peer: impl Into<PeerRef>) → MessageIter
Lazy iterator over the full message history of a peer, newest first. Call iter.next(&client).await?.
async client.get_message_history(peer: impl Into<PeerRef>, limit: i32, offset_id: i32) → Result<Vec<IncomingMessage>, InvocationError>
Fetch a page of messages. Pass the lowest message ID from the previous page as offset_id to paginate.
async client.mark_read(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Mark all messages in a dialog as read.
async client.clear_mentions(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Clear unread @mention badges in a chat.
async client.delete_dialog(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Delete a dialog from the account's dialog list (does not delete messages for others).
async client.delete_chat_history(peer: impl Into<PeerRef>, max_id: i32, revoke: bool) → Result<(), InvocationError>
Delete message history up to max_id. Pass max_id = 0 to delete everything. revoke = true also removes messages for all other participants (requires admin rights in channels).
async client.pin_dialog(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Pin a dialog to the top of the dialog list.
async client.pin_dialog(peer: impl Into<PeerRef>, pin: bool) → Result<(), InvocationError>
Unpin a previously pinned dialog.
async client.get_pinned_dialogs(folder_id: i32) → Result<Vec<tl::enums::Dialog>, InvocationError>
Fetch all pinned dialogs in a folder. Use folder_id = 0 for the main list, 1 for the archive.
async client.mark_dialog_unread(peer: impl Into<PeerRef>, unread: bool) → Result<(), InvocationError>
Manually mark a dialog as unread (true) or read (false). This sets the unread dot without actually having new messages.

Scheduled messages

async client.get_scheduled_messages(peer: impl Into<PeerRef>) → Result<Vec<IncomingMessage>, InvocationError>
Fetch all messages currently scheduled in a chat.
async client.delete_scheduled_messages(peer: impl Into<PeerRef>, ids: Vec<i32>) → Result<(), InvocationError>
Cancel and delete scheduled messages by their scheduled message IDs.
async client.send_scheduled_now(peer: impl Into<PeerRef>, ids: Vec<i32>) → Result<(), InvocationError>
Immediately deliver one or more scheduled messages. ids are the scheduled message IDs returned by get_scheduled_messages.

Participants & Admin

async client.get_participants(peer: impl Into<PeerRef>, limit: i32) → Result<Vec<Participant>, InvocationError>
Fetch members of a chat or channel. Pass limit = 0 for the default server maximum per page. Use iter_participants to lazily page all members.
async client.iter_participants(peer: impl Into<PeerRef>, filter: Option<tl::enums::ChannelParticipantsFilter>, limit: i32) → Result<Vec<Participant>, InvocationError>
Fetch all members of a channel or supergroup, optionally filtered and limited. Pass filter = None and limit = 0 to retrieve all members up to the server default. For basic groups use get_participants.
async client.kick(peer: impl Into<PeerRef>, user_id: i64) → Result<(), InvocationError>
Remove a user from a group, channel, or supergroup.
async client.ban(peer: impl Into<PeerRef>, user_id: i64, until: Option<i32>) → Result<(), InvocationError>
Ban a user from a channel or supergroup. until: None is permanent; Some(ts) bans until that Unix timestamp. To unban, use restrict with an empty BannedRightsBuilder.
async client.set_admin(peer: impl Into<PeerRef>, user_id: i64, rights: AdminRightsBuilder) → Result<(), InvocationError>
Set admin rights. Use AdminRightsBuilder::full_admin() to promote or AdminRightsBuilder::new() to demote.
async client.set_admin(peer: impl Into<PeerRef>, user_id: i64, rights: AdminRightsBuilder) → Result<(), InvocationError>
Promote a user to admin with specified rights. See Admin & Ban Rights.
async client.restrict(peer: impl Into<PeerRef>, user_id: i64, rights: BannedRightsBuilder) → Result<(), InvocationError>
Restrict or ban a user. Pass BannedRightsBuilder::full_ban() to fully ban. See Admin & Ban Rights.
async client.get_profile_photos(peer: impl Into<PeerRef>, limit: i32) → Result<Vec<tl::enums::Photo>, InvocationError>
Fetch a page of a user's profile photos.
async client.iter_profile_photos(peer: impl Into<PeerRef>, chunk_size: i32) → Result<ProfilePhotoIter, InvocationError>
Lazy iterator over all profile photos of a user, fetched in pages of chunk_size. Pass chunk_size = 0 for the default (100). Call iter.next().await? to advance. Only works for users.
async client.search_peer(query: &str) → Result<Vec<tl::enums::Peer>, InvocationError>
Search for a peer (user, group, or channel) by name prefix. Searches contacts, dialogs, and globally. Returns combined results.
async client.get_permissions(peer: impl Into<PeerRef>, user_id: i64) → Result<ParticipantPermissions, InvocationError>
Fetch the effective permissions of a user in a channel or supergroup. See Participants & Members.

Media

async client.upload_file(path: impl AsRef<Path>) → Result<UploadedFile, InvocationError>
Upload a file from disk. Stats the file for optimal part sizing; uses parallel workers and saveBigFilePart for files over 10 MB automatically. Returns an UploadedFile.
let data = std::fs::read("photo.jpg")?;
let uploaded = client.upload_file("/tmp/photo.jpg").await?;
let media = uploaded.as_photo_media();
async client.send_file(peer: tl::enums::Peer, media: tl::enums::InputMedia, caption: &str) → Result<(), InvocationError>
Send an uploaded file as a photo or document. caption is the message text shown below the media; pass "" for no caption (it is not Option).
async client.send_album(peer: tl::enums::Peer, items: Vec<AlbumItem>) → Result<(), InvocationError>
Send 2-10 media items as a grouped album. Each AlbumItem carries its own caption and optional reply_to. See AlbumItem for builder details.
use ferogram::media::AlbumItem;
client.send_album(peer, vec![
    AlbumItem::new(photo1).caption("First"),
    AlbumItem::new(photo2).caption("Second"),
]).await?;
async client.download(media: &MessageMedia, dest: impl AsyncWrite + Unpin) → Result<u64, InvocationError>
Download a media file and write it to path. The path argument accepts anything that implements AsRef<Path> (e.g. &str, String, PathBuf). DC routing is handled automatically.

Callbacks & Inline

async client.answer_callback_query(query_id: i64, text: Option<&str>, alert: bool) → Result<(), InvocationError>
Acknowledge an inline button press. text shows a toast (or alert if alert=true). Must be called within 60 seconds of the button press.
async client.answer_inline_query(query_id: i64, results: Vec<InputBotInlineResult>, cache_time: i32, is_personal: bool, next_offset: Option<&str>) → Result<(), InvocationError>
Respond to an inline query with a list of results. cache_time in seconds. Empty result list now handled correctly (fixed in v0.2.0).

Peer resolution

async client.resolve<P: Into<PeerRef>>(peer: P) → Result<tl::enums::Peer, InvocationError>
Resolve any peer reference to a Peer. Accepts all PeerRef input types:
  • &str / String: "@username", "me", "self", numeric string, t.me/ URL, invite link, E.164 phone
  • i64 / i32: Bot-API encoded numeric ID
  • tl::enums::Peer: returned as-is, zero cost
  • tl::enums::InputPeer: access hash cached, then stripped to Peer
Resolution is cache-first; an RPC is only made on a cache miss.
async client.resolve(peer: &str) → Result<tl::enums::Peer, InvocationError>
String-only variant of resolve(). Accepts "@username", "+phone", "me", numeric string, t.me/ URL, and invite links. Prefer resolve() when the input may not be a string.
async client.resolve_to_input_peer(peer: &tl::enums::Peer) → Result<tl::enums::InputPeer, InvocationError>
Convert a bare Peer to an InputPeer with access hash. Returns an error if the peer has not been seen in a prior API call and the hash is unknown.

Raw API

async client.invoke<R: RemoteCall>(req: &R) → Result<R::Return, InvocationError>
Call any Layer 225 API method directly. See Raw API Access for the full guide.
use ferogram_tl_types::functions;
let state = client.invoke(&functions::updates::GetState {}).await?;
async client.invoke_on_dc<R: RemoteCall>(dc_id: i32, req: &R) → Result<R::Return, InvocationError>
Send a request to a specific Telegram data centre. Used for file downloads from CDN DCs.

Chat management

async client.join_chat(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Join a group or channel by peer reference.
async client.join_link(link: &str) → Result<(), InvocationError>
Accept a t.me/+hash or t.me/joinchat/hash invite link.
async client.create_group(title: impl Into<String>, user_ids: Vec<i64>) → Result<tl::enums::Chat, InvocationError>
Create a new basic group with the given title and initial member list. Returns the created Chat. Basic groups support up to 200 members; migrate to supergroup with migrate_chat if you need more.
async client.create_channel(title: impl Into<String>, about: impl Into<String>, broadcast: bool) → Result<tl::enums::Chat, InvocationError>
Create a new channel (broadcast = true) or supergroup (broadcast = false). Returns the created Chat.
async client.delete_chat(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Permanently delete a channel or supergroup. Only the creator can do this. Irreversible.
async client.delete_chat(chat_id: i64) → Result<(), InvocationError>
Delete a legacy basic group by its chat ID. Only the creator can do this. Use delete_chat for all peer types.
async client.leave_chat(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Leave a channel or supergroup. For basic groups, use kick on yourself or delete_dialog to just hide it.
async client.set_profile(peer).title(: impl Into<PeerRef>, title: impl Into<String>) → Result<(), InvocationError>
Rename a chat, group, channel, or supergroup. Works for both basic groups and channels/supergroups.
async client.set_profile(peer).bio(: impl Into<PeerRef>, about: impl Into<String>) → Result<(), InvocationError>
Set or update the description/about text for any chat type.
async client.set_profile(peer).chat_photo(peer: impl Into<PeerRef>, photo: tl::enums::InputChatPhoto) → Result<(), InvocationError>
Change the profile photo of a chat. Pass tl::enums::InputChatPhoto::Empty to remove the current photo.
async client.edit_chat_default_banned_rights(peer: impl Into<PeerRef>, build: impl FnOnce(BannedRightsBuilder) → BannedRightsBuilder) → Result<(), InvocationError>
Set default permissions for all members of a group or channel via a closure:
// Disable media and polls for everyone
client.edit_chat_default_banned_rights(peer, |b| {
    b.send_media(true).send_polls(true)
}).await?;
async client.get_chat_full(peer: impl Into<PeerRef>) → Result<tl::enums::messages::ChatFull, InvocationError>
Get the full info object for any chat type. Contains full description, pinned message ID, linked channel, member count, slow mode, and more.
async client.migrate_chat(chat_id: i64) → Result<tl::enums::Chat, InvocationError>
Upgrade a legacy basic group to a supergroup. Returns the new channel peer. The original chat ID becomes invalid after migration.
async client.invite_users(peer: impl Into<PeerRef>, user_ids: Vec<i64>) → Result<(), InvocationError>
Add one or more users to a chat. For channels all users are added in one request; for basic groups each user is added individually.
async client.set_history_ttl(peer: impl Into<PeerRef>, period: i32) → Result<(), InvocationError>
Set the auto-delete timer for a chat. period is in seconds. Common values: 86400 (1 day), 604800 (1 week), 2678400 (1 month). Pass 0 to disable.
async client.get_common_chats(user_id: i64, max_id: i64, limit: i32) → Result<Vec<tl::enums::Chat>, InvocationError>
Get chats shared between the logged-in account and user_id. Pass max_id = 0 for the first page. Max limit is 100.
async client.get_online_count(peer: impl Into<PeerRef>) → Result<i32, InvocationError>
Get the approximate number of members currently online in a group or channel.
async client.toggle_no_forwards(peer: impl Into<PeerRef>, enabled: bool) → Result<(), InvocationError>
Enable or disable the no-forwards restriction. When enabled, members cannot forward messages out of this chat.
sync Client::parse_invite_hash(link: &str) → Option<&str>
Parse the invite hash out of any t.me/+… or t.me/joinchat/… link format. Returns None if the link is not a valid invite.
async client.set_chat_theme(peer: impl Into<PeerRef>, emoticon: impl Into<String>) → Result<(), InvocationError>
Set the emoji-based colour theme for a chat. Pass a single emoji string such as "🌈" or "❄️" to apply a theme, or an empty string to reset to default.
async client.set_chat_reactions(peer: impl Into<PeerRef>, reactions: tl::enums::ChatReactions) → Result<(), InvocationError>
Control which reactions are allowed in a chat. Use ChatReactionsAll, ChatReactionsSome, or ChatReactionsNone.
// Allow all (including custom emoji)
client.set_chat_reactions(peer.clone(),
    tl::enums::ChatReactions::ChatReactionsAll(
        tl::types::ChatReactionsAll { allow_custom: true }
    )
).await?;

// Disable all reactions client.set_chat_reactions(peer.clone(), tl::enums::ChatReactions::ChatReactionsNone ).await?;

async client.toggle_forum(peer: impl Into<PeerRef>, enabled: bool) → Result<(), InvocationError>
Enable or disable forum (topics) mode on a supergroup. Requires channel admin rights. Once enabled the group gains a General topic (ID 1) automatically. See Forum Topics for full topic management.

Advanced Messaging

async client.forward_messages_returning(destination: impl Into<PeerRef>, message_ids: &[i32], source: impl Into<PeerRef>) → Result<Vec<IncomingMessage>, InvocationError>
Like forward_messages but returns the newly created message objects in the destination chat. Useful when you need the forwarded message IDs immediately.
async msg.get_reply() → Option<&IncomingMessage>
Access the message this message replies to. Available directly on IncomingMessage. Returns None if not a reply. To fetch the replied-to message by ID, use client.get_messages(peer, &[id]).
async client.get_users_by_id(ids: &[i64]) → Result<Vec<Option<User>>, InvocationError>
Bulk-fetch typed User objects by their IDs. The result is in the same order as ids; entries are None for deleted/unknown users.
async client.get_user_full(user_id: i64) → Result<tl::types::UserFull, InvocationError>
Get the full info object for a user. Contains bio, common chats count, bot info, profile/fallback photos, privacy settings, pinned message ID, and more.
async client.get_pinned_message(peer: impl Into<PeerRef>) → Result<Option<IncomingMessage>, InvocationError>
Fetch the currently pinned message in a chat. Returns None if nothing is pinned.
async client.pin_message(peer: impl Into<PeerRef>, message_id: i32, silent: bool, unpin: bool, pm_oneside: bool) → Result<(), InvocationError>
Pin (or unpin) a message. Set silent = true to avoid a pin notification. pm_oneside = true pins only for the logged-in user in DMs.
async client.pin_message(peer: impl Into<PeerRef>, id: i32, pin: bool) → Result<(), InvocationError>
Shorthand for unpinning a specific message (calls pin_message with unpin = true).
async client.unpin_all_messages(peer: impl Into<PeerRef>) → Result<(), InvocationError>
Unpin every pinned message in a chat at once.
async client.get_message_read_participants(peer: impl Into<PeerRef>, msg_id: i32) → Result<Vec<tl::types::ReadParticipantDate>, InvocationError>
Get the list of users who have read a specific message and the time each read it. Only works in groups; returns an empty list for channels and private chats.
async client.get_replies(peer: impl Into<PeerRef>, msg_id: i32, limit: i32, offset_id: i32) → Result<Vec<IncomingMessage>, InvocationError>
Fetch thread replies under a message. msg_id is the root message ID. Pass offset_id = 0 for the first page; use the lowest ID from the previous page to paginate. Max limit is 100.
async client.get_discussion_message(peer: impl Into<PeerRef>, msg_id: i32) → Result<tl::types::messages::DiscussionMessage, InvocationError>
Get the linked discussion message in the comments group for a channel post. Returns the discussion metadata including unread counts and max-read IDs.
async client.read_discussion(peer: impl Into<PeerRef>, msg_id: i32, read_max_id: i32) → Result<(), InvocationError>
Mark a discussion thread as read up to read_max_id. peer is the channel, msg_id is the root post.
async client.get_web_page_preview(text: impl Into<String>) → Result<tl::enums::MessageMedia, InvocationError>
Generate a link preview for a URL embedded in text. Returns the MessageMedia that Telegram would attach (webpage card, article embed, video thumbnail, etc.).
async client.upload_media(peer: impl Into<PeerRef>, media: tl::enums::InputMedia) → Result<tl::enums::MessageMedia, InvocationError>
Upload a media object to Telegram servers without sending it as a message. The returned MessageMedia can be reused in subsequent send_message calls via InputMessage::copy_media(). Distinct from upload_file - this works with an existing InputMedia.
async client.export_message_link(peer: impl Into<PeerRef>, msg_id: i32, grouped: bool, thread: bool) → Result<String, InvocationError>
Get a t.me/c/… permalink for a message in a channel. grouped = true returns a link to the album group; thread = true links to the discussion thread. Only works for channels (not basic groups).
async client.get_send_as_peers(peer: impl Into<PeerRef>) → Result<Vec<tl::enums::Peer>, InvocationError>
Get the list of identities the logged-in user can send messages as in a chat (e.g. own account, linked anonymous channel). Used to implement "send as channel" / anonymous posting.
async client.set_default_send_as(peer: impl Into<PeerRef>, send_as_peer: impl Into<PeerRef>) → Result<(), InvocationError>
send_as_peer must be one of the peers returned by get_send_as_peers. Sets the default identity for new messages in peer.

Translation & Transcription

async client.translate_messages(peer: impl Into<PeerRef>, msg_ids: Vec<i32>, to_lang: impl Into<String>) → Result<Vec<tl::types::TextWithEntities>, InvocationError>
Translate one or more messages to to_lang (e.g. "en", "ru"). Returns translated text in the same order as msg_ids. Requires Telegram Premium for many language pairs.
async client.transcribe_audio(peer: impl Into<PeerRef>, msg_id: i32) → Result<tl::types::messages::TranscribedAudio, InvocationError>
Request speech-to-text transcription of a voice message or video note. Transcription may be pending on first call; poll again if result.pending == true. Requires Telegram Premium.
async client.toggle_peer_translations(peer: impl Into<PeerRef>, disabled: bool) → Result<(), InvocationError>
Show or hide the "Translate" toolbar button for a chat. disabled = true hides it.

Admin Log

async client.get_admin_log(peer: impl Into<PeerRef>, query: impl Into<String>, limit: i32, max_id: i64, min_id: i64) → Result<Vec<tl::types::ChannelAdminLogEvent>, InvocationError>
Fetch the admin action log for a channel or supergroup. query filters by keyword (pass "" for all events). Max limit is 100. Use max_id / min_id for pagination; pass 0 for both on the first call. Only works for channels/supergroups; returns an error for basic groups.

Drafts

async client.save_draft(peer: impl Into<PeerRef>, text: impl Into<String>) → Result<(), InvocationError>
Save a draft message for a chat. Pass an empty string to clear the current draft.
async client.sync_drafts() → Result<(), InvocationError>
Sync all saved drafts from the server. The server responds with updateDraftMessage updates in the update stream.
async client.clear_all_drafts() → Result<(), InvocationError>
Delete all saved drafts across all chats at once.