slack-smart-bot 1.7.0 → 1.9.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 +4 -4
- data/README.md +24 -12
- data/lib/slack-smart-bot.rb +53 -43
- data/lib/slack-smart-bot_general_rules.rb +7 -4
- data/lib/slack-smart-bot_rules.rb +8 -6
- data/lib/slack/smart-bot/comm.rb +6 -1
- data/lib/slack/smart-bot/comm/ask.rb +12 -5
- data/lib/slack/smart-bot/comm/dont_understand.rb +1 -1
- data/lib/slack/smart-bot/comm/event_hello.rb +30 -0
- data/lib/slack/smart-bot/comm/get_channel_members.rb +8 -0
- data/lib/slack/smart-bot/comm/get_channels.rb +20 -0
- data/lib/slack/smart-bot/comm/get_user_info.rb +16 -0
- data/lib/slack/smart-bot/comm/react.rb +21 -8
- data/lib/slack/smart-bot/comm/respond.rb +38 -12
- data/lib/slack/smart-bot/comm/send_file.rb +1 -1
- data/lib/slack/smart-bot/comm/send_msg_channel.rb +2 -2
- data/lib/slack/smart-bot/comm/send_msg_user.rb +4 -4
- data/lib/slack/smart-bot/comm/unreact.rb +29 -0
- data/lib/slack/smart-bot/commands.rb +3 -1
- data/lib/slack/smart-bot/commands/general/bot_help.rb +16 -3
- data/lib/slack/smart-bot/commands/general/bot_stats.rb +313 -0
- data/lib/slack/smart-bot/commands/general/bot_status.rb +1 -1
- data/lib/slack/smart-bot/commands/general/bye_bot.rb +1 -1
- data/lib/slack/smart-bot/commands/general/hi_bot.rb +1 -1
- data/lib/slack/smart-bot/commands/general/use_rules.rb +6 -9
- data/lib/slack/smart-bot/commands/general/whats_new.rb +19 -0
- data/lib/slack/smart-bot/commands/on_bot/add_shortcut.rb +65 -33
- data/lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb +42 -9
- data/lib/slack/smart-bot/commands/on_bot/admin/extend_rules.rb +3 -7
- data/lib/slack/smart-bot/commands/on_bot/admin/pause_bot.rb +1 -0
- data/lib/slack/smart-bot/commands/on_bot/admin/see_routines.rb +9 -2
- data/lib/slack/smart-bot/commands/on_bot/admin/start_bot.rb +1 -0
- data/lib/slack/smart-bot/commands/on_bot/delete_repl.rb +1 -1
- data/lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb +52 -21
- data/lib/slack/smart-bot/commands/on_bot/get_repl.rb +5 -5
- data/lib/slack/smart-bot/commands/on_bot/repl.rb +50 -18
- data/lib/slack/smart-bot/commands/on_bot/ruby_code.rb +34 -9
- data/lib/slack/smart-bot/commands/on_bot/run_repl.rb +2 -3
- data/lib/slack/smart-bot/commands/on_bot/see_repls.rb +1 -1
- data/lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb +27 -9
- data/lib/slack/smart-bot/commands/on_extended/bot_rules.rb +14 -1
- data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +3 -3
- data/lib/slack/smart-bot/commands/on_master/admin_master/notify_message.rb +1 -1
- data/lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb +41 -0
- data/lib/slack/smart-bot/commands/on_master/create_bot.rb +4 -8
- data/lib/slack/smart-bot/listen.rb +6 -5
- data/lib/slack/smart-bot/process.rb +230 -186
- data/lib/slack/smart-bot/process_first.rb +104 -87
- data/lib/slack/smart-bot/treat_message.rb +128 -52
- data/lib/slack/smart-bot/utils.rb +2 -0
- data/lib/slack/smart-bot/utils/answer.rb +18 -0
- data/lib/slack/smart-bot/utils/answer_delete.rb +15 -0
- data/lib/slack/smart-bot/utils/build_help.rb +57 -5
- data/lib/slack/smart-bot/utils/create_routine_thread.rb +48 -8
- data/lib/slack/smart-bot/utils/get_channels_name_and_id.rb +1 -7
- data/lib/slack/smart-bot/utils/get_help.rb +79 -17
- data/lib/slack/smart-bot/utils/save_stats.rb +21 -8
- data/lib/slack/smart-bot/utils/update_shortcuts_file.rb +6 -0
- data/whats_new.txt +24 -0
- metadata +23 -13
- data/lib/slack/smart-bot/commands/on_bot/admin_master/bot_stats.rb +0 -135
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-smart-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-ruby-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.14'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
19
|
+
version: 0.17.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.17'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.14'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
29
|
+
version: 0.17.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.17'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: nice_http
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
version: '1'
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: 1.
|
84
|
+
version: 1.3.0
|
85
85
|
type: :runtime
|
86
86
|
prerelease: false
|
87
87
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +91,7 @@ dependencies:
|
|
91
91
|
version: '1'
|
92
92
|
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 1.
|
94
|
+
version: 1.3.0
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: rspec
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,19 +130,26 @@ files:
|
|
130
130
|
- lib/slack/smart-bot/comm.rb
|
131
131
|
- lib/slack/smart-bot/comm/ask.rb
|
132
132
|
- lib/slack/smart-bot/comm/dont_understand.rb
|
133
|
+
- lib/slack/smart-bot/comm/event_hello.rb
|
134
|
+
- lib/slack/smart-bot/comm/get_channel_members.rb
|
135
|
+
- lib/slack/smart-bot/comm/get_channels.rb
|
136
|
+
- lib/slack/smart-bot/comm/get_user_info.rb
|
133
137
|
- lib/slack/smart-bot/comm/react.rb
|
134
138
|
- lib/slack/smart-bot/comm/respond.rb
|
135
139
|
- lib/slack/smart-bot/comm/respond_direct.rb
|
136
140
|
- lib/slack/smart-bot/comm/send_file.rb
|
137
141
|
- lib/slack/smart-bot/comm/send_msg_channel.rb
|
138
142
|
- lib/slack/smart-bot/comm/send_msg_user.rb
|
143
|
+
- lib/slack/smart-bot/comm/unreact.rb
|
139
144
|
- lib/slack/smart-bot/commands.rb
|
140
145
|
- lib/slack/smart-bot/commands/general/bot_help.rb
|
146
|
+
- lib/slack/smart-bot/commands/general/bot_stats.rb
|
141
147
|
- lib/slack/smart-bot/commands/general/bot_status.rb
|
142
148
|
- lib/slack/smart-bot/commands/general/bye_bot.rb
|
143
149
|
- lib/slack/smart-bot/commands/general/hi_bot.rb
|
144
150
|
- lib/slack/smart-bot/commands/general/stop_using_rules.rb
|
145
151
|
- lib/slack/smart-bot/commands/general/use_rules.rb
|
152
|
+
- lib/slack/smart-bot/commands/general/whats_new.rb
|
146
153
|
- lib/slack/smart-bot/commands/on_bot/add_shortcut.rb
|
147
154
|
- lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb
|
148
155
|
- lib/slack/smart-bot/commands/on_bot/admin/extend_rules.rb
|
@@ -154,7 +161,6 @@ files:
|
|
154
161
|
- lib/slack/smart-bot/commands/on_bot/admin/start_bot.rb
|
155
162
|
- lib/slack/smart-bot/commands/on_bot/admin/start_routine.rb
|
156
163
|
- lib/slack/smart-bot/commands/on_bot/admin/stop_using_rules_on.rb
|
157
|
-
- lib/slack/smart-bot/commands/on_bot/admin_master/bot_stats.rb
|
158
164
|
- lib/slack/smart-bot/commands/on_bot/admin_master/get_bot_logs.rb
|
159
165
|
- lib/slack/smart-bot/commands/on_bot/delete_repl.rb
|
160
166
|
- lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb
|
@@ -168,12 +174,15 @@ files:
|
|
168
174
|
- lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb
|
169
175
|
- lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb
|
170
176
|
- lib/slack/smart-bot/commands/on_master/admin_master/notify_message.rb
|
177
|
+
- lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb
|
171
178
|
- lib/slack/smart-bot/commands/on_master/create_bot.rb
|
172
179
|
- lib/slack/smart-bot/listen.rb
|
173
180
|
- lib/slack/smart-bot/process.rb
|
174
181
|
- lib/slack/smart-bot/process_first.rb
|
175
182
|
- lib/slack/smart-bot/treat_message.rb
|
176
183
|
- lib/slack/smart-bot/utils.rb
|
184
|
+
- lib/slack/smart-bot/utils/answer.rb
|
185
|
+
- lib/slack/smart-bot/utils/answer_delete.rb
|
177
186
|
- lib/slack/smart-bot/utils/build_help.rb
|
178
187
|
- lib/slack/smart-bot/utils/create_routine_thread.rb
|
179
188
|
- lib/slack/smart-bot/utils/get_bots_created.rb
|
@@ -189,6 +198,7 @@ files:
|
|
189
198
|
- lib/slack/smart-bot/utils/update_routines.rb
|
190
199
|
- lib/slack/smart-bot/utils/update_rules_imported.rb
|
191
200
|
- lib/slack/smart-bot/utils/update_shortcuts_file.rb
|
201
|
+
- whats_new.txt
|
192
202
|
homepage: https://github.com/MarioRuiz/slack-smart-bot
|
193
203
|
licenses:
|
194
204
|
- MIT
|
@@ -1,135 +0,0 @@
|
|
1
|
-
class SlackSmartBot
|
2
|
-
# helpadmin: ----------------------------------------------
|
3
|
-
# helpadmin: `bot stats`
|
4
|
-
# helpadmin: `bot stats USER_NAME`
|
5
|
-
# helpadmin: `bot stats exclude masters`
|
6
|
-
# helpadmin: `bot stats from YYYY/MM/DD`
|
7
|
-
# helpadmin: `bot stats from YYYY/MM/DD to YYYY/MM/DD`
|
8
|
-
# helpadmin: `bot stats CHANNEL`
|
9
|
-
# helpadmin: `bot stats CHANNEL from YYYY/MM/DD`
|
10
|
-
# helpadmin: `bot stats CHANNEL from YYYY/MM/DD to YYYY/MM/DD`
|
11
|
-
# helpadmin: `bot stats USER_NAME from YYYY/MM/DD to YYYY/MM/DD`
|
12
|
-
# helpadmin: `bot stats CHANNEL USER_NAME from YYYY/MM/DD to YYYY/MM/DD`
|
13
|
-
# helpadmin: `bot stats CHANNEL exclude masters from YYYY/MM/DD to YYYY/MM/DD`
|
14
|
-
# helpadmin: `bot stats today`
|
15
|
-
# helpadmin: `bot stats exclude COMMAND_ID`
|
16
|
-
# helpadmin: `bot stats monthly`
|
17
|
-
# helpadmin: To see the bot stats
|
18
|
-
# helpadmin: You can use this command only if you are a Master admin user and if you are in a private conversation with the bot
|
19
|
-
# helpadmin: You need to set stats to true to generate the stats when running the bot instance.
|
20
|
-
# helpadmin: Examples:
|
21
|
-
# helpadmin: _bot stats #sales_
|
22
|
-
# helpadmin: _bot stats @peter.wind_
|
23
|
-
# helpadmin: _bot stats #sales from 2019/12/15 to 2019/12/31_
|
24
|
-
# helpadmin: _bot stats #sales today_
|
25
|
-
# helpadmin: _bot stats #sales monthly_
|
26
|
-
# helpadmin:
|
27
|
-
def bot_stats(dest, from_user, typem, channel_id, from, to, user, exclude_masters, exclude_command, monthly)
|
28
|
-
require 'csv'
|
29
|
-
if config.stats
|
30
|
-
message = []
|
31
|
-
else
|
32
|
-
message = ["You need to set stats to true to generate the stats when running the bot instance."]
|
33
|
-
end
|
34
|
-
save_stats(__method__)
|
35
|
-
if config.masters.include?(from_user) and typem==:on_dm #master admin user
|
36
|
-
if !File.exist?("#{config.stats_path}.#{Time.now.strftime("%Y-%m")}.log")
|
37
|
-
message<<'No stats'
|
38
|
-
else
|
39
|
-
from = "#{Time.now.strftime("%Y-%m")}-01" if from == ''
|
40
|
-
to = "#{Time.now.strftime("%Y-%m-%d")}" if to == ''
|
41
|
-
from_short = from
|
42
|
-
to_short = to
|
43
|
-
from_file = from[0..3] + '-' + from[5..6]
|
44
|
-
to_file = to[0..3] + '-' + to[5..6]
|
45
|
-
from+= " 00:00:00 +0000"
|
46
|
-
to+= " 23:59:59 +0000"
|
47
|
-
rows = []
|
48
|
-
rows_month = {}
|
49
|
-
|
50
|
-
Dir["#{config.stats_path}.*.log"].sort.each do |file|
|
51
|
-
if file >= "#{config.stats_path}.#{from_file}.log" or file <= "#{config.stats_path}.#{to_file}.log"
|
52
|
-
CSV.foreach(file, headers: true, header_converters: :symbol, converters: :numeric) do |row|
|
53
|
-
row[:date] = row[:date].to_s
|
54
|
-
if !exclude_masters or (exclude_masters and !config.masters.include?(row[:user_name]))
|
55
|
-
if user=='' or (user!='' and row[:user_id] == user)
|
56
|
-
if exclude_command == '' or (exclude_command!='' and row[:command]!=exclude_command)
|
57
|
-
if row[:bot_channel_id] == channel_id or channel_id == ''
|
58
|
-
if row[:date] >= from and row[:date] <= to
|
59
|
-
rows << row.to_h
|
60
|
-
if monthly
|
61
|
-
rows_month[row[:date][0..6]] = 0 unless rows_month.key?(row[:date][0..6])
|
62
|
-
rows_month[row[:date][0..6]] += 1
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
total = rows.size
|
74
|
-
if exclude_masters
|
75
|
-
message << 'Excluding master admins'
|
76
|
-
end
|
77
|
-
if exclude_command != ''
|
78
|
-
message << "Excluding command #{exclude_command}"
|
79
|
-
end
|
80
|
-
if user!=''
|
81
|
-
message << "Showing only user <@#{user}>"
|
82
|
-
end
|
83
|
-
if channel_id == ''
|
84
|
-
message << "*Total calls*: #{total} from #{from_short} to #{to_short}"
|
85
|
-
else
|
86
|
-
message << "*Total calls <##{channel_id}>*: #{total} from #{from_short} to #{to_short}"
|
87
|
-
end
|
88
|
-
if total > 0
|
89
|
-
if monthly
|
90
|
-
message << '*Totals by month*'
|
91
|
-
rows_month.each do |k,v|
|
92
|
-
message << "\t#{k}: #{v} (#{(v.to_f*100/total).round(2)}%)"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
if channel_id == ''
|
97
|
-
message << "*Channels*"
|
98
|
-
channels = rows.bot_channel.uniq.sort
|
99
|
-
channels.each do |channel|
|
100
|
-
count = rows.count {|h| h.bot_channel==channel}
|
101
|
-
message << "\t#{channel}: #{count} (#{(count.to_f*100/total).round(2)}%)"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
if user==''
|
105
|
-
message << "*Users*"
|
106
|
-
users = rows.user_name.uniq.sort
|
107
|
-
users.each do |user|
|
108
|
-
count = rows.count {|h| h.user_name==user}
|
109
|
-
message << "\t#{user}: #{count} (#{(count.to_f*100/total).round(2)}%)"
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
message << "*Commands*"
|
114
|
-
commands = rows.command.uniq.sort
|
115
|
-
commands.each do |command|
|
116
|
-
count = rows.count {|h| h.command==command}
|
117
|
-
message << "\t#{command}: #{count} (#{(count.to_f*100/total).round(2)}%)"
|
118
|
-
end
|
119
|
-
|
120
|
-
message << "*Message type*"
|
121
|
-
types = rows.type_message.uniq.sort
|
122
|
-
types.each do |type|
|
123
|
-
count = rows.count {|h| h.type_message==type}
|
124
|
-
message << "\t#{type}: #{count} (#{(count.to_f*100/total).round(2)}%)"
|
125
|
-
end
|
126
|
-
message << "*Last activity*: #{rows[-1].date} #{rows[-1].bot_channel} #{rows[-1].type_message} #{rows[-1].user_name} #{rows[-1].command}"
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
else
|
131
|
-
message<<"Only Master admin users on a private conversation with the bot can see the bot stats."
|
132
|
-
end
|
133
|
-
respond "#{message.join("\n")}", dest
|
134
|
-
end
|
135
|
-
end
|