slack-smart-bot 1.10.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +134 -23
- data/lib/slack/smart-bot/comm/delete.rb +13 -0
- data/lib/slack/smart-bot/comm/dont_understand.rb +2 -2
- data/lib/slack/smart-bot/comm/get_channel_members.rb +7 -3
- data/lib/slack/smart-bot/comm/get_presence.rb +20 -0
- data/lib/slack/smart-bot/comm/get_users.rb +1 -1
- data/lib/slack/smart-bot/comm/respond.rb +24 -13
- data/lib/slack/smart-bot/comm/send_msg_user.rb +12 -11
- data/lib/slack/smart-bot/comm/set_status.rb +21 -0
- data/lib/slack/smart-bot/comm.rb +3 -0
- data/lib/slack/smart-bot/commands/general/add_admin.rb +51 -0
- data/lib/slack/smart-bot/commands/general/add_announcement.rb +1 -1
- data/lib/slack/smart-bot/commands/general/add_memo_team.rb +117 -0
- data/lib/slack/smart-bot/commands/general/add_team.rb +80 -0
- data/lib/slack/smart-bot/commands/general/add_vacation.rb +51 -0
- data/lib/slack/smart-bot/commands/general/allow_access.rb +67 -0
- data/lib/slack/smart-bot/commands/general/bot_help.rb +20 -11
- data/lib/slack/smart-bot/commands/general/delete_announcement.rb +1 -1
- data/lib/slack/smart-bot/commands/general/delete_memo_team.rb +69 -0
- data/lib/slack/smart-bot/commands/general/delete_share.rb +1 -1
- data/lib/slack/smart-bot/commands/general/delete_team.rb +54 -0
- data/lib/slack/smart-bot/commands/general/deny_access.rb +36 -0
- data/lib/slack/smart-bot/commands/general/ping_team.rb +100 -0
- data/lib/slack/smart-bot/commands/general/poster.rb +116 -0
- data/lib/slack/smart-bot/commands/general/remove_admin.rb +58 -0
- data/lib/slack/smart-bot/commands/general/remove_vacation.rb +27 -0
- data/lib/slack/smart-bot/commands/general/see_access.rb +24 -0
- data/lib/slack/smart-bot/commands/general/see_admins.rb +33 -0
- data/lib/slack/smart-bot/commands/general/see_announcements.rb +7 -5
- data/lib/slack/smart-bot/commands/general/see_command_ids.rb +29 -0
- data/lib/slack/smart-bot/commands/general/see_favorite_commands.rb +3 -4
- data/lib/slack/smart-bot/commands/general/see_statuses.rb +34 -21
- data/lib/slack/smart-bot/commands/general/see_teams.rb +402 -0
- data/lib/slack/smart-bot/commands/general/see_vacations.rb +58 -0
- data/lib/slack/smart-bot/commands/general/see_vacations_team.rb +136 -0
- data/lib/slack/smart-bot/commands/general/set_memo_status.rb +58 -0
- data/lib/slack/smart-bot/commands/general/share_messages.rb +1 -1
- data/lib/slack/smart-bot/commands/general/update_team.rb +130 -0
- data/lib/slack/smart-bot/commands/general_bot_commands.rb +442 -13
- data/lib/slack/smart-bot/commands/on_bot/add_shortcut.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/extend_rules.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/pause_bot.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/pause_routine.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/remove_routine.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/run_routine.rb +3 -2
- data/lib/slack/smart-bot/commands/on_bot/admin/see_result_routine.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/see_routines.rb +10 -9
- data/lib/slack/smart-bot/commands/on_bot/admin/start_bot.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/start_routine.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin/stop_using_rules_on.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/admin_master/delete_message.rb +25 -0
- data/lib/slack/smart-bot/commands/on_bot/admin_master/get_bot_logs.rb +1 -0
- data/lib/slack/smart-bot/commands/on_bot/admin_master/react_to.rb +3 -1
- data/lib/slack/smart-bot/commands/on_bot/admin_master/send_message.rb +15 -2
- data/lib/slack/smart-bot/commands/on_bot/delete_repl.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb +5 -4
- data/lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb +416 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/bot_status.rb +1 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/leaderboard.rb +1 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/stop_using_rules.rb +1 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/suggest_command.rb +6 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/use_rules.rb +1 -0
- data/lib/slack/smart-bot/commands/{general → on_bot/general}/whats_new.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/get_repl.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/kill_repl.rb +32 -0
- data/lib/slack/smart-bot/commands/on_bot/repl.rb +73 -15
- data/lib/slack/smart-bot/commands/on_bot/ruby_code.rb +1 -0
- data/lib/slack/smart-bot/commands/on_bot/run_repl.rb +117 -28
- data/lib/slack/smart-bot/commands/on_bot/see_repls.rb +2 -1
- data/lib/slack/smart-bot/commands/on_bot/see_shortcuts.rb +3 -2
- data/lib/slack/smart-bot/commands/on_master/admin/kill_bot_on_channel.rb +5 -4
- data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +3 -2
- data/lib/slack/smart-bot/commands/on_master/admin_master/notify_message.rb +2 -1
- data/lib/slack/smart-bot/commands/on_master/admin_master/publish_announcements.rb +6 -3
- data/lib/slack/smart-bot/commands/on_master/admin_master/set_general_message.rb +2 -1
- data/lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb +2 -1
- data/lib/slack/smart-bot/commands/on_master/create_bot.rb +1 -0
- data/lib/slack/smart-bot/commands/on_master/where_smartbot.rb +41 -0
- data/lib/slack/smart-bot/commands.rb +30 -7
- data/lib/slack/smart-bot/listen.rb +30 -30
- data/lib/slack/smart-bot/process.rb +53 -23
- data/lib/slack/smart-bot/process_first.rb +2 -2
- data/lib/slack/smart-bot/treat_message.rb +23 -17
- data/lib/slack/smart-bot/utils/build_help.rb +1 -1
- data/lib/slack/smart-bot/utils/check_vacations.rb +43 -0
- data/lib/slack/smart-bot/utils/create_routine_thread.rb +1 -1
- data/lib/slack/smart-bot/utils/get_access_channels.rb +13 -0
- data/lib/slack/smart-bot/utils/get_admins_channels.rb +33 -0
- data/lib/slack/smart-bot/utils/get_bots_created.rb +27 -10
- data/lib/slack/smart-bot/utils/get_channels_name_and_id.rb +7 -2
- data/lib/slack/smart-bot/utils/get_command_ids.rb +84 -0
- data/lib/slack/smart-bot/utils/get_help.rb +36 -19
- data/lib/slack/smart-bot/utils/get_repls.rb +22 -2
- data/lib/slack/smart-bot/utils/get_routines.rb +22 -2
- data/lib/slack/smart-bot/utils/get_teams.rb +22 -0
- data/lib/slack/smart-bot/utils/get_vacations.rb +22 -0
- data/lib/slack/smart-bot/utils/has_access.rb +25 -9
- data/lib/slack/smart-bot/utils/is_admin.rb +27 -0
- data/lib/slack/smart-bot/utils/save_stats.rb +52 -42
- data/lib/slack/smart-bot/utils/save_status.rb +22 -7
- data/lib/slack/smart-bot/utils/update_access_channels.rb +8 -0
- data/lib/slack/smart-bot/utils/update_admins_channels.rb +25 -0
- data/lib/slack/smart-bot/utils/update_bots_file.rb +28 -7
- data/lib/slack/smart-bot/utils/update_repls.rb +7 -4
- data/lib/slack/smart-bot/utils/update_routines.rb +9 -3
- data/lib/slack/smart-bot/utils/update_shortcuts_file.rb +13 -6
- data/lib/slack/smart-bot/utils/update_teams.rb +16 -0
- data/lib/slack/smart-bot/utils/update_vacations.rb +16 -0
- data/lib/slack/smart-bot/utils.rb +11 -0
- data/lib/slack-smart-bot.rb +50 -12
- data/lib/slack-smart-bot_general_commands.rb +16 -1
- data/whats_new.txt +12 -30
- metadata +78 -21
- data/lib/slack/smart-bot/commands/general/bot_stats.rb +0 -314
@@ -1,8 +1,11 @@
|
|
1
1
|
class SlackSmartBot
|
2
2
|
|
3
3
|
def update_routines(channel = @channel_id)
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
routines_file = "#{config.path}/routines/routines_#{channel}.yaml"
|
7
|
+
|
4
8
|
routines = {}
|
5
|
-
file = File.open("#{config.path}/routines/routines_#{channel}.rb", "w")
|
6
9
|
@routines.each do |k,v|
|
7
10
|
routines[k]={}
|
8
11
|
v.each do |kk,vv|
|
@@ -10,7 +13,10 @@ class SlackSmartBot
|
|
10
13
|
routines[k][kk][:thread]=""
|
11
14
|
end
|
12
15
|
end
|
13
|
-
|
14
|
-
|
16
|
+
File.open(routines_file, 'w') {|file|
|
17
|
+
file.flock(File::LOCK_EX)
|
18
|
+
file.write(routines.to_yaml)
|
19
|
+
file.flock(File::LOCK_UN)
|
20
|
+
}
|
15
21
|
end
|
16
22
|
end
|
@@ -1,13 +1,20 @@
|
|
1
1
|
class SlackSmartBot
|
2
2
|
def update_shortcuts_file
|
3
|
-
|
4
|
-
|
5
|
-
file
|
3
|
+
require 'yaml'
|
4
|
+
sc_file = "#{config.path}/shortcuts/#{config.shortcuts_file}"
|
5
|
+
File.open(sc_file, 'w') {|file|
|
6
|
+
file.flock(File::LOCK_EX)
|
7
|
+
file.write(@shortcuts.to_yaml)
|
8
|
+
file.flock(File::LOCK_UN)
|
9
|
+
}
|
6
10
|
|
7
11
|
if config.on_master_bot
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
sc_file = "#{config.path}/shortcuts/shortcuts_global.yaml"
|
13
|
+
File.open(sc_file, 'w') {|file|
|
14
|
+
file.flock(File::LOCK_EX)
|
15
|
+
file.write(@shortcuts_global.to_yaml)
|
16
|
+
file.flock(File::LOCK_UN)
|
17
|
+
}
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class SlackSmartBot
|
2
|
+
def update_teams(team=nil)
|
3
|
+
require 'yaml'
|
4
|
+
unless team.nil?
|
5
|
+
get_teams()
|
6
|
+
@teams.merge!(team)
|
7
|
+
end
|
8
|
+
teams_file = config.file_path.gsub(".rb", "_teams.yaml")
|
9
|
+
File.open(teams_file, 'w') {|file|
|
10
|
+
file.flock(File::LOCK_EX)
|
11
|
+
file.write(@teams.to_yaml)
|
12
|
+
file.flock(File::LOCK_UN)
|
13
|
+
}
|
14
|
+
@datetime_teams_file = File.mtime(teams_file)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class SlackSmartBot
|
2
|
+
def update_vacations(vacation=nil)
|
3
|
+
require 'yaml'
|
4
|
+
unless vacation.nil?
|
5
|
+
get_vacations()
|
6
|
+
@vacations.merge!(vacation)
|
7
|
+
end
|
8
|
+
vacations_file = config.file_path.gsub(".rb", "_vacations.yaml")
|
9
|
+
File.open(vacations_file, 'w') {|file|
|
10
|
+
file.flock(File::LOCK_EX)
|
11
|
+
file.write(@vacations.to_yaml)
|
12
|
+
file.flock(File::LOCK_UN)
|
13
|
+
}
|
14
|
+
@datetime_vacations_file = File.mtime(vacations_file)
|
15
|
+
end
|
16
|
+
end
|
@@ -18,4 +18,15 @@ require_relative 'utils/answer'
|
|
18
18
|
require_relative 'utils/answer_delete'
|
19
19
|
require_relative 'utils/has_access'
|
20
20
|
require_relative 'utils/save_status'
|
21
|
+
require_relative 'utils/get_admins_channels'
|
22
|
+
require_relative 'utils/update_admins_channels'
|
23
|
+
require_relative 'utils/is_admin'
|
24
|
+
require_relative 'utils/get_access_channels'
|
25
|
+
require_relative 'utils/update_access_channels'
|
26
|
+
require_relative 'utils/get_command_ids'
|
27
|
+
require_relative 'utils/get_teams'
|
28
|
+
require_relative 'utils/get_vacations'
|
29
|
+
require_relative 'utils/update_teams'
|
30
|
+
require_relative 'utils/update_vacations'
|
31
|
+
require_relative 'utils/check_vacations'
|
21
32
|
|
data/lib/slack-smart-bot.rb
CHANGED
@@ -9,6 +9,7 @@ require "open3"
|
|
9
9
|
require "nice_http"
|
10
10
|
require "nice_hash"
|
11
11
|
require 'cgi'
|
12
|
+
require 'yaml'
|
12
13
|
|
13
14
|
require_relative "slack/smart-bot/comm"
|
14
15
|
require_relative "slack/smart-bot/listen"
|
@@ -20,7 +21,7 @@ require_relative "slack/smart-bot/utils"
|
|
20
21
|
|
21
22
|
ADMIN_USERS = MASTER_USERS if defined?(MASTER_USERS) # for bg compatibility
|
22
23
|
class SlackSmartBot
|
23
|
-
attr_accessor :config, :client
|
24
|
+
attr_accessor :config, :client, :client_user
|
24
25
|
attr_reader :master_bot_id, :channel_id
|
25
26
|
geml = Gem.loaded_specs.values.select { |x| x.name == "slack-smart-bot" }[0]
|
26
27
|
if geml.nil?
|
@@ -46,7 +47,11 @@ class SlackSmartBot
|
|
46
47
|
config[:general_message] = "" unless config.key?(:general_message)
|
47
48
|
config[:logrtm] = false unless config.key?(:logrtm)
|
48
49
|
config[:status_channel] = 'smartbot-status' unless config.key?(:status_channel)
|
49
|
-
|
50
|
+
config[:jira] = { host: '', user: '', password: '' } unless config.key?(:jira) and config[:jira].key?(:host) and config[:jira].key?(:user) and config[:jira].key?(:password)
|
51
|
+
config[:jira][:host] = "https://#{config[:jira][:host]}" unless config[:jira][:host] == '' or config[:jira][:host].match?(/^http/)
|
52
|
+
config[:github] = {token: '' } unless config.key?(:github) and config[:github].key?(:token)
|
53
|
+
config[:github][:host] ||= "https://api.github.com"
|
54
|
+
config[:github][:host] = "https://#{config[:github][:host]}" unless config[:github][:host] == '' or config[:github][:host].match?(/^http/)
|
50
55
|
if config.path.to_s!='' and config.file.to_s==''
|
51
56
|
config.file = File.basename($0)
|
52
57
|
end
|
@@ -66,6 +71,7 @@ class SlackSmartBot
|
|
66
71
|
Dir.mkdir("#{config.path}/routines") unless Dir.exist?("#{config.path}/routines")
|
67
72
|
Dir.mkdir("#{config.path}/announcements") unless Dir.exist?("#{config.path}/announcements")
|
68
73
|
Dir.mkdir("#{config.path}/shares") unless Dir.exist?("#{config.path}/shares")
|
74
|
+
Dir.mkdir("#{config.path}/rules") unless Dir.exist?("#{config.path}/rules")
|
69
75
|
File.delete("#{config.path}/config_tmp.status") if File.exist?("#{config.path}/config_tmp.status")
|
70
76
|
|
71
77
|
config.masters = MASTER_USERS if config.masters.to_s=='' and defined?(MASTER_USERS)
|
@@ -77,7 +83,7 @@ class SlackSmartBot
|
|
77
83
|
default_rules = (__FILE__).gsub(/\.rb$/, "_rules.rb")
|
78
84
|
FileUtils.copy_file(default_rules, config.path + '/' + config.rules_file)
|
79
85
|
end
|
80
|
-
config.admins = config.masters unless config.admins.to_s!=''
|
86
|
+
config.admins = config.masters.dup unless config.admins.to_s!=''
|
81
87
|
config.channel = config.master_channel unless config.channel.to_s!=''
|
82
88
|
config.status_init = :on unless config.status_init.to_s!=''
|
83
89
|
else
|
@@ -89,7 +95,7 @@ class SlackSmartBot
|
|
89
95
|
config.rules_file[0]='' if config.rules_file[0]=='.'
|
90
96
|
config.rules_file='/'+config.rules_file if config.rules_file[0]!='/'
|
91
97
|
|
92
|
-
config.shortcuts_file = "slack-smart-bot_shortcuts_#{config.channel}.
|
98
|
+
config.shortcuts_file = "slack-smart-bot_shortcuts_#{config.channel}.yaml".gsub(" ", "_")
|
93
99
|
if config.channel == config.master_channel
|
94
100
|
config.on_master_bot = true
|
95
101
|
config.start_bots = true unless config.key?(:start_bots)
|
@@ -116,6 +122,7 @@ class SlackSmartBot
|
|
116
122
|
|
117
123
|
config_log = config.dup
|
118
124
|
config_log.delete(:token)
|
125
|
+
config_log.delete(:user_token)
|
119
126
|
@logger.info "Initializing bot: #{config_log.inspect}"
|
120
127
|
|
121
128
|
File.new("#{config.path}/buffer.log", "w") if config[:testing] and config.on_master_bot
|
@@ -129,6 +136,18 @@ class SlackSmartBot
|
|
129
136
|
conf.token = config[:token]
|
130
137
|
end
|
131
138
|
end
|
139
|
+
unless (config.simulate and config.key?(:client)) or config.user_token.nil? or config.user_token.empty?
|
140
|
+
begin
|
141
|
+
self.client_user = Slack::Web::Client.new(token: config.user_token)
|
142
|
+
self.client_user.auth_test
|
143
|
+
rescue Exception => e
|
144
|
+
@logger.fatal "*" * 50
|
145
|
+
@logger.fatal "Rescued on creation client_user: #{e.inspect}"
|
146
|
+
self.client_user = nil
|
147
|
+
end
|
148
|
+
else
|
149
|
+
self.client_user = nil
|
150
|
+
end
|
132
151
|
restarts = 0
|
133
152
|
created = false
|
134
153
|
while restarts < 200 and !created
|
@@ -140,7 +159,7 @@ class SlackSmartBot
|
|
140
159
|
else
|
141
160
|
if config.logrtm
|
142
161
|
logrtmname = "#{config.path}/logs/rtm_#{config.channel}.log"
|
143
|
-
File.delete(logrtmname) if File.
|
162
|
+
File.delete(logrtmname) if File.exist?(logrtmname)
|
144
163
|
@logrtm = Logger.new(logrtmname)
|
145
164
|
self.client = Slack::RealTime::Client.new(start_method: :rtm_connect, logger: @logrtm)
|
146
165
|
else
|
@@ -174,29 +193,42 @@ class SlackSmartBot
|
|
174
193
|
@rules_imported = Hash.new()
|
175
194
|
@routines = Hash.new()
|
176
195
|
@repls = Hash.new()
|
196
|
+
@run_repls = Hash.new()
|
177
197
|
@users = Hash.new()
|
178
198
|
@announcements = Hash.new()
|
179
199
|
@shares = Hash.new()
|
180
200
|
@last_status_change = Time.now
|
201
|
+
@vacations_check = (Date.today - 1)
|
202
|
+
@announcements_activity_after = Hash.new()
|
181
203
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
204
|
+
if File.exist?("#{config.path}/shortcuts/#{config.shortcuts_file}".gsub('.yaml','.rb')) #backwards compatible
|
205
|
+
file_conf = IO.readlines("#{config.path}/shortcuts/#{config.shortcuts_file}".gsub('.yaml','.rb')).join
|
206
|
+
if file_conf.to_s() == ""
|
207
|
+
@shortcuts = {}
|
208
|
+
else
|
209
|
+
@shortcuts = eval(file_conf)
|
187
210
|
end
|
211
|
+
File.open("#{config.path}/shortcuts/#{config.shortcuts_file}", 'w') {|file| file.write(@shortcuts.to_yaml) }
|
212
|
+
File.delete("#{config.path}/shortcuts/#{config.shortcuts_file}".gsub('.yaml','.rb'))
|
213
|
+
elsif File.exist?("#{config.path}/shortcuts/#{config.shortcuts_file}")
|
214
|
+
@shortcuts = YAML.load(File.read("#{config.path}/shortcuts/#{config.shortcuts_file}"))
|
188
215
|
end
|
189
|
-
if File.exist?("#{config.path}/shortcuts/shortcuts_global.rb")
|
216
|
+
if File.exist?("#{config.path}/shortcuts/shortcuts_global.rb") #backwards compatible
|
190
217
|
file_sc = IO.readlines("#{config.path}/shortcuts/shortcuts_global.rb").join
|
218
|
+
@shortcuts_global = {}
|
191
219
|
unless file_sc.to_s() == ""
|
192
220
|
@shortcuts_global = eval(file_sc)
|
193
221
|
end
|
222
|
+
File.open("#{config.path}/shortcuts/shortcuts_global.yaml", 'w') {|file| file.write(@shortcuts_global.to_yaml) }
|
223
|
+
File.delete("#{config.path}/shortcuts/shortcuts_global.rb")
|
224
|
+
elsif File.exist?("#{config.path}/shortcuts/shortcuts_global.yaml")
|
225
|
+
@shortcuts_global = YAML.load(File.read("#{config.path}/shortcuts/shortcuts_global.yaml"))
|
194
226
|
end
|
195
227
|
|
196
228
|
get_routines()
|
197
229
|
get_repls()
|
198
230
|
|
199
|
-
if config.on_master_bot and File.exist?(config.file_path.gsub(".rb", "_bots.rb"))
|
231
|
+
if config.on_master_bot and (File.exist?(config.file_path.gsub(".rb", "_bots.rb")) or File.exist?(config.file_path.gsub('.rb', '_bots.yaml')))
|
200
232
|
get_bots_created()
|
201
233
|
if @bots_created.kind_of?(Hash) and config.start_bots
|
202
234
|
@bots_created.each { |key, value|
|
@@ -270,13 +302,19 @@ class SlackSmartBot
|
|
270
302
|
@datetime_general_commands = 0
|
271
303
|
@channels_id = Hash.new()
|
272
304
|
@channels_name = Hash.new()
|
305
|
+
@channels_creator = Hash.new()
|
306
|
+
@channels_list = Hash.new()
|
273
307
|
get_channels_name_and_id()
|
274
308
|
@channel_id = @channels_id[config.channel].dup
|
275
309
|
@master_bot_id = @channels_id[config.master_channel].dup
|
276
310
|
|
311
|
+
Dir.mkdir("#{config.path}/rules/#{@channel_id}") unless Dir.exist?("#{config.path}/rules/#{@channel_id}/")
|
312
|
+
|
277
313
|
get_routines()
|
278
314
|
get_repls()
|
279
315
|
get_shares()
|
316
|
+
get_admins_channels()
|
317
|
+
get_access_channels()
|
280
318
|
|
281
319
|
if @routines.key?(@channel_id)
|
282
320
|
@routines[@channel_id].each do |k, v|
|
@@ -21,7 +21,7 @@ def general_commands(user, command, dest, files = [])
|
|
21
21
|
|
22
22
|
|
23
23
|
# this is a hidden command that it is not listed when calling bot help
|
24
|
-
when /\
|
24
|
+
when /\s*(that's\s+)?(thanks|thank\s+you|I\s+love\s+you|nice|cool)\s+(#{@salutations.join("|")})\s*!*\s*$/i
|
25
25
|
save_stats :thanks
|
26
26
|
reactions = [:heart, :heart_eyes, :blush, :relaxed, :simple_smile, :smiley, :two_hearts, :heartbeat, :green_heart ]
|
27
27
|
reactions.sample(rand(3)+1).each {|rt| react rt }
|
@@ -30,6 +30,21 @@ def general_commands(user, command, dest, files = [])
|
|
30
30
|
'Það var ekkert', 'De nada', 'No hay de qué', 'De rien', 'Bitte', 'Prego', 'मेरा सौभाग्य है', '不客氣', 'Παρακαλώ']
|
31
31
|
respond "#{responses.sample}#{'!'*rand(4)}"
|
32
32
|
|
33
|
+
# this is a hidden command that it is not listed when calling bot help
|
34
|
+
when /\s*.*happy\s+birthday.*(<@\w+>)\s*.*$/i, /\s*.*(<@\w+>).*happy\s+birthday\s*.*$/i
|
35
|
+
unless Thread.current[:on_thread]
|
36
|
+
save_stats :happy_birthday
|
37
|
+
happy_user = $1
|
38
|
+
reactions = [:tada, :cake, :birthday]
|
39
|
+
sleep 30
|
40
|
+
reactions.sample(rand(3)+1).each {|rt| react rt }
|
41
|
+
sleep (rand(10)+5)*60 # so SmartBot is not the first one
|
42
|
+
responses = ['Happy birthday', "Very happy birthday", "Happy happy happy birthday", "Have a fabulous birthday", 'May all your wishes come true',
|
43
|
+
'Many happy returns of the day', 'I wish you a wonderful birthday', 'Have a great one', 'I hope you have a fantastic day and a fantastic year to come',
|
44
|
+
'To your happiness', "Don't count the candles. Enjoy the party", 'May your day be as awesome as you are', 'The best things in life are yet to come']
|
45
|
+
respond "#{happy_user} #{responses.sample}#{'!'*rand(4)}", :on_thread
|
46
|
+
end
|
47
|
+
|
33
48
|
else
|
34
49
|
return false
|
35
50
|
end
|
data/whats_new.txt
CHANGED
@@ -1,36 +1,18 @@
|
|
1
|
-
*Version 1.
|
1
|
+
*Version 1.12.0* Released 2022-Sep-28
|
2
2
|
|
3
3
|
*For General users*
|
4
|
-
-
|
5
|
-
-
|
6
|
-
- Now
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
- Added
|
12
|
-
- New general command `see favorite commands`. It will display the favorite commands in that channel.
|
13
|
-
- Now when running the `ruby` command it can be supplied a code block.
|
14
|
-
- New general command `share messages /REGEXP/ on #CHANNEL`, `share messages "TEXT" on #CHANNEL`, `see shares', `delete share ID`. It will automatically share new messages published that meet the specified criteria.
|
4
|
+
- `run repl` accepts local parameters and precode to be supplied (<https://github.com/MarioRuiz/slack-smart-bot/issues/60|#60>).
|
5
|
+
- `!!run repl` will respond as soon as any result is released (<https://github.com/MarioRuiz/slack-smart-bot/issues/63|#63>)
|
6
|
+
- Now you can add notes for the team, even you can specify if those notes are private so only the members of the team can see them, or even personal. You can use different types of notes: memo, note, issue, task, feature, bug. Also you can indicate the topic of the note. To be able to add or delete notes you need to be a member of that team. Example: `add private bug to Moon team SRE : Logs should not be accessible from outside VPN` (<https://github.com/MarioRuiz/slack-smart-bot/issues/64|#64> <https://github.com/MarioRuiz/slack-smart-bot/issues/67|#67>)
|
7
|
+
- It is possible to add a JIRA JQL to the team memos that will automatically create the memos from the JIRA issues (<https://github.com/MarioRuiz/slack-smart-bot/issues/68|#68>)
|
8
|
+
- `kill repl RUN_REPL_ID` Will kill a running repl previously executed with `run repl` command. (<https://github.com/MarioRuiz/slack-smart-bot/issues/69|#69>)
|
9
|
+
- Now you can add a GitHub url to the issues you want to add as memos for teams. (<https://github.com/MarioRuiz/slack-smart-bot/issues/71|#71>)
|
10
|
+
- It is possible to add the status of a memo on teams feature. (<https://github.com/MarioRuiz/slack-smart-bot/issues/72|#72>)
|
11
|
+
- Added 'Time off' (Vacation/Sick/Sick Child) management. The SmartBot will automatically set your status on the periods specified. It will be possible to see the 'Time off' plan for a specific team and period. (<https://github.com/MarioRuiz/slack-smart-bot/issues/73|#73>)
|
15
12
|
|
16
13
|
*For Admin users*
|
17
|
-
-
|
18
|
-
-
|
19
|
-
- You can add general commands that will be responding on any channel where the Smart Bot is a member even though is not 'listening to you'. Add them to '/rules/general_commands.rb
|
20
|
-
- when using `respond` you can supply two options: unfurl_links and unfurl_media. By default is a boolean: true
|
21
|
-
- added option 'weekdays' and 'weekends' for `create routine` command, for example: `add silent routine suggestions on weekdays at 09:00 suggest command`
|
22
|
-
- Added a new config for the SmartBot to log all RTM communication, admits `true` or `false`, by default `false`: `logrtm`
|
23
|
-
- Use the command `send message to` and `react to` to impersonate the SmartBot. Only accessible for Master Admins on a DM with the SmartBot.
|
24
|
-
- New command to see the result of the last run of a routine: `see result routine NAME`
|
25
|
-
- Now it is possible to create *bgroutine* then the results of the routine run won't be published.
|
26
|
-
- To display a general message after every command use: `set general message MESSAGE`. Use `set general message off` to stop displaying it.
|
27
|
-
- When adding a general message is possible to use interpolation
|
28
|
-
- If you are a master admin and you are on master channel then you can call `publish announcements` that will publish the announcements on all channels. The messages stored on a DM won't be published. This is very convenient to be called from a *Routine* for example every weekday at 09:00.
|
29
|
-
- Now it is possible to send blocks `respond blocks: my_blocks`. More info about blocks: https://api.slack.com/block-kit
|
30
|
-
- When using bgroutines if we want to avoid a file to be sent:
|
31
|
-
send_file(dest, 'description', "file_path", 'desc', 'text/plain', "text") unless Thread.current[:routine_type] == 'bgroutine'
|
32
|
-
- SmartBot will notify about SmartBot status changes if defined the status_channel in config file and the channel exists. By default: smartbot-status
|
33
|
-
|
14
|
+
- Bot Stats is now saving the time_zone of the user (<https://github.com/MarioRuiz/slack-smart-bot/issues/66|#66>)
|
15
|
+
- Announcements won't be published if no activity on channel. (<https://github.com/MarioRuiz/slack-smart-bot/issues/74|#74)
|
34
16
|
------------------------------
|
35
17
|
|
36
|
-
*Previous*: <https://github.com/MarioRuiz/slack-smart-bot/blob/
|
18
|
+
*Previous*: <https://github.com/MarioRuiz/slack-smart-bot/blob/b1a368c3342094e886f53d96dc4d12ecd81ab04b/whats_new.txt|1.11.0>
|
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.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-29 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.17.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.0
|
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.17.0
|
30
27
|
- - "~>"
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
29
|
+
version: '1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.1.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: nice_http
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: string_pattern
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.2.3
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.2.3
|
61
81
|
- !ruby/object:Gem::Dependency
|
62
82
|
name: async-websocket
|
63
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,10 +150,12 @@ files:
|
|
130
150
|
- lib/slack-smart-bot_rules.rb
|
131
151
|
- lib/slack/smart-bot/comm.rb
|
132
152
|
- lib/slack/smart-bot/comm/ask.rb
|
153
|
+
- lib/slack/smart-bot/comm/delete.rb
|
133
154
|
- lib/slack/smart-bot/comm/dont_understand.rb
|
134
155
|
- lib/slack/smart-bot/comm/event_hello.rb
|
135
156
|
- lib/slack/smart-bot/comm/get_channel_members.rb
|
136
157
|
- lib/slack/smart-bot/comm/get_channels.rb
|
158
|
+
- lib/slack/smart-bot/comm/get_presence.rb
|
137
159
|
- lib/slack/smart-bot/comm/get_user_info.rb
|
138
160
|
- lib/slack/smart-bot/comm/get_users.rb
|
139
161
|
- lib/slack/smart-bot/comm/react.rb
|
@@ -143,26 +165,40 @@ files:
|
|
143
165
|
- lib/slack/smart-bot/comm/send_file.rb
|
144
166
|
- lib/slack/smart-bot/comm/send_msg_channel.rb
|
145
167
|
- lib/slack/smart-bot/comm/send_msg_user.rb
|
168
|
+
- lib/slack/smart-bot/comm/set_status.rb
|
146
169
|
- lib/slack/smart-bot/comm/unreact.rb
|
147
170
|
- lib/slack/smart-bot/commands.rb
|
171
|
+
- lib/slack/smart-bot/commands/general/add_admin.rb
|
148
172
|
- lib/slack/smart-bot/commands/general/add_announcement.rb
|
173
|
+
- lib/slack/smart-bot/commands/general/add_memo_team.rb
|
174
|
+
- lib/slack/smart-bot/commands/general/add_team.rb
|
175
|
+
- lib/slack/smart-bot/commands/general/add_vacation.rb
|
176
|
+
- lib/slack/smart-bot/commands/general/allow_access.rb
|
149
177
|
- lib/slack/smart-bot/commands/general/bot_help.rb
|
150
|
-
- lib/slack/smart-bot/commands/general/bot_stats.rb
|
151
|
-
- lib/slack/smart-bot/commands/general/bot_status.rb
|
152
178
|
- lib/slack/smart-bot/commands/general/bye_bot.rb
|
153
179
|
- lib/slack/smart-bot/commands/general/delete_announcement.rb
|
180
|
+
- lib/slack/smart-bot/commands/general/delete_memo_team.rb
|
154
181
|
- lib/slack/smart-bot/commands/general/delete_share.rb
|
182
|
+
- lib/slack/smart-bot/commands/general/delete_team.rb
|
183
|
+
- lib/slack/smart-bot/commands/general/deny_access.rb
|
155
184
|
- lib/slack/smart-bot/commands/general/hi_bot.rb
|
156
|
-
- lib/slack/smart-bot/commands/general/
|
185
|
+
- lib/slack/smart-bot/commands/general/ping_team.rb
|
186
|
+
- lib/slack/smart-bot/commands/general/poster.rb
|
187
|
+
- lib/slack/smart-bot/commands/general/remove_admin.rb
|
188
|
+
- lib/slack/smart-bot/commands/general/remove_vacation.rb
|
189
|
+
- lib/slack/smart-bot/commands/general/see_access.rb
|
190
|
+
- lib/slack/smart-bot/commands/general/see_admins.rb
|
157
191
|
- lib/slack/smart-bot/commands/general/see_announcements.rb
|
192
|
+
- lib/slack/smart-bot/commands/general/see_command_ids.rb
|
158
193
|
- lib/slack/smart-bot/commands/general/see_favorite_commands.rb
|
159
194
|
- lib/slack/smart-bot/commands/general/see_shares.rb
|
160
195
|
- lib/slack/smart-bot/commands/general/see_statuses.rb
|
196
|
+
- lib/slack/smart-bot/commands/general/see_teams.rb
|
197
|
+
- lib/slack/smart-bot/commands/general/see_vacations.rb
|
198
|
+
- lib/slack/smart-bot/commands/general/see_vacations_team.rb
|
199
|
+
- lib/slack/smart-bot/commands/general/set_memo_status.rb
|
161
200
|
- lib/slack/smart-bot/commands/general/share_messages.rb
|
162
|
-
- lib/slack/smart-bot/commands/general/
|
163
|
-
- lib/slack/smart-bot/commands/general/suggest_command.rb
|
164
|
-
- lib/slack/smart-bot/commands/general/use_rules.rb
|
165
|
-
- lib/slack/smart-bot/commands/general/whats_new.rb
|
201
|
+
- lib/slack/smart-bot/commands/general/update_team.rb
|
166
202
|
- lib/slack/smart-bot/commands/general_bot_commands.rb
|
167
203
|
- lib/slack/smart-bot/commands/on_bot/add_shortcut.rb
|
168
204
|
- lib/slack/smart-bot/commands/on_bot/admin/add_routine.rb
|
@@ -176,12 +212,21 @@ files:
|
|
176
212
|
- lib/slack/smart-bot/commands/on_bot/admin/start_bot.rb
|
177
213
|
- lib/slack/smart-bot/commands/on_bot/admin/start_routine.rb
|
178
214
|
- lib/slack/smart-bot/commands/on_bot/admin/stop_using_rules_on.rb
|
215
|
+
- lib/slack/smart-bot/commands/on_bot/admin_master/delete_message.rb
|
179
216
|
- lib/slack/smart-bot/commands/on_bot/admin_master/get_bot_logs.rb
|
180
217
|
- lib/slack/smart-bot/commands/on_bot/admin_master/react_to.rb
|
181
218
|
- lib/slack/smart-bot/commands/on_bot/admin_master/send_message.rb
|
182
219
|
- lib/slack/smart-bot/commands/on_bot/delete_repl.rb
|
183
220
|
- lib/slack/smart-bot/commands/on_bot/delete_shortcut.rb
|
221
|
+
- lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb
|
222
|
+
- lib/slack/smart-bot/commands/on_bot/general/bot_status.rb
|
223
|
+
- lib/slack/smart-bot/commands/on_bot/general/leaderboard.rb
|
224
|
+
- lib/slack/smart-bot/commands/on_bot/general/stop_using_rules.rb
|
225
|
+
- lib/slack/smart-bot/commands/on_bot/general/suggest_command.rb
|
226
|
+
- lib/slack/smart-bot/commands/on_bot/general/use_rules.rb
|
227
|
+
- lib/slack/smart-bot/commands/on_bot/general/whats_new.rb
|
184
228
|
- lib/slack/smart-bot/commands/on_bot/get_repl.rb
|
229
|
+
- lib/slack/smart-bot/commands/on_bot/kill_repl.rb
|
185
230
|
- lib/slack/smart-bot/commands/on_bot/repl.rb
|
186
231
|
- lib/slack/smart-bot/commands/on_bot/ruby_code.rb
|
187
232
|
- lib/slack/smart-bot/commands/on_bot/run_repl.rb
|
@@ -195,6 +240,7 @@ files:
|
|
195
240
|
- lib/slack/smart-bot/commands/on_master/admin_master/set_general_message.rb
|
196
241
|
- lib/slack/smart-bot/commands/on_master/admin_master/set_maintenance.rb
|
197
242
|
- lib/slack/smart-bot/commands/on_master/create_bot.rb
|
243
|
+
- lib/slack/smart-bot/commands/on_master/where_smartbot.rb
|
198
244
|
- lib/slack/smart-bot/listen.rb
|
199
245
|
- lib/slack/smart-bot/process.rb
|
200
246
|
- lib/slack/smart-bot/process_first.rb
|
@@ -203,23 +249,34 @@ files:
|
|
203
249
|
- lib/slack/smart-bot/utils/answer.rb
|
204
250
|
- lib/slack/smart-bot/utils/answer_delete.rb
|
205
251
|
- lib/slack/smart-bot/utils/build_help.rb
|
252
|
+
- lib/slack/smart-bot/utils/check_vacations.rb
|
206
253
|
- lib/slack/smart-bot/utils/create_routine_thread.rb
|
254
|
+
- lib/slack/smart-bot/utils/get_access_channels.rb
|
255
|
+
- lib/slack/smart-bot/utils/get_admins_channels.rb
|
207
256
|
- lib/slack/smart-bot/utils/get_bots_created.rb
|
208
257
|
- lib/slack/smart-bot/utils/get_channels_name_and_id.rb
|
258
|
+
- lib/slack/smart-bot/utils/get_command_ids.rb
|
209
259
|
- lib/slack/smart-bot/utils/get_help.rb
|
210
260
|
- lib/slack/smart-bot/utils/get_repls.rb
|
211
261
|
- lib/slack/smart-bot/utils/get_routines.rb
|
212
262
|
- lib/slack/smart-bot/utils/get_rules_imported.rb
|
213
263
|
- lib/slack/smart-bot/utils/get_shares.rb
|
264
|
+
- lib/slack/smart-bot/utils/get_teams.rb
|
265
|
+
- lib/slack/smart-bot/utils/get_vacations.rb
|
214
266
|
- lib/slack/smart-bot/utils/has_access.rb
|
267
|
+
- lib/slack/smart-bot/utils/is_admin.rb
|
215
268
|
- lib/slack/smart-bot/utils/remove_hash_keys.rb
|
216
269
|
- lib/slack/smart-bot/utils/save_stats.rb
|
217
270
|
- lib/slack/smart-bot/utils/save_status.rb
|
271
|
+
- lib/slack/smart-bot/utils/update_access_channels.rb
|
272
|
+
- lib/slack/smart-bot/utils/update_admins_channels.rb
|
218
273
|
- lib/slack/smart-bot/utils/update_bots_file.rb
|
219
274
|
- lib/slack/smart-bot/utils/update_repls.rb
|
220
275
|
- lib/slack/smart-bot/utils/update_routines.rb
|
221
276
|
- lib/slack/smart-bot/utils/update_rules_imported.rb
|
222
277
|
- lib/slack/smart-bot/utils/update_shortcuts_file.rb
|
278
|
+
- lib/slack/smart-bot/utils/update_teams.rb
|
279
|
+
- lib/slack/smart-bot/utils/update_vacations.rb
|
223
280
|
- whats_new.txt
|
224
281
|
homepage: https://github.com/MarioRuiz/slack-smart-bot
|
225
282
|
licenses:
|
@@ -233,15 +290,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
290
|
requirements:
|
234
291
|
- - ">="
|
235
292
|
- !ruby/object:Gem::Version
|
236
|
-
version: '2.
|
293
|
+
version: '2.7'
|
237
294
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
295
|
requirements:
|
239
296
|
- - ">="
|
240
297
|
- !ruby/object:Gem::Version
|
241
298
|
version: '0'
|
242
299
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
244
|
-
signing_key:
|
300
|
+
rubygems_version: 3.2.15
|
301
|
+
signing_key:
|
245
302
|
specification_version: 4
|
246
303
|
summary: Create a Slack bot that is smart and so easy to expand, create new bots on
|
247
304
|
demand, run ruby code on chat, create shortcuts...
|