telegram-bot-ruby 0.2.4 → 0.2.5

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: b9f0ea70d6518a6c8151a83e6ab922c3b4724b49
4
- data.tar.gz: 2397c4d6744e443e3f9aae921566c130547ae870
3
+ metadata.gz: 78b3239cfaec3cd066e216eb93e9de6bc297636e
4
+ data.tar.gz: fe4dca782da5b1a22539943158fcdc9f573d27ea
5
5
  SHA512:
6
- metadata.gz: ac7225aaedd1f4261b6967b9788cf8e4836303434691ef771fe9eb97d32de77855d17220fe263d6dc25b8e504e5f056869bef85416b69cd245adf28eee3457ee
7
- data.tar.gz: 89ed4164c4173139cdaaa98865d731b0442af459d605289f632bfb67a606f267b6e8d3391347914d73b31b2af8b32ddbf5b8012325eb09f47256dfa7a194e590
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 /^\/start$/
40
+ when '/start'
41
41
  bot.api.sendMessage(chat_id: message.chat.id, text: "Hello, #{message.from.username}")
42
- when /^\/stop$/
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 /^\/start$/
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 /^\/stop$/
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 /^\/photo$/
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
@@ -27,7 +27,7 @@ module Telegram
27
27
 
28
28
  def chat=(value)
29
29
  @chat =
30
- if value.key?('username')
30
+ if value.key?('first_name')
31
31
  User.new(value)
32
32
  elsif value.key?('title')
33
33
  GroupChat.new(value)
@@ -1,5 +1,5 @@
1
1
  module Telegram
2
2
  module Bot
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
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
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-06-30 00:00:00.000000000 Z
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