class MessageEntity

Monday, August 24 2020 EAT

This object represents one special entity in a text message.

For example, hashtags, usernames, URLs, etc.

Public Instance Methods

bot_command?() click to toggle source

Returns true if entity type is bot_command else false is returned.

# File lib/objects/message_entity.rb, line 65
def bot_command?
  type.eql? 'bot_command'
end
email?() click to toggle source

Returns true if entity type is email else false is returned.

# File lib/objects/message_entity.rb, line 75
def email?
  type.eql? 'email'
end
language() click to toggle source

Optional. For pre only, the programming language of the entity text.

# File lib/objects/message_entity.rb, line 46
def language
  @msg.language
end
length() click to toggle source

Length of the entity in UTF-16 code units.

# File lib/objects/message_entity.rb, line 35
def length
  @msg.length
end
mention?() click to toggle source

Returns true if entity type is mention else false is returned.

# File lib/objects/message_entity.rb, line 60
def mention?
  type.eql? 'mention'
end
offset() click to toggle source

Offset in UTF-16 code units to the start of the entity.

# File lib/objects/message_entity.rb, line 30
def offset
  @msg.offset
end
phone_number?() click to toggle source

Return true if entity type is phone_number else false is returned.

# File lib/objects/message_entity.rb, line 80
def phone_number?
  type.eql? 'phone_number'
end
text_mention?() click to toggle source

Returns true if entity type is text_mention else false is returned.

# File lib/objects/message_entity.rb, line 90
def text_mention?
  type.eql? 'text_mention'
end
type() click to toggle source

Type of the entity. Can be mention( @username ), hashtag( hashtag ), cashtag( $USD ), bot_command( /start@jobs_bot ), url( telegram.org ), email( do-not-reply@telegram.org ), phone_number( +1-212-555-0123 ), bold(bold text), italic(italic text), underline(underlined text), strikethrough(strikethrough text), code (monowidth string), pre (monowidth block), text_link(for clickable text URLs), text_mention (for users without usernames)

# File lib/objects/message_entity.rb, line 25
def type
  @msg.type
end
url() click to toggle source

Optional. For text_link only, url that will be opened after user taps on the text.

# File lib/objects/message_entity.rb, line 41
def url
  @msg.url
end
user() click to toggle source

Optional. For text_mention? only, the mentioned user. Returns User object

# File lib/objects/message_entity.rb, line 52
def user
  usr = @msg.user
  return User.new(usr) if usr

  false
end