MessageEntities

telegramium.bots.high.messageentities.MessageEntities
See theMessageEntities companion object
final class MessageEntities(val underlying: Vector[MessageEntityFormat]) extends AnyVal

Utility class to work with styled messages using message entities (see https://core.telegram.org/bots/api#messageentity).

Compose your message's text using different formatting options like plain text, bold, italics, links, mentions, hashtags and more. This class automatically takes care of calculating text offsets and lengths required by the Telegram API.

Value parameters

underlying

This class is basically a thin wrapper over the Vector collection. It supports some of the Vector operations directly, such as ++, :+, and +:. For additional collection methods not directly available through this class, you can access the underlying Vector instance.

Attributes

Example
 val msgEntities = MessageEntities()
   .bold("Hello, ")
   .mention("@user")
   .plain("! Welcome to our ")
   .textLink("website", "https://example.com")
   .lineBreak()
   .plain("Enjoy your stay.")
 Methods.sendMessage(
   chatId,
   // Hello, @user! Welcome to our website\nEnjoy your stay.
   text = msgEntities.toPlainText(),
   // List(BoldMessageEntity(0, 7), MentionMessageEntity(7, 5), TextLinkMessageEntity(29, 7, "https://example.com"))
   entities = msgEntities.toTelegramEntities()
 )
Companion
object
Graph
Supertypes
class AnyVal
trait Matchable
class Any

Members list

Value members

Concrete methods

def blockquote(text: String): MessageEntities
def bold(text: String): MessageEntities
def botCommand(text: String): MessageEntities

Alias for lineBreak

Alias for lineBreak

Attributes

def cashtag(text: String): MessageEntities
def code(text: String): MessageEntities
def customEmoji(text: String, customEmojiId: String): MessageEntities
def email(text: String): MessageEntities
def hashtag(text: String): MessageEntities
def italic(text: String): MessageEntities
def mention(text: String): MessageEntities
def phoneNumber(text: String): MessageEntities
def plain(text: String): MessageEntities
def pre(text: String, language: Option[String]): MessageEntities
def spoiler(text: String): MessageEntities
def strikethrough(text: String): MessageEntities
def textMention(text: String, user: User): MessageEntities
def toPlainText(): String

Converts the underlying message entity formats to a plain text string. You can pass it as the text parameter of the sendMessage Telegram Bot API method.

Converts the underlying message entity formats to a plain text string. You can pass it as the text parameter of the sendMessage Telegram Bot API method.

Attributes

def toTelegramEntities(): List[MessageEntity]

Converts the underlying message entity formats to a list of Telegram message entities.

Converts the underlying message entity formats to a list of Telegram message entities.

Note: There is no Plain message entity in Telegram, so you won't see it in the final list.

Attributes

def underline(text: String): MessageEntities
def url(text: String): MessageEntities

Concrete fields