Message broadcasting and editing

Function
Description
Bot.sendMessage(text)
Send message to current chat
Bot.sendMessage("Hello from bot")
Bot.sendMessageToChatWithId(chatid, text)
Send message to chat with id. Current chatid for chat is contained in chat.chatid
Bot.sendMessageToChatWithId("45445454521", "Hello users!")
Bot.sendMessageToChat(chat_name, text)
Send message to other chat. The bot must be installed in another chat room
sendMessageToChat("OtherTestChat", "Hello to all!")

Do you want broadcast text?

See Bot.runAll command

Do you want broadcast photo, video and etc?

See Bot.runAll command
Security
Please note that the user can create a chat with any name and add to it your bot.
Therefore, the function Bot.sendMessageToChatWithId is more preferable than the function Bot.sendMessageToChat.

Message editing

Function
Description
editMessage(value, message_id, options)
edit message with value and message_id
Bot.editMessage("new text", 20)
editMessageInChat(chat_id, value, message_id)
edit message with value and message_id in chat
Bot.editMessageInChat(10512154, "new text", 25)
message_id - it is unique identificator for all chats of this bot.

Message_id for income messages to bot

For income messages to bot: use request.message_id

Example

let msg_id = request.message_id;
Bot.editMessage("new text", msg_id)
// also you can store message_id for future editing:
User.setProperty("msg_id", msg_id, "integer");
// or if you want to edit message from others chats:
Bot.setProperty("msg_id" + chat.chatid, msg_id, "integer");
Message_id - have unique value for all chats of bot. So we have only one message_id with value "2" and only in one chat.

Message_id for messages from bot

use on_result in options - see this

Example

in first command:
Bot.sendMessage("hello",
{on_result: "onMessageSending" }
)
in command onMessageSending:
// You can inspect all result:
// Bot.inspect(options)
let msg_id = options.result.message_id;
Bot.editMessage("new text", msg_id);
// Also you can save message_id for future:
// Bot.setProperty( "MSG-for-edit" + chat.chatid, msg_id, "integer");

Options for sendMessage, editMessage and sendKeyboard functionals: Reply, Disable Notification, Disable web page preview

You can pass options parameter to any sendMessageXXX, sendKeyboard, editMesage, editMessageInChat andsendInlineKeyboard functions:
let options = { disable_notification: true, reply_to_message_id: request.message_id };
Bot.sendMessage("Hello from bot", options);
Bot.sendMessageToChatWithId("45445454521", "Hello users!", options);
Bot.sendKeyboard("about, help,\ncontacts", "send keyboard now", options)
Parameter
Type
Description
disable_web_page_preview
Boolean
Disables link previews for links in this message
disable_notification
Boolean
Sends the message silently. Users will receive a notification with no sound.
reply_to_message_id
Integer
If the message is a reply, ID of the original message
is_reply
Boolean
If the message is a reply for previous message
parse_mode
String
Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. Default Markdown. Can be Markdown, HTML or null
result_to_bot_property
String
It is preferable to use "on_result". Store result of message sending in bot property with this name. You can read this result later in other commands by Bot.getProperty
on_result
String
Call this command after method with result