senrigan 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/senrigan/adapter.rb +17 -26
- data/lib/senrigan/version.rb +1 -1
- data/senrigan.gemspec +3 -2
- metadata +29 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31e1010fe33a276e722f409afa222d52fd9f0640cfb3718da9182d3e6307ec88
|
4
|
+
data.tar.gz: 932916ac50b24d6e80a38cbbd64384f30cc12e48cad3c09a6eb41cf52b9a01ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b3fc066d08f12627258daedc9f4e4b7d378c996454d78ebd28b1c4a2c38395120d190c5124088f4ed6006ec09c38cf9e46d15b2a6c2081bdd2b1f6b7e14a5d6
|
7
|
+
data.tar.gz: 56c06758235706b3a7be1ad3c73a985a590bb9f991cd1552af142f17d8436fc4154c2339c432d1fc4654ce97bbf45ba340a06fc702e0da40510d8edb3077e8a5
|
data/lib/senrigan/adapter.rb
CHANGED
@@ -29,6 +29,8 @@ module Senrigan
|
|
29
29
|
@rtm.start!
|
30
30
|
rescue StandardError => e
|
31
31
|
STDOUT.puts e.inspect if ENV['DEBUG'].to_i != 0
|
32
|
+
ensure
|
33
|
+
@rtm.stop! rescue nil
|
32
34
|
end
|
33
35
|
sleep 5
|
34
36
|
end
|
@@ -49,10 +51,7 @@ module Senrigan
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def regenerate_cache
|
52
|
-
@channel_caches =
|
53
|
-
@client.channels_list['channels'] +
|
54
|
-
@client.groups_list['groups']
|
55
|
-
).map { |c| [c['id'], c] }.to_h
|
54
|
+
@channel_caches = {}
|
56
55
|
@user_caches = @client.users_list['members'].map { |u| [u['id'], u] }.to_h
|
57
56
|
end
|
58
57
|
|
@@ -61,37 +60,23 @@ module Senrigan
|
|
61
60
|
resp = @client.users_info(
|
62
61
|
user: user_id
|
63
62
|
)
|
64
|
-
resp['
|
63
|
+
resp['user'] || OpenStruct.new
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
67
|
def fetch_channel(channel_id)
|
69
68
|
@channel_caches[channel_id] ||= begin
|
70
|
-
data =
|
71
|
-
case channel_id.first
|
72
|
-
when 'C'
|
73
|
-
resp = @client.conversations_info(
|
74
|
-
channel: channel_id
|
75
|
-
)
|
76
|
-
resp['channel']
|
77
|
-
when 'G'
|
78
|
-
resp = @client.groups_info(
|
79
|
-
channel: channel_id
|
80
|
-
)
|
81
|
-
resp['group']
|
82
|
-
else
|
83
|
-
OpenStruct.new(name: channel_id, is_private: true)
|
84
|
-
end
|
69
|
+
data = @client.conversations_info(channel: channel_id)['channel']
|
85
70
|
data || OpenStruct.new(name: channel_id, is_private: false)
|
86
71
|
end
|
87
72
|
end
|
88
73
|
|
89
74
|
def on_message(msg)
|
90
75
|
entity =
|
91
|
-
case
|
92
|
-
when
|
76
|
+
case msg.subtype
|
77
|
+
when 'message_changed'
|
93
78
|
create_message_change_event_entity(msg)
|
94
|
-
when
|
79
|
+
when nil, 'bot_message', 'me_message'
|
95
80
|
create_message_entity(msg)
|
96
81
|
end
|
97
82
|
return unless entity
|
@@ -171,7 +156,7 @@ module Senrigan
|
|
171
156
|
)
|
172
157
|
when msg.user, msg.message&.user
|
173
158
|
user = fetch_user(msg.user || msg.message.user)
|
174
|
-
name =
|
159
|
+
name = user ? pick_name_from_user(user) : msg.user
|
175
160
|
Entities::User.new(
|
176
161
|
name: name.to_s,
|
177
162
|
is_bot: user&.is_bot
|
@@ -181,14 +166,20 @@ module Senrigan
|
|
181
166
|
end
|
182
167
|
end
|
183
168
|
|
169
|
+
def pick_name_from_user(user)
|
170
|
+
return '' unless user
|
171
|
+
return user.profile.display_name if user.profile&.display_name
|
172
|
+
user.name.to_s
|
173
|
+
end
|
174
|
+
|
184
175
|
def format_text(src_text)
|
185
176
|
text = src_text.to_s.dup
|
186
177
|
text.gsub!(/\\b/, '')
|
187
178
|
text.gsub!(/\<\@(U[^>\|]+)\>/) do
|
188
|
-
"@#{fetch_user(Regexp.last_match(1))
|
179
|
+
"@#{pick_name_from_user(fetch_user(Regexp.last_match(1)))}"
|
189
180
|
end
|
190
181
|
text.gsub!(/\<\@(U[^\|]+)\|([^>]+)\>/) do
|
191
|
-
"@#{fetch_user(Regexp.last_match(1))
|
182
|
+
"@#{pick_name_from_user(fetch_user(Regexp.last_match(1)))}"
|
192
183
|
end
|
193
184
|
text.gsub!(/\<\#(C[^>\|]+)\>/) do
|
194
185
|
"##{fetch_channel(Regexp.last_match(1)).name}"
|
data/lib/senrigan/version.rb
CHANGED
data/senrigan.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'faye-websocket'
|
24
24
|
spec.add_dependency 'gemoji'
|
25
25
|
spec.add_dependency 'slack-ruby-client'
|
26
|
-
spec.
|
27
|
-
spec.add_development_dependency '
|
26
|
+
spec.add_dependency 'async-websocket', '~> 0.8.0'
|
27
|
+
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency 'rake'
|
28
29
|
spec.add_development_dependency 'rubocop'
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: senrigan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ru_shalm
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -67,33 +67,47 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: async-websocket
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
type: :
|
75
|
+
version: 0.8.0
|
76
|
+
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - "
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - "
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rubocop
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +122,7 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
|
-
description:
|
125
|
+
description:
|
112
126
|
email:
|
113
127
|
- ru_shalm@hazimu.com
|
114
128
|
executables:
|
@@ -139,7 +153,7 @@ files:
|
|
139
153
|
homepage: https://github.com/rutan/senrigan
|
140
154
|
licenses: []
|
141
155
|
metadata: {}
|
142
|
-
post_install_message:
|
156
|
+
post_install_message:
|
143
157
|
rdoc_options: []
|
144
158
|
require_paths:
|
145
159
|
- lib
|
@@ -154,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
168
|
- !ruby/object:Gem::Version
|
155
169
|
version: '0'
|
156
170
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
171
|
+
rubygems_version: 3.2.3
|
172
|
+
signing_key:
|
159
173
|
specification_version: 4
|
160
174
|
summary: Slack timeline viewer
|
161
175
|
test_files: []
|