messages.SetTyping
Sends a current user typing event (see SendMessageAction for all event types) to a conversation partner or group.
Example
const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result = await client.invoke(
new Api.messages.SetTyping({
peer: "username",
action: new Api.SendMessageTypingAction({}),
topMsgId: 43,
})
);
console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result: Api.Bool = await client.invoke(
new Api.messages.SetTyping({
peer: "username",
action: new Api.SendMessageTypingAction({}),
topMsgId: 43,
})
);
console.log(result); // prints the result
})();
Parameters
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
peer | InputPeer | Target user or group |
topMsgId | flags.0?int | Thread ID |
action | SendMessageAction | Type of actionParameter added in Layer 17. |
Result
Possible errors
Code | Type | Description |
---|---|---|
400 | CHANNEL_INVALID | The provided channel is invalid. |
400 | CHANNEL_PRIVATE | You haven't joined this channel/supergroup. |
400 | CHAT_ADMIN_REQUIRED | You must be an admin in this chat to do this. |
400 | CHAT_ID_INVALID | The provided chat id is invalid. |
403 | CHAT_WRITE_FORBIDDEN | You can't write in this chat. |
403 | GROUPCALL_FORBIDDEN | The group call has already ended. |
400 | INPUT_USER_DEACTIVATED | The specified user was deleted. |
400 | MSG_ID_INVALID | Invalid message ID provided. |
400 | PEER_ID_INVALID | The provided peer id is invalid. |
400 | USER_BANNED_IN_CHANNEL | You're banned from sending messages in supergroups/channels. |
403 | USER_IS_BLOCKED | You were blocked by this user. |
400 | USER_IS_BOT | Bots can't send messages to other bots. |
Can bots use this method?
Yes
Related pages
Threads
Telegram allows commenting on a channel post or on a generic supergroup message, thanks to message threads.
Layers
Below you will find information on schema changes. For more details on the use of layers, see Invoking API methods.
SendMessageAction
User actions. Use this to provide users with detailed info about their chat partner's actions: typing or sending attachments of all kinds.