Class: BotMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/telegram_bot_builder/bot_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



11
12
13
# File 'lib/telegram_bot_builder/bot_message.rb', line 11

def audio
  @audio
end

#captionObject

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_createdObject

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

#chatObject

is user object



5
6
7
# File 'lib/telegram_bot_builder/bot_message.rb', line 5

def chat
  @chat
end

#contactObject

Returns the value of attribute contact.



18
19
20
# File 'lib/telegram_bot_builder/bot_message.rb', line 18

def contact
  @contact
end

#dateObject

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_photoObject

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_notificationObject

true/false



37
38
39
# File 'lib/telegram_bot_builder/bot_message.rb', line 37

def disable_notification
  @disable_notification
end

#disable_web_page_previewObject

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

#documentObject

Returns the value of attribute document.



12
13
14
# File 'lib/telegram_bot_builder/bot_message.rb', line 12

def document
  @document
end

#entitiesObject

Returns the value of attribute entities.



10
11
12
# File 'lib/telegram_bot_builder/bot_message.rb', line 10

def entities
  @entities
end

#forward_dateObject

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_fromObject

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

#fromObject

is user object



3
4
5
# File 'lib/telegram_bot_builder/bot_message.rb', line 3

def from
  @from
end

#group_chat_createdObject

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_memberObject

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

#locationObject

Returns the value of attribute location.



19
20
21
# File 'lib/telegram_bot_builder/bot_message.rb', line 19

def location
  @location
end

#message_idObject

Returns the value of attribute message_id.



2
3
4
# File 'lib/telegram_bot_builder/bot_message.rb', line 2

def message_id
  @message_id
end

#migrate_from_chat_idObject

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_idObject

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_littleObject

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_memberObject

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_photoObject

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_modeObject

:markdown, :html



35
36
37
# File 'lib/telegram_bot_builder/bot_message.rb', line 35

def parse_mode
  @parse_mode
end

#photoObject

Returns the value of attribute photo.



13
14
15
# File 'lib/telegram_bot_builder/bot_message.rb', line 13

def photo
  @photo
end

#pinned_messageObject

Returns the value of attribute pinned_message.



31
32
33
# File 'lib/telegram_bot_builder/bot_message.rb', line 31

def pinned_message
  @pinned_message
end

#reply_markupObject

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_messageObject

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
  @reply_to_message
end

#reply_to_message_idObject

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
  @reply_to_message_id
end

#stickerObject

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_createdObject

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

#textObject

for message



34
35
36
# File 'lib/telegram_bot_builder/bot_message.rb', line 34

def text
  @text
end

#venueObject

Returns the value of attribute venue.



20
21
22
# File 'lib/telegram_bot_builder/bot_message.rb', line 20

def venue
  @venue
end

#videoObject

Returns the value of attribute video.



15
16
17
# File 'lib/telegram_bot_builder/bot_message.rb', line 15

def video
  @video
end

#voiceObject

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

#sendObject



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