telegram-bot-ruby 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/examples/bot.rb +17 -0
- data/lib/telegram/bot/types/message.rb +1 -1
- data/lib/telegram/bot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78b3239cfaec3cd066e216eb93e9de6bc297636e
|
4
|
+
data.tar.gz: fe4dca782da5b1a22539943158fcdc9f573d27ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ef6457d157c9fd7ee158e36d88a9708192aaf629d191be0f5f4b6c21b5dbae088119b4d7ad2ab11bf7d20ab229fbc2be63b0af3980f99d52bc36ca27b285ed4
|
7
|
+
data.tar.gz: 4c91802a720df20bf90dd7417f0f15f01c8f40999dbd5a9d2444a52f13b73e829ba39bc615f296f36ea85e7f7730b1291747a2000a699f929f22026e6baa94e2
|
data/README.md
CHANGED
@@ -37,9 +37,9 @@ token = 'YOUR_TELEGRAM_BOT_API_TOKEN'
|
|
37
37
|
Telegram::Bot::Client.run(token) do |bot|
|
38
38
|
bot.listen do |message|
|
39
39
|
case message.text
|
40
|
-
when
|
40
|
+
when '/start'
|
41
41
|
bot.api.sendMessage(chat_id: message.chat.id, text: "Hello, #{message.from.username}")
|
42
|
-
when
|
42
|
+
when '/stop'
|
43
43
|
bot.api.sendMessage(chat_id: message.chat.id, text: "Bye, #{message.from.username}")
|
44
44
|
end
|
45
45
|
end
|
@@ -57,14 +57,14 @@ You can use your own [custom keyboards](https://core.telegram.org/bots#keyboards
|
|
57
57
|
```ruby
|
58
58
|
bot.listen do |message|
|
59
59
|
case message.text
|
60
|
-
when
|
60
|
+
when '/start'
|
61
61
|
question = 'London is a capital of which country?'
|
62
62
|
# See more: https://core.telegram.org/bots/api#replykeyboardmarkup
|
63
63
|
answers =
|
64
64
|
Telegram::Bot::Types::ReplyKeyboardMarkup
|
65
65
|
.new(keyboard: [%w(A B), %w(C D)], one_time_keyboard: true)
|
66
66
|
bot.api.sendMessage(chat_id: message.chat.id, text: question, reply_markup: answers)
|
67
|
-
when
|
67
|
+
when '/stop'
|
68
68
|
# See more: https://core.telegram.org/bots/api#replykeyboardhide
|
69
69
|
kb = Telegram::Bot::Types::ReplyKeyboardHide.new(hide_keyboard: true)
|
70
70
|
bot.api.sendMessage(chat_id: message.chat.id, text: 'Sorry to see you go :(', reply_markup: kb)
|
@@ -79,7 +79,7 @@ Your bot can even upload files ([photos](https://core.telegram.org/bots/api#send
|
|
79
79
|
```ruby
|
80
80
|
bot.listen do |message|
|
81
81
|
case message.text
|
82
|
-
when
|
82
|
+
when '/photo'
|
83
83
|
bot.api.sendPhoto(chat_id: message.chat.id, photo: File.new('~/Desktop/jennifer.jpg'))
|
84
84
|
end
|
85
85
|
end
|
data/examples/bot.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'telegram/bot'
|
3
|
+
|
4
|
+
token = 'replace-me-with-your-real-token'
|
5
|
+
|
6
|
+
Telegram::Bot::Client.run(token) do |bot|
|
7
|
+
bot.listen do |message|
|
8
|
+
case message.text
|
9
|
+
when '/start'
|
10
|
+
bot.api.sendMessage(chat_id: message.chat.id, text: "Hello, #{message.from.username}!")
|
11
|
+
when '/end'
|
12
|
+
bot.api.sendMessage(chat_id: message.chat.id, text: "Bye, #{message.from.username}!")
|
13
|
+
else
|
14
|
+
bot.api.sendMessage(chat_id: message.chat.id, text: "I don't understand you :(")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Tipugin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httmultiparty
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- bin/console
|
125
125
|
- bin/setup
|
126
|
+
- examples/bot.rb
|
126
127
|
- lib/telegram/bot.rb
|
127
128
|
- lib/telegram/bot/api.rb
|
128
129
|
- lib/telegram/bot/client.rb
|