telegram-bot-ruby 0.9.0 → 0.9.1
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/CHANGELOG.md +5 -0
- data/README.md +10 -0
- data/lib/telegram/bot/api.rb +4 -3
- data/lib/telegram/bot/client.rb +9 -4
- data/lib/telegram/bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2cb7116b2990f0bccbc7fadb1e34106a1e2ffe5fe319f79ee7907f01f4ee918
|
4
|
+
data.tar.gz: 46965b28805fecefee9b2f8beaa8b8d5bca6f539ef3bdd390e5bd5d31b146ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e73e3e3690a75a9de50e87af8effa1fd53a95b281f325fa230bd09d9e4f8ac9129aa9811064573469fdc6e15de1000f0b3554af8af8d0f1ab4a17d94edb45e6c
|
7
|
+
data.tar.gz: 79699f7dbda65732c6b940a54e6d39d0ea880481a7614e3d786f50902cab9ef67955a094420db9f300237972ed752166be6b0dd4c2d5c6683dd4c2c297e7b502
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.9.1
|
4
|
+
|
5
|
+
- Allow to configure API URL (thx [@markfrst][])
|
6
|
+
|
3
7
|
## 0.9.0
|
4
8
|
|
5
9
|
- Implement [Bot API 4.2](https://core.telegram.org/bots/api-changelog#april-14-2019)
|
@@ -73,3 +77,4 @@
|
|
73
77
|
- Let `Client#logger` be overwritten later (use `attr_accessor` instead of `attr_reader`)
|
74
78
|
|
75
79
|
[@ivanovaleksey]: https://github.com/ivanovaleksey
|
80
|
+
[@markfrst]: https://github.com/markfrst
|
data/README.md
CHANGED
@@ -56,6 +56,16 @@ Same thing about `message` object - it implements [Message](https://core.telegra
|
|
56
56
|
|
57
57
|
If you are going to use [webhooks](https://core.telegram.org/bots/api#setwebhook) instead of [long polling](https://core.telegram.org/bots/api#getupdates), you need to implement your own webhook callbacks server. Take a look at [this repo](https://github.com/solyaris/BOTServer) as an example.
|
58
58
|
|
59
|
+
## Proxy
|
60
|
+
|
61
|
+
As some countries block access to Telegram, you can set up your own proxy and use it to access Telegram API. In this case you need to configure API url:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
Telegram::Bot::Client.run(token, url: 'https://proxy.example.com') do |bot|
|
65
|
+
# ...
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
59
69
|
## Custom keyboards
|
60
70
|
|
61
71
|
You can use your own [custom keyboards](https://core.telegram.org/bots#keyboards). Here is an example:
|
data/lib/telegram/bot/api.rb
CHANGED
@@ -48,10 +48,11 @@ module Telegram
|
|
48
48
|
Telegram::Bot::Types::InlineQueryResultCachedAudio
|
49
49
|
].freeze
|
50
50
|
|
51
|
-
attr_reader :token
|
51
|
+
attr_reader :token, :url
|
52
52
|
|
53
|
-
def initialize(token)
|
53
|
+
def initialize(token, url: 'https://api.telegram.org')
|
54
54
|
@token = token
|
55
|
+
@url = url
|
55
56
|
end
|
56
57
|
|
57
58
|
def method_missing(method_name, *args, &block)
|
@@ -110,7 +111,7 @@ module Telegram
|
|
110
111
|
end
|
111
112
|
|
112
113
|
def conn
|
113
|
-
@conn ||= Faraday.new(url:
|
114
|
+
@conn ||= Faraday.new(url: url) do |faraday|
|
114
115
|
faraday.request :multipart
|
115
116
|
faraday.request :url_encoded
|
116
117
|
faraday.adapter Telegram::Bot.configuration.adapter
|
data/lib/telegram/bot/client.rb
CHANGED
@@ -8,9 +8,9 @@ module Telegram
|
|
8
8
|
new(*args).run(&block)
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(token,
|
12
|
-
@options = default_options.merge(
|
13
|
-
@api = Api.new(token)
|
11
|
+
def initialize(token, hash = {})
|
12
|
+
@options = default_options.merge(hash)
|
13
|
+
@api = Api.new(token, url: options.delete(:url))
|
14
14
|
@logger = options.delete(:logger)
|
15
15
|
end
|
16
16
|
|
@@ -44,7 +44,12 @@ module Telegram
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def default_options
|
47
|
-
{
|
47
|
+
{
|
48
|
+
offset: 0,
|
49
|
+
timeout: 20,
|
50
|
+
logger: NullLogger.new,
|
51
|
+
url: 'https://api.telegram.org'
|
52
|
+
}
|
48
53
|
end
|
49
54
|
|
50
55
|
def log_incoming_message(message)
|
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.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Tipugin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|