telegram-ruby 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -2
- data/lib/telegram/bot.rb +1 -0
- data/lib/telegram/bot/botan.rb +23 -0
- data/lib/telegram/bot/client.rb +1 -0
- data/lib/telegram/bot/client_accessors.rb +1 -1
- data/lib/telegram/bot/configuration.rb +1 -1
- data/lib/telegram/bot/exceptions.rb +2 -0
- data/lib/telegram/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaeb8d7427db178da5a2b7b1785be1a19245c4af1482e7cfdea12e6b47ad60dc
|
4
|
+
data.tar.gz: 13349eb5fb126a938a8c99d93ce5976f8b2a66b7e950ba86a31267cf69781763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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** -
|
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.
|
data/lib/telegram/bot.rb
CHANGED
@@ -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
|
data/lib/telegram/bot/client.rb
CHANGED
data/lib/telegram/version.rb
CHANGED
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.
|
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
|
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
|