telegram-ruby 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7533e24832aa9f7ec818f5536f1bf8c8b0957dd712ad8e92b9e90860ff21c8bf
4
- data.tar.gz: cb7e6877c72be165e5042c0f3198c228c939ed7995b0d985e8ed179dcee6a9d1
3
+ metadata.gz: eaeb8d7427db178da5a2b7b1785be1a19245c4af1482e7cfdea12e6b47ad60dc
4
+ data.tar.gz: 13349eb5fb126a938a8c99d93ce5976f8b2a66b7e950ba86a31267cf69781763
5
5
  SHA512:
6
- metadata.gz: 672c7a66b3a9859852194daf1c0ed7da7009c0aaced7109becb81352ad8bbf9928ac94a023c6c864361b8e5d64f23a379d19dbf9dfb01ff4874d3e83426c9063
7
- data.tar.gz: 306ef69d1c49f3dde32b597ea3676cb14050e558bdc4ec6807416cc313416bfcadf213e27ab0ae87fdf74f58dd032cc4b15f14bd824c545176e7f93679611352
6
+ metadata.gz: d73e6f9a24f9140003de2cc46358521257d3004402ed6b81287f97a899889ca7b60b697f553af65ca814bbf4892b736b45a0f56eadbcdc449e7935b958cc9f3f
7
+ data.tar.gz: 85034f2a4b400ef0521c0ef87804542d33ca09d62d9b083ac81679f1cd628506859ba774a98793c64fca06f3e5138cc5d59528e25d8ffa51753060384e0ebc98
data/README.md CHANGED
@@ -35,7 +35,8 @@ require 'telegram/bot'
35
35
  Telegram::Bot.configure do |conf|
36
36
  conf.token = 'Here your token'
37
37
  conf.raise_exceptions = false #By default true
38
- conf.name = '@MyBot
38
+ conf.name = '@MyBot'
39
+ conf.botan_token = 'Botan token' #If using botan.io
39
40
  end
40
41
  ```
41
42
 
@@ -87,7 +88,9 @@ In your handler you can use helper accessors
87
88
 
88
89
  **message** - This [object](https://core.telegram.org/bots/api#message) represents a message.
89
90
 
90
- **command** - current command if found in message text (without prefix cmd_)
91
+ **command** - Current command if found in message text (without prefix cmd_)
92
+
93
+ **botan** - This object represents a [botan](http://botan.io) integration
91
94
 
92
95
  ### Send Photo
93
96
  From url
@@ -99,6 +102,20 @@ From server
99
102
  api.sendPhoto([Chat id], Faraday::UploadIO.new([patg to image], 'image/png', 'my_image.png'), {caption: 'Image caption'})
100
103
  ```
101
104
 
105
+ ### Botan
106
+
107
+ The most advanced analytics for your Telegram bot.
108
+ See more information on [botan.io](http://botan.io)
109
+
110
+ Usage
111
+ ```
112
+ botan = Telegram::Bot::Botan([appmetrica-token])
113
+ uid = 123
114
+ message = 'text'
115
+ name = 'search'
116
+ botan.track(uid, message, name)
117
+ ```
118
+
102
119
  ## Contributing
103
120
 
104
121
  Bug reports and pull requests are welcome on GitHub at https://github.com/Stajor/telegram-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -8,6 +8,7 @@ require 'telegram/bot/api'
8
8
  require 'telegram/bot/types'
9
9
  require 'telegram/bot/client'
10
10
  require 'telegram/bot/client_accessors'
11
+ require 'telegram/bot/botan'
11
12
 
12
13
  module Telegram
13
14
  module Bot
@@ -0,0 +1,23 @@
1
+ module Telegram::Bot
2
+ class Botan
3
+ API_URL = 'https://api.botan.io'.freeze
4
+
5
+ def initialize(token = nil)
6
+ @token = token || Telegram::Bot.configuration.botan_token
7
+ end
8
+
9
+ def track(uid, message, name)
10
+ begin
11
+ response = Faraday.new(url: API_URL).post do |req|
12
+ req.url "/track?token=#{@token}&uid=#{uid}&name=#{name}"
13
+ req.headers['Content-Type'] = 'application/json'
14
+ req.body = JSON.dump({text: message})
15
+ end
16
+
17
+ JSON.parse(response.body)
18
+ rescue => e
19
+ raise Telegram::Bot::Exceptions::BotanError.new(e.message)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -7,6 +7,7 @@ module Telegram::Bot
7
7
  def initialize(handler)
8
8
  @handler = handler.new
9
9
  @handler.api = Telegram::Bot::Api.new
10
+ @handler.botan = Telegram::Bot::Botan.new
10
11
  end
11
12
 
12
13
  def handle(params)
@@ -1,5 +1,5 @@
1
1
  module Telegram::Bot
2
2
  module ClientAccessors
3
- attr_accessor :api, :update, :message, :command
3
+ attr_accessor :api, :update, :message, :command, :botan
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  module Telegram
2
2
  module Bot
3
3
  class Configuration
4
- attr_accessor :token, :raise_exceptions, :name
4
+ attr_accessor :token, :raise_exceptions, :name, :botan_token
5
5
 
6
6
  def initialize
7
7
  @raise_exceptions = true
@@ -8,6 +8,8 @@ module Telegram
8
8
  class ParseError < Error; end
9
9
 
10
10
  class KeyboardMarkupError < Error; end
11
+
12
+ class BotanError < Error; end
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,3 @@
1
1
  module Telegram
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegram-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Belenky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,6 +102,7 @@ files:
102
102
  - examples/client/handler.rb
103
103
  - lib/telegram/bot.rb
104
104
  - lib/telegram/bot/api.rb
105
+ - lib/telegram/bot/botan.rb
105
106
  - lib/telegram/bot/client.rb
106
107
  - lib/telegram/bot/client_accessors.rb
107
108
  - lib/telegram/bot/configuration.rb