telegramium.bots.high.messageentities

Members list

Type members

Classlikes

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).

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
Supertypes
class AnyVal
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
sealed abstract class MessageEntityFormat extends Product, Serializable

Base class for different types of message entity formats that mirror the ones used by Telegram. Each format corresponds to a specific type of content in a message, such as mentions, hashtags, URLs, and more.

Base class for different types of message entity formats that mirror the ones used by Telegram. Each format corresponds to a specific type of content in a message, such as mentions, hashtags, URLs, and more.

These formats can be used to wrap different parts of a message, which can then be composed to create a complete message. The benefits of this approach:

  • It automatically calculates the text offsets and lengths that are required by the Telegram Bot API.
  • It allows for generating the plain text of a message from the same source, simplifying the future message and formatting changes.

Note: This lower-level API is not typically used directly. Instead, most users should work with the MessageEntities API, which provides a higher-level, more user-friendly interface to the same functionality.

Attributes

See also
Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Bold
class BotCommand
class Cashtag
class Code
class CustomEmoji
class Email
class Hashtag
class Italic
class Mention
class PhoneNumber
class Plain
class Pre
class Spoiler
class TextLink
class TextMention
class Underline
class Url
Show all

Attributes

Companion
class
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type