telegram-rails 0.1.1 → 0.1.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc8e332062f1de259d8d94fc1a085d939ba651e
|
4
|
+
data.tar.gz: 92f18fd15c4d8bb3b3937dab3a76c24ba5e57e3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55c1e49bcb0ca3b075dc23ed3a948d50d0ce457c199ee3ea3b8c03aa5d81d0365cf81ee4d10efac3e49746e33420e05757cc4a495477645af0fac2aa4b5fa2a5
|
7
|
+
data.tar.gz: 20be9baa1e333b9704761d135ed71eeea26fa7732a623885536a0e9335bbc744d7e84855f23f603ac01e6f4bb98ae220f76d81fdcee6f086718d59b14342ab67
|
data/lib/telegram/controller.rb
CHANGED
@@ -8,19 +8,10 @@ require 'telegram/controller/renderer'
|
|
8
8
|
module Telegram
|
9
9
|
class Controller
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def bot_name= name
|
17
|
-
@bot_name = name
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
def message= payload
|
22
|
-
@message = payload
|
23
|
-
end
|
11
|
+
attr_writer :bots
|
12
|
+
attr_writer :bot_name
|
13
|
+
attr_writer :message
|
14
|
+
attr_writer :params
|
24
15
|
|
25
16
|
|
26
17
|
def dispatch action
|
@@ -101,6 +92,11 @@ module Telegram
|
|
101
92
|
end
|
102
93
|
|
103
94
|
|
95
|
+
def params
|
96
|
+
@params
|
97
|
+
end
|
98
|
+
|
99
|
+
|
104
100
|
def send_message *args
|
105
101
|
bot.api.send_message *args
|
106
102
|
@has_response = true
|
@@ -18,7 +18,7 @@ module Telegram
|
|
18
18
|
|
19
19
|
|
20
20
|
def render opts = {}
|
21
|
-
options = opts
|
21
|
+
options = normalize_options(opts)
|
22
22
|
view = Controller::ViewObject.new(@controller.expose_instance_variables)
|
23
23
|
template_file_name, response_format = resolve_template(options)
|
24
24
|
|
@@ -32,6 +32,14 @@ module Telegram
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
+
def normalize_options opts
|
36
|
+
if opts.is_a? String
|
37
|
+
opts = {template: opts}
|
38
|
+
end
|
39
|
+
default_render_options.merge(opts)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
35
43
|
def default_render_options
|
36
44
|
controller_name = @controller.class.to_s.underscore.gsub(/_controller$/,'')
|
37
45
|
{
|
@@ -32,7 +32,7 @@ module Telegram
|
|
32
32
|
route = find_route_for bot_name, command
|
33
33
|
return unless route
|
34
34
|
|
35
|
-
process_message message, with: route
|
35
|
+
process_message message, with: route, args: args, command: command
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -58,19 +58,23 @@ module Telegram
|
|
58
58
|
|
59
59
|
def process_message message, opts
|
60
60
|
route = opts[:with]
|
61
|
+
|
61
62
|
controller = route[:controller_class].new
|
62
63
|
controller.tap do |c|
|
63
64
|
c.bots = @adapters
|
64
65
|
c.bot_name = route[:bot_name]
|
65
66
|
c.message = message
|
67
|
+
c.params = {
|
68
|
+
command: opts[:command],
|
69
|
+
args: opts[:args],
|
70
|
+
}
|
66
71
|
end
|
67
72
|
|
68
73
|
controller.dispatch route[:action_name]
|
69
|
-
#HERE args support
|
70
74
|
end
|
71
75
|
|
72
76
|
|
73
|
-
#TEST
|
77
|
+
# TEST
|
74
78
|
def parse_route route_data
|
75
79
|
route_string = route_data[:route]
|
76
80
|
options = route_data[:options]
|
@@ -79,7 +83,7 @@ module Telegram
|
|
79
83
|
bot_name, command = segments
|
80
84
|
|
81
85
|
bot_name = bot_name.to_sym if bot_name
|
82
|
-
command = command.to_sym
|
86
|
+
command = command.to_sym if command
|
83
87
|
|
84
88
|
endpoint = options[:to]
|
85
89
|
controller_name, action_name = endpoint.to_s.split ENDPOINT_DELIMETER, 2
|
@@ -96,6 +100,7 @@ module Telegram
|
|
96
100
|
end
|
97
101
|
|
98
102
|
|
103
|
+
# TEST
|
99
104
|
# get command name from payload
|
100
105
|
def extract_command_from payload
|
101
106
|
command_str = payload.text
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav E. Govorov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: telegram-bot-ruby
|