telegram_bot 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/telegram_bot/api_response.rb +4 -1
- data/lib/telegram_bot/out_message.rb +12 -3
- data/lib/telegram_bot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1205a818fad06f88ea0d6b45c3456a44e414ff1d
|
4
|
+
data.tar.gz: 30e9dcccd40322684e21d95f31b4bd4db78c0874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 382595c7ac6914f56af0fac5b1b957b03a81e220ddc80fd639e5135fb921867099d39cb59df4dc9ce84a45359fb4c2a617518c4652fbaa876fbf772e4661ea3f
|
7
|
+
data.tar.gz: f186585044bf4a3f2e27abe22626985f341ecdc76aadad35be6c88cdfaa4b6588e6a60ed309eb8e18fc940981da19d0c83fdc05f81187d0b149cc9e21962d54b
|
data/README.md
CHANGED
@@ -78,7 +78,7 @@ messages = bot.get_updates(timeout: 30, offset: 123)
|
|
78
78
|
Because things can go wrong sometimes with the API, there's a ``fail_silently`` option that you can pass to ``#get_updates`` like this:
|
79
79
|
```ruby
|
80
80
|
bot.get_updates(fail_silently: true) do |message|
|
81
|
-
|
81
|
+
puts message.text
|
82
82
|
end
|
83
83
|
```
|
84
84
|
|
@@ -101,8 +101,8 @@ message.channel.id # 123123123 (telegram's id)
|
|
101
101
|
|
102
102
|
# reply
|
103
103
|
message.reply do |reply|
|
104
|
-
|
105
|
-
|
104
|
+
reply.text = "homer please clean the garage"
|
105
|
+
reply.send_with(bot)
|
106
106
|
end
|
107
107
|
# or
|
108
108
|
reply = message.reply
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module TelegramBot
|
2
2
|
class ApiResponse
|
3
|
-
attr_reader :body, :ok, :result
|
3
|
+
attr_reader :body, :ok, :result, :description, :error_code
|
4
4
|
|
5
5
|
def initialize(res)
|
6
6
|
@body = res.body
|
@@ -9,7 +9,10 @@ module TelegramBot
|
|
9
9
|
@ok = data["ok"]
|
10
10
|
@result = data["result"]
|
11
11
|
else
|
12
|
+
data = JSON.parse(body)
|
12
13
|
@ok = false
|
14
|
+
@description = data["description"]
|
15
|
+
@error_code = data["error_code"]
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -3,6 +3,9 @@ module TelegramBot
|
|
3
3
|
include Virtus.model
|
4
4
|
attribute :chat, Channel
|
5
5
|
attribute :text, String
|
6
|
+
attribute :reply_to, Message
|
7
|
+
attribute :parse_mode, String
|
8
|
+
attribute :disable_web_page_preview, Boolean
|
6
9
|
|
7
10
|
def send_with(bot)
|
8
11
|
bot.send_message(self)
|
@@ -13,10 +16,16 @@ module TelegramBot
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def to_h
|
16
|
-
{
|
17
|
-
|
18
|
-
|
19
|
+
message = {
|
20
|
+
text: text,
|
21
|
+
chat_id: chat.id
|
19
22
|
}
|
23
|
+
|
24
|
+
message[:reply_to_message_id] = reply_to.id unless reply_to.nil?
|
25
|
+
message[:parse_mode] = parse_mode unless parse_mode.nil?
|
26
|
+
message[:disable_web_page_preview] = disable_web_page_preview unless disable_web_page_preview.nil?
|
27
|
+
|
28
|
+
message
|
20
29
|
end
|
21
30
|
end
|
22
31
|
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.5
|
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:
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.5.1
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Simple client for Telegram's Bot API
|