Class: BotMessage
- Inherits:
-
Object
- Object
- BotMessage
- Defined in:
- lib/telegram_bot_builder/bot_message.rb
Instance Attribute Summary collapse
-
#audio ⇒ Object
Returns the value of attribute audio.
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#channel_chat_created ⇒ Object
Returns the value of attribute channel_chat_created.
-
#chat ⇒ Object
is user object.
-
#contact ⇒ Object
Returns the value of attribute contact.
-
#date ⇒ Object
Returns the value of attribute date.
-
#delete_chat_photo ⇒ Object
Returns the value of attribute delete_chat_photo.
-
#disable_notification ⇒ Object
true/false.
-
#disable_web_page_preview ⇒ Object
true/false.
-
#document ⇒ Object
Returns the value of attribute document.
-
#entities ⇒ Object
Returns the value of attribute entities.
-
#forward_date ⇒ Object
Returns the value of attribute forward_date.
-
#forward_from ⇒ Object
Returns the value of attribute forward_from.
-
#from ⇒ Object
is user object.
-
#group_chat_created ⇒ Object
Returns the value of attribute group_chat_created.
-
#left_chat_member ⇒ Object
Returns the value of attribute left_chat_member.
-
#location ⇒ Object
Returns the value of attribute location.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#migrate_from_chat_id ⇒ Object
Returns the value of attribute migrate_from_chat_id.
-
#migrate_to_chat_id ⇒ Object
Returns the value of attribute migrate_to_chat_id.
-
#new_chat_little ⇒ Object
Returns the value of attribute new_chat_little.
-
#new_chat_member ⇒ Object
Returns the value of attribute new_chat_member.
-
#new_chat_photo ⇒ Object
Returns the value of attribute new_chat_photo.
-
#parse_mode ⇒ Object
:markdown, :html.
-
#photo ⇒ Object
Returns the value of attribute photo.
-
#pinned_message ⇒ Object
Returns the value of attribute pinned_message.
-
#reply_markup ⇒ Object
keyboard interface for reply - :inline/:reply/:reply_hide/:force_reply.
-
#reply_to_message ⇒ Object
Returns the value of attribute reply_to_message.
-
#reply_to_message_id ⇒ Object
if the message is a reply, ID of the original message.
-
#sticker ⇒ Object
Returns the value of attribute sticker.
-
#supergroup_chat_created ⇒ Object
Returns the value of attribute supergroup_chat_created.
-
#text ⇒ Object
for message.
-
#venue ⇒ Object
Returns the value of attribute venue.
-
#video ⇒ Object
Returns the value of attribute video.
-
#voice ⇒ Object
Returns the value of attribute voice.
Instance Method Summary collapse
Instance Attribute Details
#audio ⇒ Object
Returns the value of attribute audio.
11 12 13 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 11 def audio @audio end |
#caption ⇒ Object
Returns the value of attribute caption.
17 18 19 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 17 def caption @caption end |
#channel_chat_created ⇒ Object
Returns the value of attribute channel_chat_created.
28 29 30 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 28 def channel_chat_created @channel_chat_created end |
#chat ⇒ Object
is user object
5 6 7 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 5 def chat @chat end |
#contact ⇒ Object
Returns the value of attribute contact.
18 19 20 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 18 def contact @contact end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 4 def date @date end |
#delete_chat_photo ⇒ Object
Returns the value of attribute delete_chat_photo.
25 26 27 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 25 def delete_chat_photo @delete_chat_photo end |
#disable_notification ⇒ Object
true/false
37 38 39 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 37 def disable_notification @disable_notification end |
#disable_web_page_preview ⇒ Object
true/false
36 37 38 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 36 def disable_web_page_preview @disable_web_page_preview end |
#document ⇒ Object
Returns the value of attribute document.
12 13 14 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 12 def document @document end |
#entities ⇒ Object
Returns the value of attribute entities.
10 11 12 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 10 def entities @entities end |
#forward_date ⇒ Object
Returns the value of attribute forward_date.
7 8 9 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 7 def forward_date @forward_date end |
#forward_from ⇒ Object
Returns the value of attribute forward_from.
6 7 8 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 6 def forward_from @forward_from end |
#from ⇒ Object
is user object
3 4 5 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 3 def from @from end |
#group_chat_created ⇒ Object
Returns the value of attribute group_chat_created.
26 27 28 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 26 def group_chat_created @group_chat_created end |
#left_chat_member ⇒ Object
Returns the value of attribute left_chat_member.
22 23 24 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 22 def left_chat_member @left_chat_member end |
#location ⇒ Object
Returns the value of attribute location.
19 20 21 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 19 def location @location end |
#message_id ⇒ Object
Returns the value of attribute message_id.
2 3 4 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 2 def @message_id end |
#migrate_from_chat_id ⇒ Object
Returns the value of attribute migrate_from_chat_id.
30 31 32 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 30 def migrate_from_chat_id @migrate_from_chat_id end |
#migrate_to_chat_id ⇒ Object
Returns the value of attribute migrate_to_chat_id.
29 30 31 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 29 def migrate_to_chat_id @migrate_to_chat_id end |
#new_chat_little ⇒ Object
Returns the value of attribute new_chat_little.
23 24 25 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 23 def new_chat_little @new_chat_little end |
#new_chat_member ⇒ Object
Returns the value of attribute new_chat_member.
21 22 23 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 21 def new_chat_member @new_chat_member end |
#new_chat_photo ⇒ Object
Returns the value of attribute new_chat_photo.
24 25 26 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 24 def new_chat_photo @new_chat_photo end |
#parse_mode ⇒ Object
:markdown, :html
35 36 37 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 35 def parse_mode @parse_mode end |
#photo ⇒ Object
Returns the value of attribute photo.
13 14 15 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 13 def photo @photo end |
#pinned_message ⇒ Object
Returns the value of attribute pinned_message.
31 32 33 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 31 def @pinned_message end |
#reply_markup ⇒ Object
keyboard interface for reply - :inline/:reply/:reply_hide/:force_reply
39 40 41 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 39 def reply_markup @reply_markup end |
#reply_to_message ⇒ Object
Returns the value of attribute reply_to_message.
8 9 10 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 8 def @reply_to_message end |
#reply_to_message_id ⇒ Object
if the message is a reply, ID of the original message
38 39 40 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 38 def @reply_to_message_id end |
#sticker ⇒ Object
Returns the value of attribute sticker.
14 15 16 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 14 def sticker @sticker end |
#supergroup_chat_created ⇒ Object
Returns the value of attribute supergroup_chat_created.
27 28 29 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 27 def supergroup_chat_created @supergroup_chat_created end |
#text ⇒ Object
for message
34 35 36 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 34 def text @text end |
#venue ⇒ Object
Returns the value of attribute venue.
20 21 22 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 20 def venue @venue end |
#video ⇒ Object
Returns the value of attribute video.
15 16 17 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 15 def video @video end |
#voice ⇒ Object
Returns the value of attribute voice.
16 17 18 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 16 def voice @voice end |
Instance Method Details
#send ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/telegram_bot_builder/bot_message.rb', line 41 def send method = 'sendMessage' params = { chat_id: chat.id, text: text, } if parse_mode == :markdown params[:parse_mode] = 'Markdown' elsif parse_mode == :html params[:parse_mode] = 'HTML' end if disable_web_page_preview != nil params[:disable_web_page_preview] = disable_web_page_preview end if disable_notification != nil params[:disable_notification] = disable_notification end if reply_markup == :inline params[:reply_markup] = 'InlineKeyboardMarkup' elsif reply_markup == :reply params[:reply_markup] = 'ReplyKeyboardMarkup' elsif reply_markup == :reply_hide params[:reply_markup] = 'ReplyKeyboardHide' elsif reply_markup == :force_reply params[:reply_markup] = 'ForceReply' end uri = URI.parse(BotAPI::URLBUIDER.build(method)) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(params) result = http.request(request) if result.code == "200" return BotAPI.parse(method, result.body) end end |