Class: Telegram::TelegramMessage
- Inherits:
-
Object
- Object
- Telegram::TelegramMessage
- Defined in:
- lib/telegram/models.rb
Instance Attribute Summary collapse
- #chat ⇒ TelegramChat readonly
- #client ⇒ Telegram readonly
- #id ⇒ Integer readonly
- #raw ⇒ String readonly
-
#raw_target ⇒ Object
readonly
targets to send a message.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
- #time ⇒ Time readonly
-
#user ⇒ TelegramContact
readonly
The user who sent this message.
Instance Method Summary collapse
-
#initialize(client, event) ⇒ TelegramMessage
constructor
A new instance of TelegramMessage.
- #reply(type, content, target = nil, &cb) ⇒ Object
- #reply_user(type, content) ⇒ Object
Constructor Details
#initialize(client, event) ⇒ TelegramMessage
Returns a new instance of TelegramMessage.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/telegram/models.rb', line 131 def initialize(client, event) @event = event @id = event.id @raw = event..text @time = event.time @content_type = event..type @raw_sender = event..raw_from @raw_receiver = event..raw_to @user = @sender = event..from @receiver = event..to @target = case @receiver.type when 'user' @sender when 'chat', 'encr_chat' @receiver end end |
Instance Attribute Details
#chat ⇒ TelegramChat (readonly)
129 130 131 |
# File 'lib/telegram/models.rb', line 129 def chat @chat end |
#client ⇒ Telegram (readonly)
110 111 112 |
# File 'lib/telegram/models.rb', line 110 def client @client end |
#id ⇒ Integer (readonly)
116 117 118 |
# File 'lib/telegram/models.rb', line 116 def id @id end |
#raw ⇒ String (readonly)
113 114 115 |
# File 'lib/telegram/models.rb', line 113 def raw @raw end |
#raw_target ⇒ Object (readonly)
targets to send a message
125 126 127 |
# File 'lib/telegram/models.rb', line 125 def raw_target @raw_target end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
126 127 128 |
# File 'lib/telegram/models.rb', line 126 def target @target end |
#time ⇒ Time (readonly)
119 120 121 |
# File 'lib/telegram/models.rb', line 119 def time @time end |
#user ⇒ TelegramContact (readonly)
Returns The user who sent this message.
122 123 124 |
# File 'lib/telegram/models.rb', line 122 def user @user end |
Instance Method Details
#reply(type, content, target = nil, &cb) ⇒ Object
157 158 159 160 161 162 163 164 165 |
# File 'lib/telegram/models.rb', line 157 def reply(type, content, target=nil, &cb) target = @target if target.nil? if type == :text target.(content, self) elsif type == :sticker elsif type == :image end end |
#reply_user(type, content) ⇒ Object
153 154 155 |
# File 'lib/telegram/models.rb', line 153 def reply_user(type, content) end |