telegram-bot 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tasks/telegram-bot.rake +3 -2
- data/lib/telegram/bot/railtie.rb +2 -1
- data/lib/telegram/bot/routes_helper.rb +7 -1
- data/lib/telegram/bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5eceb612bf67f9b1f05245c19819f1751ef334d
|
4
|
+
data.tar.gz: 99cc3ab478fd7f8f27bbf07dd0489b860f9930ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 805ba831853459b8cf7153584c8038bc324b87daa994590e0f6ecd833bb5ac72ae2029a3513644f7c73c6ee88d20181f4d61bffb1e8fd64ed5d8a915d7eaae90
|
7
|
+
data.tar.gz: 5cb874f9de3cf0c96d24b3402364fcd8ef10dfac0131717f068175e3c9a86452a08b47ae5015d2e9cac8e4d19d56be44c162ce2134e91f6be7115106b8dbf985
|
data/lib/tasks/telegram-bot.rake
CHANGED
@@ -12,9 +12,10 @@ namespace :telegram do
|
|
12
12
|
routes = Rails.application.routes.url_helpers
|
13
13
|
cert_file = ENV['CERT']
|
14
14
|
cert = File.open(cert_file) if cert_file
|
15
|
-
Telegram.bots.
|
16
|
-
route_name = Telegram::RoutesHelper.route_name_for_bot(bot)
|
15
|
+
Telegram.bots.each do |key, bot|
|
16
|
+
route_name = Telegram::Bot::RoutesHelper.route_name_for_bot(bot)
|
17
17
|
url = routes.send("#{route_name}_url")
|
18
|
+
puts "Setting webhook for #{key}..."
|
18
19
|
bot.set_webhook(url: url, certificate: cert)
|
19
20
|
end
|
20
21
|
end
|
data/lib/telegram/bot/railtie.rb
CHANGED
@@ -25,7 +25,8 @@ module Telegram
|
|
25
25
|
initializer 'telegram.bot.updates_controller.add_ar_runtime' do
|
26
26
|
ActiveSupport.on_load('telegram.bot.updates_controller') do
|
27
27
|
if defined?(ActiveRecord::Railties::ControllerRuntime)
|
28
|
-
|
28
|
+
prepend ActiveRecord::Railties::ControllerRuntime
|
29
|
+
extend ActiveRecord::Railties::ControllerRuntime::ClassMethods
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -16,6 +16,12 @@ module Telegram
|
|
16
16
|
name && "#{name}_telegram_webhook"
|
17
17
|
end || 'telegram_webhook'
|
18
18
|
end
|
19
|
+
|
20
|
+
# Replaces colon with underscore so rails don't treat it as
|
21
|
+
# route parameter.
|
22
|
+
def escape_token(token)
|
23
|
+
token.tr(':', '_')
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
# # Create routes for all Telegram.bots to use same controller:
|
@@ -50,7 +56,7 @@ module Telegram
|
|
50
56
|
as: RoutesHelper.route_name_for_bot(bot),
|
51
57
|
format: false,
|
52
58
|
}.merge!(options).merge!(bot_options || {})
|
53
|
-
post("telegram/#{bot.token}", params)
|
59
|
+
post("telegram/#{RoutesHelper.escape_token bot.token}", params)
|
54
60
|
UpdatesPoller.add(bot, controller) if Telegram.bot_poller_mode?
|
55
61
|
end
|
56
62
|
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
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Melentiev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|