telegram_bot 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/telegram_bot.rb +4 -0
- data/lib/telegram_bot/force_replay.rb +22 -0
- data/lib/telegram_bot/keyboard.rb +5 -0
- data/lib/telegram_bot/out_message.rb +2 -0
- data/lib/telegram_bot/reply_keyboard_hide.rb +31 -0
- data/lib/telegram_bot/reply_keyboard_markup.rb +39 -0
- data/lib/telegram_bot/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46b3af1c9c15bfd7fee3afb047af8491f0438be7
|
4
|
+
data.tar.gz: c15932937abf729352f39858151060e15ce45cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1877d5b81089d6a5e705455a05ec575972e564f495052124b944a296423ae73fad55457a1e3232dcce385de26a75d83be6fecefc789444d057526a954413bfd
|
7
|
+
data.tar.gz: efc71998e43116e210bad3e50fb630c86697f470451dfed1213fbb41ea56da160c4c827ba43666811c59d4fbd33faff622e04b6735757f74da00ba0847f0bb74
|
data/.gitignore
CHANGED
data/lib/telegram_bot.rb
CHANGED
@@ -8,6 +8,10 @@ require "telegram_bot/user"
|
|
8
8
|
require "telegram_bot/group_chat"
|
9
9
|
require "telegram_bot/channel"
|
10
10
|
require "telegram_bot/message"
|
11
|
+
require "telegram_bot/keyboard"
|
12
|
+
require "telegram_bot/reply_keyboard_hide"
|
13
|
+
require "telegram_bot/reply_keyboard_markup"
|
14
|
+
require "telegram_bot/force_replay"
|
11
15
|
require "telegram_bot/out_message"
|
12
16
|
require "telegram_bot/update"
|
13
17
|
require "telegram_bot/api_response"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
class ForceReply < Keyboard
|
3
|
+
|
4
|
+
# Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
|
5
|
+
# Always true
|
6
|
+
# attribute :force_reply, Boolean
|
7
|
+
|
8
|
+
# Optional. Use this parameter if you want to force reply from specific users only.
|
9
|
+
# Targets:
|
10
|
+
# 1) users that are @mentioned in the text of the Message object;
|
11
|
+
# 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
12
|
+
attribute :selective, Boolean, :default => false
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
h = {force_reply: true}
|
19
|
+
h[:selective] = selective unless selective.nil?
|
20
|
+
h
|
21
|
+
end
|
22
|
+
end
|
@@ -6,6 +6,7 @@ module TelegramBot
|
|
6
6
|
attribute :reply_to, Message
|
7
7
|
attribute :parse_mode, String
|
8
8
|
attribute :disable_web_page_preview, Boolean
|
9
|
+
attribute :reply_markup, Keyboard
|
9
10
|
|
10
11
|
def send_with(bot)
|
11
12
|
bot.send_message(self)
|
@@ -24,6 +25,7 @@ module TelegramBot
|
|
24
25
|
message[:reply_to_message_id] = reply_to.id unless reply_to.nil?
|
25
26
|
message[:parse_mode] = parse_mode unless parse_mode.nil?
|
26
27
|
message[:disable_web_page_preview] = disable_web_page_preview unless disable_web_page_preview.nil?
|
28
|
+
message[:reply_markup] = reply_markup.to_h.to_json unless reply_markup.nil?
|
27
29
|
|
28
30
|
message
|
29
31
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
#
|
3
|
+
# Upon receiving a message with this object, Telegram clients will hide the current custom keyboard
|
4
|
+
# and display the default letter-keyboard.
|
5
|
+
# By default, custom keyboards are displayed until a new keyboard is sent by a bot.
|
6
|
+
# An exception is made for one-time keyboards that are hidden immediately after the user presses a button
|
7
|
+
# (see ReplyKeyboardMarkup).
|
8
|
+
class ReplyKeyboardHide < Keyboard
|
9
|
+
|
10
|
+
# Requests clients to hide the custom keyboard
|
11
|
+
# Always true
|
12
|
+
# attribute :hide_keyboard, Boolean
|
13
|
+
|
14
|
+
# Optional. Use this parameter if you want to hide keyboard for specific users only.
|
15
|
+
# Targets:
|
16
|
+
# 1) users that are @mentioned in the text of the Message object;
|
17
|
+
# 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
18
|
+
#
|
19
|
+
# Example: A user votes in a poll,
|
20
|
+
# bot returns confirmation message in reply to the vote and hides keyboard for that user,
|
21
|
+
# while still showing the keyboard with poll options to users who haven't voted yet.
|
22
|
+
attribute :selective, Boolean, :default => false
|
23
|
+
|
24
|
+
def to_h
|
25
|
+
h = { hide_keyboard: true }
|
26
|
+
h[:selective] = selective unless selective.nil?
|
27
|
+
h
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module TelegramBot
|
2
|
+
#
|
3
|
+
# This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
|
4
|
+
#
|
5
|
+
class ReplyKeyboardMarkup < Keyboard
|
6
|
+
|
7
|
+
# Array of button rows, each represented by an Array of Strings
|
8
|
+
attribute :keyboard, Array
|
9
|
+
|
10
|
+
# Optional. Requests clients to resize the keyboard vertically for optimal fit
|
11
|
+
# (e.g., make the keyboard smaller if there are just two rows of buttons).
|
12
|
+
# Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
|
13
|
+
attribute :resize_keyboard, Boolean, :default => false
|
14
|
+
|
15
|
+
# Optional. Requests clients to hide the keyboard as soon as it's been used.
|
16
|
+
# Defaults to false.
|
17
|
+
attribute :one_time_keyboard, Boolean, :default => false
|
18
|
+
|
19
|
+
# Optional. Use this parameter if you want to show the keyboard to specific users only.
|
20
|
+
#
|
21
|
+
# Targets:
|
22
|
+
# 1) users that are @mentioned in the text of the Message object;
|
23
|
+
# 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
|
24
|
+
#
|
25
|
+
# Example: A user requests to change the bot‘s language,
|
26
|
+
# bot replies to the request with a keyboard to select the new language.
|
27
|
+
# Other users in the group don’t see the keyboard.
|
28
|
+
attribute :selective, Boolean, :default => false
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_h
|
33
|
+
h = {keyboard: keyboard}
|
34
|
+
h[:resize_keyboard] = resize_keyboard unless resize_keyboard.nil?
|
35
|
+
h[:one_time_keyboard] = one_time_keyboard unless one_time_keyboard.nil?
|
36
|
+
h[:selective] = selective unless selective.nil?
|
37
|
+
h
|
38
|
+
end
|
39
|
+
end
|
data/lib/telegram_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Tomás Albornoz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -86,10 +86,14 @@ files:
|
|
86
86
|
- lib/telegram_bot/api_response.rb
|
87
87
|
- lib/telegram_bot/bot.rb
|
88
88
|
- lib/telegram_bot/channel.rb
|
89
|
+
- lib/telegram_bot/force_replay.rb
|
89
90
|
- lib/telegram_bot/group_chat.rb
|
91
|
+
- lib/telegram_bot/keyboard.rb
|
90
92
|
- lib/telegram_bot/message.rb
|
91
93
|
- lib/telegram_bot/null_logger.rb
|
92
94
|
- lib/telegram_bot/out_message.rb
|
95
|
+
- lib/telegram_bot/reply_keyboard_hide.rb
|
96
|
+
- lib/telegram_bot/reply_keyboard_markup.rb
|
93
97
|
- lib/telegram_bot/update.rb
|
94
98
|
- lib/telegram_bot/user.rb
|
95
99
|
- lib/telegram_bot/version.rb
|