telegrammer 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d0ee4efb76d8d569cc4082605df91692c262439
4
- data.tar.gz: f8955b60e5c18a973835e27c307d0d5e3df744d0
3
+ metadata.gz: 1e7d63ced4d594d0750cff564f42d74cc737ee9c
4
+ data.tar.gz: 47b850bb589fb3c4ee0a9be1e5ed2a70ed77c0cd
5
5
  SHA512:
6
- metadata.gz: 8f71a0902ead755f1ccf41d3c7f78754cbfa7b4492b7627c9fcff5fdd6fc9516da04bda3386635573e4166038501884e7dd1377b39932ce96443d6ba29010e2b
7
- data.tar.gz: db5a654a0873cc194c81fbbef051bcd0551b5e9d39f75b87ff2fe7fd1c0c68ebf4c0d697d0ac987845008a314bcd5107dd9ffea7fa8db0e8fac32fa0113452a8
6
+ metadata.gz: 514d1f49af6ca9fb18264f6eaaaac6d4b541efc8d150f0fe8140b8b19ae125af08b67b2bbdba6e93958d47e88c0c145bbb2f6e9fa827aee9d2cd903472cdaab3
7
+ data.tar.gz: bf8d83bdbac9e10b21ffe557fce10f4b669edca9b586f11b0b7f70076c0d1c5b4afac66c024dc1164f946882478779d21a25f2fff74277accd8f0bf5767a228f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ v0.7.0
2
+ ======
3
+
4
+ * Added support for supergroups (https://telegram.org/blog/supergroups).
5
+ * Added support for the new inline mode (https://core.telegram.org/bots/inline).
6
+ * Gem is now up to date with API version 2016-01-04 (https://core.telegram.org/bots/api-changelog#january-4-2016).
7
+
1
8
  v0.6.2
2
9
  ======
3
10
 
data/lib/telegrammer.rb CHANGED
@@ -26,6 +26,14 @@ require 'telegrammer/data_types/reply_keyboard_markup'
26
26
  require 'telegrammer/data_types/update'
27
27
  require 'telegrammer/data_types/user_profile_photos'
28
28
 
29
+ require 'telegrammer/data_types/chosen_inline_result'
30
+ require 'telegrammer/data_types/inline_query'
31
+ require 'telegrammer/data_types/inline_query_result_article'
32
+ require 'telegrammer/data_types/inline_query_result_gif'
33
+ require 'telegrammer/data_types/inline_query_result_mpeg4_gif'
34
+ require 'telegrammer/data_types/inline_query_result_photo'
35
+ require 'telegrammer/data_types/inline_query_result_video'
36
+
29
37
  require 'telegrammer/bot'
30
38
  require 'telegrammer/api_response'
31
39
 
@@ -443,12 +443,55 @@ module Telegrammer
443
443
  file_id: { required: true, class: [String] }
444
444
  }
445
445
 
446
- response = response = api_request("getFile", params, params_validation)
446
+ response = api_request("getFile", params, params_validation)
447
447
  file_object = Telegrammer::DataTypes::File.new(response.result)
448
448
 
449
449
  "#{API_ENDPOINT}/file/bot#{@api_token}/#{file_object.file_path}"
450
450
  end
451
451
 
452
+ # Answer an inline query. On success, True is returned. No more than 50 results per query are allowed.
453
+ #
454
+ # @param [Hash] params hash of paramers to send to the answerInlineQuery API operation.
455
+ # @option params [String] :inline_query_id Required. Unique identifier for the answered query
456
+ # @option params [Array] :results Required. An array of InlineQueryResults objects for the inline query
457
+ # @option params [Fixnum] :cache_time Optional. The maximum amount of time the result of the inline query may be cached on the server
458
+ # @option params [TrueClass,FalseClass] :is_personal Optional. Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
459
+ # @option params [String] :next_offset Optional. Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
460
+
461
+ #
462
+ # @example
463
+ # bot = Telegrammer::Bot.new('[YOUR TELEGRAM TOKEN]')
464
+ #
465
+ # bot.get_updates do |message|
466
+ # inline_query = message.inline_query
467
+ #
468
+ # if inline_query
469
+ # results = the_search_in_my_app(inline_query.query)
470
+ #
471
+ # bot.answer_inline_query(
472
+ # inline_query_id: "my-internal-query-id",
473
+ # results: results
474
+ # )
475
+ # end
476
+ # end
477
+
478
+ #
479
+ # @raise [Telegrammer::Errors::BadRequestError]
480
+ # @raise [Telegrammer::Errors::ServiceUnavailableError] if Telegram servers are down
481
+ #
482
+ # @return [TrueClass] True if all was OK
483
+ def answer_inline_query(params)
484
+ params_validation = {
485
+ inline_query_id: { required: true, class: [String] },
486
+ results: { required: true, class: [Array] },
487
+ cache_time: { required: false, class: [Fixnum] },
488
+ is_personal: { required: false, class: [TrueClass, FalseClass] },
489
+ next_offset: { required: false, class: [String] }
490
+ }
491
+
492
+ response = api_request("answerInlineQuery", params, params_validation)
493
+ end
494
+
452
495
  private
453
496
 
454
497
  def api_request(action, params, params_validation)
@@ -3,7 +3,7 @@ module Telegrammer
3
3
  # Telegram Chat data type
4
4
  #
5
5
  # @attr [Integer] id Unique identifier for this chat, not exceeding 1e13 by absolute value
6
- # @attr [String] type Type of chat, can be either “private”, or “group”, or “channel”
6
+ # @attr [String] type Type of chat, can be either “private”, “group”, “supergroup” or “channel”
7
7
  # @attr [String] title Optional. Title, for channels and group chats
8
8
  # @attr [String] username Optional. Username, for private chats and channels if available
9
9
  # @attr [String] first_name Optional. First name of the other party in a private chat
@@ -0,0 +1,16 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram ChosenInlineResult data type
4
+ #
5
+ # @attr [String] result_id The unique identifier for the result that was chosen.
6
+ # @attr [Telegrammer::DataTypes::User] from The user that chose the result.
7
+ # @attr [String] query The query that was used to obtain the result.
8
+ #
9
+ # See more at https://core.telegram.org/bots/api#choseninlineresult
10
+ class ChosenInlineResult < Telegrammer::DataTypes::Base
11
+ attribute :result_id, String
12
+ attribute :from, User
13
+ attribute :string, String
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQuery data type
4
+ #
5
+ # @attr [String] id Unique identifier for this query
6
+ # @attr [Telegrammer::DataTypes::User] from Sender
7
+ # @attr [String] query Text of the query
8
+ # @attr [String] offset Offset of the results to be returned, can be controlled by the bot
9
+ #
10
+ # See more at https://core.telegram.org/bots/api#inlinequery
11
+ class InlineQuery < Telegrammer::DataTypes::Base
12
+ attribute :id, String
13
+ attribute :from, User
14
+ attribute :query, String
15
+ attribute :offset, String
16
+ attribute :title, String
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQueryResultArticle data type
4
+ #
5
+ # @attr [String] type Type of the result, must be article
6
+ # @attr [String] id Unique identifier for this result, 1-64 Bytes
7
+ # @attr [String] title Title of the result
8
+ # @attr [String] message_text Text of the message to be sent
9
+ # @attr [String] parse_mode Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
10
+ # @attr [Boolean] disable_web_page_preview Optional. Disables link previews for links in the sent message
11
+ # @attr [String] url Optional. URL of the result
12
+ # @attr [Boolean] hide_url Optional. Pass True, if you don't want the URL to be shown in the message
13
+ # @attr [String] description Optional. Short description of the result
14
+ # @attr [String] thumb_url Optional. Url of the thumbnail for the result
15
+ # @attr [Integer] thumb_width Optional. Thumbnail width
16
+ # @attr [Integer] thumb_height Optional. Thumbnail height
17
+ #
18
+ # See more at https://core.telegram.org/bots/api#inlinequeryresultarticle
19
+ class InlineQueryResultArticle < Telegrammer::DataTypes::Base
20
+ attribute :type, String
21
+ attribute :id, String
22
+ attribute :title, String
23
+ attribute :message_text, String
24
+ attribute :parse_mode, String
25
+ attribute :disable_web_page_preview, Boolean
26
+ attribute :url, String
27
+ attribute :hide_url, Boolean
28
+ attribute :description, String
29
+ attribute :thumb_url, String
30
+ attribute :thumb_width, Integer
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQueryResultGif data type
4
+ #
5
+ # @attr [String] type Type of the result, must be gif
6
+ # @attr [String] id Unique identifier for this result, 1-64 bytes
7
+ # @attr [String] gif_url A valid URL for the GIF file. File size must not exceed 1MB
8
+ # @attr [Integer] gif_width Optional. Width of the GIF
9
+ # @attr [Integer] gif_height Optional. Height of the GIF
10
+ # @attr [String] thumb_url URL of the static thumbnail for the result (jpeg or gif)
11
+ # @attr [String] title Optional. Title for the result
12
+ # @attr [String] caption Optional. Caption of the GIF file to be sent, 0-200 characters
13
+ # @attr [String] message_text Optional. Text of a message to be sent instead of the animation, 1-512 characters
14
+ # @attr [String] parse_mode Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
15
+ # @attr [Boolean] disable_web_page_preview Optional. Disables link previews for links in the sent message
16
+ #
17
+ # See more at https://core.telegram.org/bots/api#inlinequeryresultgif
18
+ class InlineQueryResultGif < Telegrammer::DataTypes::Base
19
+ attribute :type, String
20
+ attribute :id, String
21
+ attribute :gif_url, String
22
+ attribute :gif_width, Integer
23
+ attribute :git_height, Integer
24
+ attribute :thumb_url, String
25
+ attribute :title, String
26
+ attribute :caption, String
27
+ attribute :message_text, String
28
+ attribute :parse_mode, String
29
+ attribute :disable_web_page_preview, Boolean
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQueryResultMpeg4Gif data type
4
+ #
5
+ # @attr [String] type Type of the result, must be mpeg4_gif
6
+ # @attr [String] id Unique identifier for this result, 1-64 bytes
7
+ # @attr [String] mpeg4_url A valid URL for the MP4 file. File size must not exceed 1MB
8
+ # @attr [Integer] mpeg4_width Optional. Video width
9
+ # @attr [Integer] mpeg4_height Optional. Video height
10
+ # @attr [String] thumb_url URL of the static thumbnail (jpeg or gif) for the result
11
+ # @attr [String] title Optional. Title for the result
12
+ # @attr [String] caption Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
13
+ # @attr [String] message_text Optional. Text of a message to be sent instead of the animation, 1-512 characters
14
+ # @attr [String] parse_mode Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
15
+ # @attr [Boolean] disable_web_page_preview Optional. Disables link previews for links in the sent message
16
+ #
17
+ # See more at https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
18
+ class InlineQueryResultMpeg4Gif < Telegrammer::DataTypes::Base
19
+ attribute :type, String
20
+ attribute :id, String
21
+ attribute :mpeg4_url, String
22
+ attribute :mpeg4_width, Integer
23
+ attribute :mpeg4_height, Integer
24
+ attribute :thumb_url, String
25
+ attribute :title, String
26
+ attribute :caption, String
27
+ attribute :message_text, String
28
+ attribute :parse_mode, String
29
+ attribute :disable_web_page_preview, Boolean
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQueryResultPhoto data type
4
+ #
5
+ # @attr [String] type Type of the result, must be article
6
+ # @attr [String] id Unique identifier for this result, 1-64 Bytes
7
+ # @attr [String] photo_url A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB
8
+ # @attr [Integer] photo_width Optional. Width of the photo
9
+ # @attr [Integer] photo_height Optional. Height of the photo
10
+ # @attr [String] thumb_url URL of the thumbnail for the photo
11
+ # @attr [String] title Title of the result
12
+ # @attr [String] description Optional. Short description of the result
13
+ # @attr [String] caption Optional. Caption of the photo to be sent, 0-200 characters
14
+ # @attr [String] message_text Optional. Text of a message to be sent instead of the photo, 1-512 characters
15
+ # @attr [String] parse_mode Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
16
+ # @attr [Boolean] disable_web_page_preview Optional. Disables link previews for links in the sent message
17
+ #
18
+ # See more at https://core.telegram.org/bots/api#inlinequeryresultphoto
19
+ class InlineQueryResultPhoto < Telegrammer::DataTypes::Base
20
+ attribute :type, String
21
+ attribute :id, String
22
+ attribute :photo_url, String
23
+ attribute :photo_width, Integer
24
+ attribute :photo_height, Integer
25
+ attribute :thumb_url, String
26
+ attribute :title, String
27
+ attribute :description, String
28
+ attribute :caption, String
29
+ attribute :message_text, String
30
+ attribute :parse_mode, String
31
+ attribute :disable_web_page_preview, Boolean
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ module Telegrammer
2
+ module DataTypes
3
+ # Telegram InlineQueryResultVideo data type
4
+ #
5
+ # @attr [String] type Type of the result, must be video
6
+ # @attr [String] id Unique identifier for this result, 1-64 bytes
7
+ # @attr [String] video_url A valid URL for the embedded video player or video file
8
+ # @attr [String] mime_type Mime type of the content of video url, “text/html” or “video/mp4”
9
+ # @attr [String] message_text Text of the message to be sent with the video, 1-512 characters
10
+ # @attr [String] parse_mode Optional. Send “Markdown”, if you want Telegram apps to show bold, italic and inline URLs in your bot's message.
11
+ # @attr [Boolean] disable_web_page_preview Optional. Disables link previews for links in the sent message
12
+ # @attr [Integer] video_width Optional. Video width
13
+ # @attr [Integer] video_height Optional. Video height
14
+ # @attr [Integer] video_duration Optional. Video duration in seconds
15
+ # @attr [String] thumb_url URL of the thumbnail (jpeg only) for the video
16
+ # @attr [String] title Title for the result
17
+ # @attr [String] description Optional. Short description of the result
18
+ #
19
+ # See more at https://core.telegram.org/bots/api#inlinequeryresultvideo
20
+ class InlineQueryResultVideo < Telegrammer::DataTypes::Base
21
+ attribute :type, String
22
+ attribute :id, String
23
+ attribute :video_url, String
24
+ attribute :mime_type, String
25
+ attribute :message_text, String
26
+ attribute :parse_mode, String
27
+ attribute :disable_web_page_preview, Boolean
28
+ attribute :video_width, Integer
29
+ attribute :video_height, Integer
30
+ attribute :video_duration, Integer
31
+ attribute :thumb_url, String
32
+ attribute :title, String
33
+ attribute :description, String
34
+ end
35
+ end
36
+ end
@@ -25,6 +25,10 @@ module Telegrammer
25
25
  # @attr [Telegrammer::DataTypes::PhotoSize] new_chat_photo Optional. A group photo was change to this value
26
26
  # @attr [Boolean] delete_chat_photo Optional. Informs that the group photo was deleted
27
27
  # @attr [Boolean] group_chat_created Optional. Informs that the group has been created
28
+ # @attr [Boolean] supergroup_chat_created Optional. Service message: the supergroup has been created
29
+ # @attr [Boolean] channel_chat_created Optional. Service message: the channel has been created
30
+ # @attr [Integer] migrate_to_chat_id Optional. The group has been migrated to a supergroup with the specified identifier, not exceeding 1e13 by absolute value
31
+ # @attr [Integer] migrate_from_chat_id Optional. The supergroup has been migrated from a group with the specified identifier, not exceeding 1e13 by absolute value
28
32
  #
29
33
  # See more at https://core.telegram.org/bots/api#message
30
34
  class Message < Telegrammer::DataTypes::Base
@@ -50,6 +54,10 @@ module Telegrammer
50
54
  attribute :new_chat_photo, Array[PhotoSize]
51
55
  attribute :delete_chat_photo, Boolean
52
56
  attribute :group_chat_created, Boolean
57
+ attribute :supergroup_chat_created, Boolean
58
+ attribute :channel_chat_created, Boolean
59
+ attribute :migrate_from_chat_id, Integer
60
+ attribute :migrate_to_chat_id, Integer
53
61
  end
54
62
  end
55
63
  end
@@ -4,11 +4,13 @@ module Telegrammer
4
4
  #
5
5
  # @attr [Integer] update_id The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially.
6
6
  # @attr [Telegrammer::DataTypes::Message] message Optional. New incoming message of any kind - text, photo, sticker, etc.
7
+ # @attr [Telegrammer::DataTypes::InlineQuery] inline_query Optional. New incoming inline query.
7
8
  #
8
9
  # See more at https://core.telegram.org/bots/api#update
9
10
  class Update < Telegrammer::DataTypes::Base
10
11
  attribute :update_id, Integer
11
12
  attribute :message, Message
13
+ attribute :inline_query, InlineQuery
12
14
  end
13
15
  end
14
16
  end
@@ -1,3 +1,3 @@
1
1
  module Telegrammer
2
- VERSION = '0.6.2'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegrammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis Mayoral
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-14 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -98,11 +98,18 @@ files:
98
98
  - lib/telegrammer/data_types/audio.rb
99
99
  - lib/telegrammer/data_types/base.rb
100
100
  - lib/telegrammer/data_types/chat.rb
101
+ - lib/telegrammer/data_types/chosen_inline_result.rb
101
102
  - lib/telegrammer/data_types/contact.rb
102
103
  - lib/telegrammer/data_types/document.rb
103
104
  - lib/telegrammer/data_types/file.rb
104
105
  - lib/telegrammer/data_types/force_reply.rb
105
106
  - lib/telegrammer/data_types/group_chat.rb
107
+ - lib/telegrammer/data_types/inline_query.rb
108
+ - lib/telegrammer/data_types/inline_query_result_article.rb
109
+ - lib/telegrammer/data_types/inline_query_result_gif.rb
110
+ - lib/telegrammer/data_types/inline_query_result_mpeg4_gif.rb
111
+ - lib/telegrammer/data_types/inline_query_result_photo.rb
112
+ - lib/telegrammer/data_types/inline_query_result_video.rb
106
113
  - lib/telegrammer/data_types/location.rb
107
114
  - lib/telegrammer/data_types/message.rb
108
115
  - lib/telegrammer/data_types/photo_array.rb
@@ -137,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
144
  version: '0'
138
145
  requirements: []
139
146
  rubyforge_project:
140
- rubygems_version: 2.4.5.1
147
+ rubygems_version: 2.5.1
141
148
  signing_key:
142
149
  specification_version: 4
143
150
  summary: Ruby client for the Telegram's Bots API