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
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
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
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 of the entity in UTF-16 code units.
# File lib/objects/message_entity.rb, line 35 def length @msg.length end
Return true if entity type
is url else false is returned.
# File lib/objects/message_entity.rb, line 70 def link? type.elq? 'url' end
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 in UTF-16 code units to the start of the entity.
# File lib/objects/message_entity.rb, line 30 def offset @msg.offset end
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
Returns true if entity type
is text_link
else false is returned.
# File lib/objects/message_entity.rb, line 85 def text_link? type.eql? 'text_link' end
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 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
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
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