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
@@ -27,6 +27,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
27
27
|
# help: you can use the option 'expanded' or the alias 'extended'
|
28
28
|
# help: `bot rules` will show only the specific rules for this channel.
|
29
29
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-help|more info>
|
30
|
+
# help: command_id: :bot_help
|
30
31
|
# help:
|
31
32
|
|
32
33
|
|
@@ -39,6 +40,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
39
40
|
# help: After that if you want to avoid a single message to be treated by the smart bot, start the message by -
|
40
41
|
# help: Also apart of Hello you can use _Hallo, Hi, Hola, What's up, Hey, Hæ_
|
41
42
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
43
|
+
# help: command_id: :hi_bot
|
42
44
|
# help:
|
43
45
|
when /\A\s*(Hello|Hallo|Hi|Hola|What's\sup|Hey|Hæ)\s+(#{@salutations.join("|")})\s*$/i
|
44
46
|
hi_bot(user, dest, user.name, display_name)
|
@@ -50,6 +52,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
50
52
|
# help: Bot stops listening to you if you are on a Bot channel
|
51
53
|
# help: Also apart of Bye you can use _Bæ, Good Bye, Adiós, Ciao, Bless, Bless Bless, Adeu_
|
52
54
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
55
|
+
# help: command_id: :bye_bot
|
53
56
|
# help:
|
54
57
|
when /\A\s*(Bye|Bæ|Good\s+Bye|Adiós|Ciao|Bless|Bless\sBless|Adeu)\s+(#{@salutations.join("|")})\s*$/i
|
55
58
|
bye_bot(dest, user.name, display_name)
|
@@ -70,9 +73,10 @@ def general_bot_commands(user, command, dest, files = [])
|
|
70
73
|
# help: _add message `*Party* will start at *20:00* :tada:`_
|
71
74
|
# help: _add :heavy_exclamation_mark: message Pay attention all DB are on maintenance until 20:00 GMT_
|
72
75
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
76
|
+
# help: command_id: :add_announcement
|
73
77
|
# help:
|
74
78
|
when /\A\s*(add|create)\s+(red\s+|green\s+|white\s+|yellow\s+)?(announcement|statement|declaration|message)\s+(.+)\s*\z/i,
|
75
|
-
/\A\s*(add|create)\s+(
|
79
|
+
/\A\s*(add|create)\s+(:[\w\-]+:)\s+(announcement|statement|declaration|message)\s+(.+)\s*\z/i
|
76
80
|
type = $2.to_s.downcase.strip
|
77
81
|
type = 'white' if type == ''
|
78
82
|
message = $4
|
@@ -89,6 +93,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
89
93
|
# help: _delete statement 77_
|
90
94
|
# help: _delete declaration 334_
|
91
95
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
96
|
+
# help: command_id: :delete_announcement
|
92
97
|
# help:
|
93
98
|
when /\A\s*(delete|remove)\s+(announcement|statement|declaration|message)\s+(\d+)\s*\z/i
|
94
99
|
message_id = $3
|
@@ -115,11 +120,12 @@ def general_bot_commands(user, command, dest, files = [])
|
|
115
120
|
# help: _see messages_
|
116
121
|
# help: _see :heavy_exclamation_mark: messages_
|
117
122
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
123
|
+
# help: command_id: :see_announcements
|
118
124
|
# help:
|
119
|
-
when /\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s
|
125
|
+
when /\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
120
126
|
/\A\s*see\s+(all\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
121
|
-
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s
|
122
|
-
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s
|
127
|
+
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+#([\w\-]+)\s*\z/i,
|
128
|
+
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+<#(\w+)\|.*>\s*\z/i
|
123
129
|
|
124
130
|
type = $1.to_s.downcase.strip
|
125
131
|
channel = $3.to_s
|
@@ -137,11 +143,12 @@ def general_bot_commands(user, command, dest, files = [])
|
|
137
143
|
# help: The Regexp will automatically add the parameters /im
|
138
144
|
# help: Only available on public channels.
|
139
145
|
# help: Examples:
|
140
|
-
# help: _share messages /(last\s+|previous\s+)
|
146
|
+
# help: _share messages /(last\s+|previous\s+)sales\s+results\s+/ on #sales_
|
141
147
|
# help: _share messages "share post" on #announcements_
|
142
148
|
# xhelp: _share messages :tada: on #announcements_
|
143
149
|
# xhelp: _share messages :moneybag: from #sales_
|
144
150
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
151
|
+
# help: command_id: :share_messages
|
145
152
|
# help:
|
146
153
|
when /\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#\w+\|(.+)>\s*\z/i,
|
147
154
|
/\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#(\w+)\|>\s*\z/,
|
@@ -158,6 +165,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
158
165
|
# help: `see shares`
|
159
166
|
# help: It will display the active shares from this channel.
|
160
167
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
168
|
+
# help: command_id: :see_shares
|
161
169
|
# help:
|
162
170
|
when /\A\s*see\s+shares\s*\z/i
|
163
171
|
see_shares()
|
@@ -168,6 +176,7 @@ def general_bot_commands(user, command, dest, files = [])
|
|
168
176
|
# help: Examples:
|
169
177
|
# help: _delete share 24_
|
170
178
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
179
|
+
# help: command_id: :delete_share
|
171
180
|
# help:
|
172
181
|
when /\A\s*(delete|remove)\s+share\s+(\d+)\s*\z/i
|
173
182
|
share_id = $2
|
@@ -185,26 +194,34 @@ def general_bot_commands(user, command, dest, files = [])
|
|
185
194
|
# help: `who is on EMOJI1 EMOJI99`
|
186
195
|
# help: `who is not on vacation?`
|
187
196
|
# help: `who is not on EMOJI`
|
197
|
+
# help: `who is available?`
|
188
198
|
# help: It will display the current statuses of the members of the channel where you are calling the command or on the channel you supply.
|
199
|
+
# help: In case of `who is available?` will show members of the channel that are on line and not on a meeting or vacation or sick.
|
189
200
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-statuses|more info>
|
201
|
+
# help: command_id: :see_statuses
|
190
202
|
# help:
|
191
203
|
when /\A\s*(see|get)\s+(statuses)()\s*\z/i,
|
192
|
-
/\A\s*(see\s+status|get\s+status|who\s+is\s+on|who\s+is\s+not\s+on)\s+(:[\w\-\:\s]+:)\s*\??()\s*\z/i,
|
193
|
-
/\A\s*(who\s+is\s+on|who\s+is\s+not\s+on)\s+(vacation|holiday)\s*\??()\s*\z/i,
|
204
|
+
/\A\s*(see\s+status|get\s+status|who\s+is\s+on|who\s+are\s+on|who\s+is\s+not\s+on|who\s+are\s+not\s+on)\s+(:[\w\-\:\s]+:)\s*\??()\s*\z/i,
|
205
|
+
/\A\s*(who\s+is\s+on|who\s+are\s+on|who\s+is\s+not\s+on|who\s+are\s+not\s+on)\s+(vacation|holiday)\s*\??()\s*\z/i,
|
206
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??()\s*\z/i,
|
194
207
|
/\A\s*(see|get)\s+(statuses)\s+#([\w\-]+)\s*\z/i,
|
195
|
-
/\A\s*(see\s+status|get\s+status|who\s+is\s+on|who\s+is\s+not\s+on)\s+(:[\w\-\:\s]+:)\s*\??\s+#([\w\-]+)\s*\z/i,
|
196
|
-
/\A\s*(who\s+is
|
197
|
-
/\A\s*(
|
198
|
-
/\A\s*(
|
199
|
-
/\A\s*(
|
208
|
+
/\A\s*(see\s+status|get\s+status|who\s+is\s+on|who\s+are\s+on|who\s+is\s+not\s+on|who\s+are\s+not\s+on)\s+(:[\w\-\:\s]+:)\s*\??\s+#([\w\-]+)\s*\z/i,
|
209
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+#([\w\-]+)\s*\z/i,
|
210
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+<#(\w+)\|.*>\s*\z/i,
|
211
|
+
/\A\s*(who\s+is\s+on|who\s+are\s+on|who\s+is\s+not\s+on|who\s+are\s+not\s+on)\s+(vacation|holiday)\s*\??\s+#([\w\-]+)\s*\z/i,
|
212
|
+
/\A\s*(see|get)\s+(statuses)\s+<#(\w+)\|.*>\s*\z/i,
|
213
|
+
/\A\s*(see\s+status|get\s+status|who\s+is\s+on|who\s+is\s+not\s+on|who\s+are\s+on|who\s+are\s+not\s+on)\s+(:[\w\-\:\s]+:)\s*\??\s+<#(\w+)\|.*>\s*\z/i,
|
214
|
+
/\A\s*(who\s+is\s+on|who\s+is\s+not\s+on|who\s+are\s+on|who\s+are\s+not\s+on)\s+(vacation|holiday)\s*\??\s+<#(\w+)\|.*>\s*\z/i
|
200
215
|
|
201
|
-
not_on = $1.match?(/who\s+is\s+not\s+on/i)
|
216
|
+
not_on = $1.match?(/who\s+(is|are)\s+not\s+on/i)
|
202
217
|
type = $2.downcase
|
203
218
|
channel = $3.to_s
|
204
219
|
if type == 'statuses'
|
205
220
|
types = []
|
206
221
|
elsif type =='vacation' or type == 'holiday'
|
207
222
|
types = [':palm_tree:']
|
223
|
+
elsif type == 'available' or type == 'active'
|
224
|
+
types = ['available']
|
208
225
|
else
|
209
226
|
type.gsub!(' ', '')
|
210
227
|
type.gsub!('::',': :')
|
@@ -222,11 +239,423 @@ def general_bot_commands(user, command, dest, files = [])
|
|
222
239
|
# help: aliases for favorite: favourite, most used, fav
|
223
240
|
# helpmaster: You need to set stats to true to generate the stats when running the bot instance and get this info.
|
224
241
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-favorite-commands|more info>
|
242
|
+
# help: command_id: :see_favorite_commands
|
225
243
|
# help:
|
226
244
|
when /\A\s*(see\s+)?(my\s+)?(fav|favorite|favourite|most\s+used)\s+commands\s*\z/i
|
227
245
|
only_mine = $2.to_s!=''
|
228
246
|
see_favorite_commands(user, only_mine)
|
229
247
|
|
248
|
+
# helpadmin: ----------------------------------------------
|
249
|
+
# helpadmin: `add admin @user`
|
250
|
+
# helpadmin: It will add @user as an admin of the channel.
|
251
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
252
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
253
|
+
# helpadmin: command_id: :add_admin
|
254
|
+
# helpadmin:
|
255
|
+
when /\A\s*add\s+admin\s+<@(\w+)>\s*\z/i
|
256
|
+
admin_user = $1
|
257
|
+
add_admin(user, admin_user)
|
258
|
+
|
259
|
+
# help: ----------------------------------------------
|
260
|
+
# help: `see admins`
|
261
|
+
# help: `show admins`
|
262
|
+
# help: `who are admins?`
|
263
|
+
# help: It will show who are the admins of the channel.
|
264
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
265
|
+
# help: command_id: :see_admins
|
266
|
+
# help:
|
267
|
+
when /\A\s*(see|show)\s+admins\s*\z/i, /\A\s*who\s+are\s+(the\s+)?admins\??\s*\z/i
|
268
|
+
see_admins()
|
269
|
+
|
270
|
+
# helpadmin: ----------------------------------------------
|
271
|
+
# helpadmin: `remove admin @user`
|
272
|
+
# helpadmin: It will remove the admin privileges for @user on the channel.
|
273
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
274
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
275
|
+
# helpadmin: command_id: :remove_admin
|
276
|
+
# helpadmin:
|
277
|
+
when /\A\s*(remove|delete)\s+admin\s+<@(\w+)>\s*\z/i
|
278
|
+
admin_user = $2
|
279
|
+
remove_admin(user, admin_user)
|
280
|
+
|
281
|
+
# helpadmin: ----------------------------------------------
|
282
|
+
# helpadmin: `see command ids`
|
283
|
+
# helpadmin: It will display all available command ids.
|
284
|
+
# helpadmin: The command id can be used on `bot stats command COMMAND_ID`, `allow access COMMAND_ID` and `deny access COMMAND_ID`
|
285
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
286
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
287
|
+
# helpadmin: command_id: :see_command_ids
|
288
|
+
# helpadmin:
|
289
|
+
when /\A\s*(see|display|get)\s+command(\s+|_)ids?\s*\z/i
|
290
|
+
see_command_ids()
|
291
|
+
|
292
|
+
# helpadmin: ----------------------------------------------
|
293
|
+
# helpadmin: `allow access COMMAND_ID`
|
294
|
+
# helpadmin: `allow access COMMAND_ID @user1 @user99`
|
295
|
+
# helpadmin: It will allow the specified command to be used on the channel.
|
296
|
+
# helpadmin: If @user specified, only those users will have access to the command.
|
297
|
+
# helpadmin: Only admins of the channel can use this command
|
298
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
299
|
+
# helpadmin: command_id: :allow_access
|
300
|
+
# helpadmin:
|
301
|
+
when /\A\s*(allow|give)\s+access\s+(\w+)\s+(.+)\s*\z/i, /\A\s*(allow|give)\s+access\s+(\w+)()\s*\z/i
|
302
|
+
command_id = $2.downcase
|
303
|
+
opt = $3.to_s.split(' ')
|
304
|
+
allow_access(user, command_id, opt)
|
305
|
+
|
306
|
+
# helpadmin: ----------------------------------------------
|
307
|
+
# helpadmin: `deny access COMMAND_ID`
|
308
|
+
# helpadmin: It won't allow the specified command to be used on the channel.
|
309
|
+
# helpadmin: Only admins of the channel can use this command
|
310
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
311
|
+
# helpadmin: command_id: :deny_access
|
312
|
+
# helpadmin:
|
313
|
+
when /\A\s*deny\s+access(\s+rights)?\s+(\w+)\s*\z/i
|
314
|
+
command_id = $2.downcase
|
315
|
+
deny_access(user, command_id)
|
316
|
+
|
317
|
+
|
318
|
+
# help: ----------------------------------------------
|
319
|
+
# help: `see access COMMAND_ID`
|
320
|
+
# help: It will show the access rights for the specified command.
|
321
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
322
|
+
# help: command_id: :see_access
|
323
|
+
# help:
|
324
|
+
when /\A\s*(see|show)\s+access(\s+rights)?\s+(.+)\s*\z/i
|
325
|
+
command_id = $3.downcase
|
326
|
+
see_access(command_id)
|
327
|
+
|
328
|
+
# help: ----------------------------------------------
|
329
|
+
# help: `poster MESSAGE`
|
330
|
+
# help: `poster :EMOTICON_TEXT: MESSAGE`
|
331
|
+
# help: `poster :EMOTICON_TEXT: :EMOTICON_BACKGROUND: MESSAGE`
|
332
|
+
# help: `poster MINUTESm MESSAGE`
|
333
|
+
# help: It will create a poster with the message supplied. By default will be autodeleted 1 minute later.
|
334
|
+
# help: If you want the poster to be permanent then use the command `pposter`
|
335
|
+
# help: If minutes supplied then it will be deleted after the minutes specified. Maximum value 60.
|
336
|
+
# help: To see the messages on a mobile phone put the phone on landscape mode
|
337
|
+
# help: Max 15 characters. If the message is longer than that won't be treat it.
|
338
|
+
# help: Only letters from a to z, 0 to 9 and the chars: ? ! - + =
|
339
|
+
# help: To be displayed correctly use words with no more than 6 characters
|
340
|
+
# help: Examples:
|
341
|
+
# help: _poster nice work!_
|
342
|
+
# help: _poster :heart: nice work!_
|
343
|
+
# help: _poster :mac-spinning-wheel: :look: love!_
|
344
|
+
# help: _poster 25m :heart: woah!_
|
345
|
+
# help: command_id: :poster
|
346
|
+
# help:
|
347
|
+
when /\A()poster\s+(\d+m\s+)?(:[^:]+:)\s+(:[^:]+:)(.+)\s*\z/i, /\A()poster\s+(\d+m\s+)?(:.+:)\s+()(.+)\s*\z/i, /\A()poster\s+(\d+m\s+)?()()(.+)\s*\z/i,
|
348
|
+
/\A(p)poster\s+()(:[^:]+:)\s+(:[^:]+:)(.+)\s*\z/i, /\A(p)poster\s+()(:.+:)\s+()(.+)\s*\z/i, /\A(p)poster\s+()()()(.+)\s*\z/i
|
349
|
+
permanent = $1.to_s != ''
|
350
|
+
minutes = $2.to_s
|
351
|
+
emoticon_text = $3
|
352
|
+
emoticon_bg = $4
|
353
|
+
text = $5
|
354
|
+
minutes = minutes.scan(/(\d+)/).join
|
355
|
+
|
356
|
+
if minutes == ''
|
357
|
+
minutes = 1
|
358
|
+
elsif minutes.to_i > 60
|
359
|
+
minutes = 60
|
360
|
+
end
|
361
|
+
|
362
|
+
save_stats :poster
|
363
|
+
if text.to_s.gsub(/\s+/, '').length > 15
|
364
|
+
respond "Too long. Max 15 chars", :on_thread
|
365
|
+
else
|
366
|
+
poster(permanent, emoticon_text, emoticon_bg, text, minutes)
|
367
|
+
end
|
368
|
+
|
369
|
+
# help: ----------------------------------------------
|
370
|
+
# help: `add team TEAM_NAME members #TEAM_CHANNEL CHANNEL_TYPE #CHANNEL1 #CHANNEL99 : INFO`
|
371
|
+
# help: `add team TEAM_NAME MEMBER_TYPE @USER1 @USER99 CHANNEL_TYPE #CHANNEL1 #CHANNEL99 : INFO`
|
372
|
+
# help: `add team TEAM_NAME MEMBER_TYPE1 @USER1 @USER99 MEMBER_TYPE99 @USER1 @USER99 CHANNEL_TYPE1 #CHANNEL1 #CHANNEL99 CHANNEL_TYPE99 #CHANNEL1 #CHANNEL99 : INFO`
|
373
|
+
# help: It will add a team with the info supplied.
|
374
|
+
# help: TEAM_NAME, TYPE: one word, a-z, A-Z, 0-9, - and _
|
375
|
+
# help: In case it is supplied a channel with type 'members' the members of that channel would be considered members of the team. The SmartBot needs to be a member of the channel.
|
376
|
+
# help: Examples:
|
377
|
+
# help: _add team sales members #sales support #sales-support public #sales-ff : Contact us if you need anything related to Sales. You can also send us an email at sales@ffxaja.com_
|
378
|
+
# help: _add team Sales manager @ann qa @peter @berglind dev @john @sam @marta members #sales support #sales-support public #sales-ff : Contact us if you need anything related to Sales. You can also send us an email at sales@ffxaja.com_
|
379
|
+
# help: _add team devweb qa @jim dev @johnja @cooke @luisa members #devweb support #devweb-support : We take care of the website_
|
380
|
+
# help: _add team sandex manager @sarah members #sandex : We take care of the sand_
|
381
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
382
|
+
# help: command_id: :add_team
|
383
|
+
# help:
|
384
|
+
when /\A\s*add\s+team\s+([\w\-]+)\s+([^:]+)\s*:\s+(.+)\s*\z/im, /\A\s*add\s+([\w\-]+)\s+team\s+([^:]+)\s*:\s+(.+)\s*\z/im
|
385
|
+
name = $1.downcase
|
386
|
+
options = $2
|
387
|
+
info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
388
|
+
add_team(user, name, options, info)
|
389
|
+
|
390
|
+
# help: ----------------------------------------------
|
391
|
+
# help: `add TYPE to TEAM_NAME team : MESSAGE`
|
392
|
+
# help: `add private TYPE to TEAM_NAME team : MESSAGE`
|
393
|
+
# help: `add personal TYPE to TEAM_NAME team : MESSAGE`
|
394
|
+
# help: `add TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
395
|
+
# help: `add private TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
396
|
+
# help: `add personal TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
397
|
+
# help: It will add a memo to the team. The memos will be displayed with the team info.
|
398
|
+
# help: Only team members can add a memo.
|
399
|
+
# help: TYPE: memo, note, issue, task, feature, bug, jira, github
|
400
|
+
# help: TOPIC: one word, a-z, A-Z, 0-9, - and _
|
401
|
+
# help: If private then the memo will be only displayed to team members on a DM or the members channel.
|
402
|
+
# help: If personal then the memo will be only displayed to the creator on a DM.
|
403
|
+
# help: In case jira type supplied:
|
404
|
+
# help: The message should be an JQL URL, JQL string or an issue URL.
|
405
|
+
# help: To be able to use it you need to specify on the SmartBot settings the credentials.
|
406
|
+
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every JIRA issue
|
407
|
+
# help: In case github type supplied:
|
408
|
+
# help: The message should be a github URL. You can filter by state (open/closed/all) and labels
|
409
|
+
# help: To be able to use it you need to specify on the SmartBot settings the github token.
|
410
|
+
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every Github issue
|
411
|
+
# help: Examples:
|
412
|
+
# help: _add memo to sales team : Add tests for Michigan feature_
|
413
|
+
# help: _add private note to sales team : Bills will need to be deployed before Friday_
|
414
|
+
# help: _add memo to dev team web : Check last version_
|
415
|
+
# help: _add private bug to dev team SRE : Logs should not be accessible from outside VPN_
|
416
|
+
# help: _add memo sales team : Add tests for Michigan feature_
|
417
|
+
# help: _add memo team sales: Add tests for Michigan feature_
|
418
|
+
# help: _add personal memo team sales: Check my vacations_
|
419
|
+
# help: _add jira to sales team : labels = SalesT AND status != Done_
|
420
|
+
# help: _add github to sales team : PeterBale/SalesBoom/issues?state=open&labels=bug_
|
421
|
+
# help: _add github to sales team dev: PeterBale/DevProject/issues/71_
|
422
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
423
|
+
# help: command_id: :add_memo_team
|
424
|
+
# help:
|
425
|
+
when /\A\s*add\s+(private\s+|personal\s+)?(memo|note|issue|task|feature|bug|jira|github)\s+(to\s+)?team\s+([\w\-]+)\s*([^:]+)?\s*:\s+(.+)\s*\z/im,
|
426
|
+
/\A\s*add\s+(private\s+|personal\s+)?(memo|note|issue|task|feature|bug|jira|github)\s+(to\s+)?([\w\-]+)\s+team\s*([^:]+)?\s*:\s+(.+)\s*\z/im
|
427
|
+
privacy = $1.to_s.strip.downcase
|
428
|
+
type = $2.downcase
|
429
|
+
team_name = $4.downcase
|
430
|
+
topic = $5.to_s.strip
|
431
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
432
|
+
add_memo_team(user, privacy, team_name, topic, type, message)
|
433
|
+
|
434
|
+
# help: ----------------------------------------------
|
435
|
+
# help: `delete memo ID from TEAM_NAME team`
|
436
|
+
# help: It will delete the supplied memo ID on the team specified.
|
437
|
+
# help: aliases for memo: note, issue, task, feature, bug, jira, github
|
438
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a memo.
|
439
|
+
# help: Examples:
|
440
|
+
# help: _delete memo 32 from sales team_
|
441
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
442
|
+
# help: command_id: :delete_memo_team
|
443
|
+
# help:
|
444
|
+
when /\A\s*(delete|remove)\s+(memo|note|issue|task|feature|bug|jira|github)\s+(\d+)\s+(from|on)\s+team\s+([\w\-]+)\s*\z/i,
|
445
|
+
/\A\s*(delete|remove)\s+(memo|note|issue|task|feature|bug|jira|github)\s+(\d+)\s+(from|on)\s+([\w\-]+)\s+team\s*\z/i
|
446
|
+
memo_id = $3
|
447
|
+
team_name = $5.downcase
|
448
|
+
delete_memo_team(user, team_name, memo_id)
|
449
|
+
|
450
|
+
# help: ----------------------------------------------
|
451
|
+
# help: `set memo ID on TEAM_NAME team STATUS`
|
452
|
+
# help: `set STATUS on memo ID TEAM_NAME team`
|
453
|
+
# help: It will assign to the ID specified the emoticon status indicated.
|
454
|
+
# help: aliases for memo: note, issue, task, feature, bug
|
455
|
+
# help: This command will be only for memo, note, issue, task, feature, bug. Not for jira or github.
|
456
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to set a status.
|
457
|
+
# help: Examples:
|
458
|
+
# help: _set memo 32 on sales team :runner:_
|
459
|
+
# help: _set bug 7 on team sales :heavy_check_mark:_
|
460
|
+
# help: _set :runner: on memo 6 sales team_
|
461
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
462
|
+
# help: command_id: :set_memo_status
|
463
|
+
# help:
|
464
|
+
when /\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+team\s+([\w\-]+)\s+(:[\w\-]+:)\s*\z/i,
|
465
|
+
/\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+([\w\-]+)\s+team\s+(:[\w\-]+:)\s*\z/i
|
466
|
+
memo_id = $3
|
467
|
+
team_name = $4.downcase
|
468
|
+
status = $5
|
469
|
+
set_memo_status(user, team_name, memo_id, status)
|
470
|
+
|
471
|
+
when /\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+team\s+([\w\-]+)\s*\z/i,
|
472
|
+
/\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+([\w\-]+)\s+team\s*\z/i
|
473
|
+
memo_id = $4
|
474
|
+
team_name = $5.downcase
|
475
|
+
status = $2
|
476
|
+
set_memo_status(user, team_name, memo_id, status)
|
477
|
+
|
478
|
+
# help: ----------------------------------------------
|
479
|
+
# help: `see teams`
|
480
|
+
# help: `see team TEAM_NAME`
|
481
|
+
# help: `team TEAM_NAME`
|
482
|
+
# help: `TEAM_NAME team`
|
483
|
+
# help: `which team @USER`
|
484
|
+
# help: `which team #CHANNEL`
|
485
|
+
# help: `which team TEXT_TO_SEARCH_ON_INFO`
|
486
|
+
# help: `which team does @USER belongs to?`
|
487
|
+
# help: It will display all teams or the team specified.
|
488
|
+
# help: In case a specific team it will show also the availability of the members.
|
489
|
+
# help: Examples:
|
490
|
+
# help: _see teams_
|
491
|
+
# help: _see team Sales_
|
492
|
+
# help: _Dev team_
|
493
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
494
|
+
# help: command_id: :see_teams
|
495
|
+
# help:
|
496
|
+
when /\A\s*see\s+teams?\s*([\w\-]+)?\s*\z/i, /\A\s*team\s+([\w\-]+)\s*\z/i, /\A\s*([\w\-]+)\s+team\s*\z/i, /\A\s*see\s+all\s+teams\s*()\z/i
|
497
|
+
name = $1.to_s.downcase
|
498
|
+
see_teams(user, name)
|
499
|
+
when /\A\s*(which|search)\s+teams?\s+(is\s+)?(.+)\??\s*\z/i, /\A\s*which\s+team\s+does\s+()()(.+)\s+belongs\s+to\??\s*\z/i
|
500
|
+
search = $3.to_s.downcase
|
501
|
+
see_teams(user, '', search)
|
502
|
+
|
503
|
+
# help: ----------------------------------------------
|
504
|
+
# help: `update team TEAM_NAME NEW_TEAM_NAME`
|
505
|
+
# help: `update team TEAM_NAME : NEW_INFO`
|
506
|
+
# help: `update team TEAM_NAME add MEMBER_TYPE @USER`
|
507
|
+
# help: `update team TEAM_NAME add CHANNEL_TYPE #CHANNEL`
|
508
|
+
# help: `update team TEAM_NAME delete MEMBER_TYPE @USER`
|
509
|
+
# help: `update team TEAM_NAME delete CHANNEL_TYPE #CHANNEL`
|
510
|
+
# help: `update team TEAM_NAME delete @USER`
|
511
|
+
# help: `update team TEAM_NAME delete #CHANNEL`
|
512
|
+
# help: It will update a team with the info supplied.
|
513
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to update a team.
|
514
|
+
# help: Examples:
|
515
|
+
# help: _update team sales salesff_
|
516
|
+
# help: _update team salesff : Support for customers_
|
517
|
+
# help: _update sales team delete @sarah @peter_
|
518
|
+
# help: _update team sales delete public #sales_
|
519
|
+
# help: _update team sales delete #sales_support_
|
520
|
+
# help: _update sales team add public #salesff_
|
521
|
+
# help: _update sales team add qa @john @ben @ana_
|
522
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
523
|
+
# help: command_id: :update_team
|
524
|
+
# help:
|
525
|
+
when /\A\s*update\s+team\s+([\w\-]+)\s+([\w\-]+)\s*\z/i, /\A\s*update\s+([\w\-]+)\s+team\s+([\w\-]+)\s*\z/i
|
526
|
+
name = $1.downcase
|
527
|
+
new_name = $2.downcase
|
528
|
+
update_team(user, name, new_name: new_name)
|
529
|
+
when /\A\s*update\s+team\s+([\w\-]+)\s*:\s+(.+)\s*\z/im, /\A\s*update\s+([\w\-]+)\s+team\s*:\s+(.+)\s*\z/im
|
530
|
+
name = $1.downcase
|
531
|
+
new_info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
532
|
+
update_team(user, name, new_info: new_info)
|
533
|
+
when /\A\s*update\s+team\s+([\w\-]+)\s+(delete|remove)\s+(.+)\s*\z/i, /\A\s*update\s+([\w\-]+)\s+team\s+(delete|remove)\s+(.+)\s*\z/i
|
534
|
+
name = $1.downcase
|
535
|
+
delete_opts = $3
|
536
|
+
update_team(user, name, delete_opts: delete_opts)
|
537
|
+
when /\A\s*update\s+team\s+([\w\-]+)\s+add\s+(.+)\s*\z/i, /\A\s*update\s+([\w\-]+)\s+team\s+add\s+(.+)\s*\z/i
|
538
|
+
name = $1.downcase
|
539
|
+
add_opts = $2
|
540
|
+
update_team(user, name, add_opts: add_opts)
|
541
|
+
|
542
|
+
# help: ----------------------------------------------
|
543
|
+
# help: `ping team TEAM_NAME MEMBER_TYPE MESSAGE`
|
544
|
+
# help: `contact team TEAM_NAME MEMBER_TYPE MESSAGE`
|
545
|
+
# help: ping: It will send the MESSAGE naming all available members of the MEMBER_TYPE supplied.
|
546
|
+
# help: contact: It will send the MESSAGE naming all members of the MEMBER_TYPE supplied.
|
547
|
+
# help: In case MEMBER_TYPE is 'all' it will name 10 random members of the team
|
548
|
+
# help: Examples:
|
549
|
+
# help: _ping team sales development How is the status on the last feature_
|
550
|
+
# help: _contact team sales qa Please finish testing of dev02 feature before noon_
|
551
|
+
# help: _contact team qa all Check the test failures please_
|
552
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
553
|
+
# help: command_id: :ping_team
|
554
|
+
# help: command_id: :contact_team
|
555
|
+
# help:
|
556
|
+
when /\A\s*(contact|ping)\s+team\s+([\w\-]+)\s+([\w\-]+)\s+(.+)\s*\z/im, /\A\s*(contact|ping)\s+([\w\-]+)\s+team\s+([\w\-]+)\s+(.+)\s*\z/im
|
557
|
+
type = $1.downcase.to_sym
|
558
|
+
name = $2.downcase
|
559
|
+
member_type = $3.downcase
|
560
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[^\s]+\s*\w+\s+team\s+[\w\-]+\s+[\w\-]+\s+(.+)\s*\z/im).join
|
561
|
+
if message == ''
|
562
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[^\s]+\s*\w+\s+[\w\-]+\s+team\s+[\w\-]+\s+(.+)\s*\z/im).join
|
563
|
+
end
|
564
|
+
ping_team(user, type, name, member_type, message)
|
565
|
+
|
566
|
+
# help: ----------------------------------------------
|
567
|
+
# help: `delete team TEAM_NAME`
|
568
|
+
# help: It will delete the supplied team.
|
569
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a team.
|
570
|
+
# help: Examples:
|
571
|
+
# help: _delete team sales_
|
572
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
573
|
+
# help: command_id: :delete_team
|
574
|
+
# help:
|
575
|
+
when /\A\s*(delete|remove)\s+team\s+([\w\-]+)\s*\z/i, /\A\s*(delete|remove)\s+([\w\-]+)\s+team\s*\z/i
|
576
|
+
name = $2.downcase
|
577
|
+
delete_team(user, name)
|
578
|
+
|
579
|
+
|
580
|
+
# help: ----------------------------------------------
|
581
|
+
# help: `add vacation from YYYY/MM/DD to YYYY/MM/DD`
|
582
|
+
# help: `add vacation YYYY/MM/DD`
|
583
|
+
# help: `add sick from YYYY/MM/DD to YYYY/MM/DD`
|
584
|
+
# help: `add sick YYYY/MM/DD`
|
585
|
+
# help: `add sick child YYYY/MM/DD`
|
586
|
+
# help: It will add the supplied period to your plan.
|
587
|
+
# help: Instead of YYYY/MM/DD you can use 'today' or 'tomorrow' or 'next week'
|
588
|
+
# help: To see your plan call `see my time off`
|
589
|
+
# help: If you want to see the vacation plan for the team `see team NAME`
|
590
|
+
# help: Also you can see the vacation plan for the team for a specific period: `vacations team NAME YYYY/MM/DD`
|
591
|
+
# help: The SmartBot will automatically set the users status to :palm_tree:, :baby: or :face_with_thermometer: and the expiration date.
|
592
|
+
# help: Examples:
|
593
|
+
# help: _add vacation from 2022/10/01 to 2022/10/22_
|
594
|
+
# help: _add sick 2022/08/22_
|
595
|
+
# help: _add vacation tomorrow_
|
596
|
+
# help: _add sick baby today_
|
597
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
598
|
+
# help: command_id: :add_vacation
|
599
|
+
# help:
|
600
|
+
when /\A\s*add\s+(sick|vacation|sick\s+baby|sick\s+child)\s+from\s+(\d\d\d\d\/\d\d\/\d\d)\s+to\s+(\d\d\d\d\/\d\d\/\d\d)\s*\z/i,
|
601
|
+
/\A\s*add\s+(sick|vacation|sick\s+baby|sick\s+child)\s+from\s+(\d\d\d\d-\d\d-\d\d)\s+to\s+(\d\d\d\d-\d\d-\d\d)\s*\z/i,
|
602
|
+
/\A\s*add\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d-\d\d-\d\d)()\s*\z/i,
|
603
|
+
/\A\s*add\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d\/\d\d\/\d\d)()\s*\z/i,
|
604
|
+
/\A\s*add\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(today|tomorrow|next\sweek)()\s*\z/i
|
605
|
+
type = $1
|
606
|
+
from = $2.downcase
|
607
|
+
to = $3
|
608
|
+
add_vacation(user, type, from, to)
|
609
|
+
|
610
|
+
# help: ----------------------------------------------
|
611
|
+
# help: `remove vacation ID`
|
612
|
+
# help: `remove vacation period ID`
|
613
|
+
# help: `remove sick period ID`
|
614
|
+
# help: `remove time off period ID`
|
615
|
+
# help: `delete vacation ID`
|
616
|
+
# help: It will remove the specified period from your vacations/sick periods.
|
617
|
+
# help: Examples:
|
618
|
+
# help: _remove vacation 20_
|
619
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
620
|
+
# help: command_id: :remove_vacation
|
621
|
+
# help:
|
622
|
+
when /\A\s*(delete|remove)\s+(vacation|sick|time\s+off)(\s+period)?\s+(\d+)\s*\z/i
|
623
|
+
vacation_id = $4
|
624
|
+
remove_vacation(user, vacation_id)
|
625
|
+
|
626
|
+
# help: ----------------------------------------------
|
627
|
+
# help: `see my vacations`
|
628
|
+
# help: `see my time off`
|
629
|
+
# help: `see vacations @USER`
|
630
|
+
# help: It will display current and past time off.
|
631
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
632
|
+
# help: command_id: :see_vacations
|
633
|
+
# help:
|
634
|
+
when /\A\s*see\s+my\s+vacations\s*()\z/i,
|
635
|
+
/\A\s*see\s+my\s+time\s+off\s*()\z/i,
|
636
|
+
/\A\s*see\s+time\s+off\s+<@(\w+)>\s*\z/i,
|
637
|
+
/\A\s*see\s+vacations\s+<@(\w+)>\s*\z/i
|
638
|
+
from_user = $1
|
639
|
+
see_vacations(user, from_user: from_user)
|
640
|
+
|
641
|
+
# help: ----------------------------------------------
|
642
|
+
# help: `vacations team NAME`
|
643
|
+
# help: `time off team NAME`
|
644
|
+
# help: `vacations team NAME YYYY/MM/DD`
|
645
|
+
# help: `time off team NAME YYYY/MM/DD`
|
646
|
+
# help: It will display the time off plan for the team specified.
|
647
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
648
|
+
# help: command_id: :see_vacations_team
|
649
|
+
# help:
|
650
|
+
when /\A\s*(see\s+)?(vacations|time\s+off)\s+team\s+([\w\-]+)\s*(\d\d\d\d\/\d\d\/\d\d)?\s*\z/i,
|
651
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+([\w\-]+)\s+team\s*(\d\d\d\d\/\d\d\/\d\d)?\s*\z/i,
|
652
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+team\s+([\w\-]+)\s*(\d\d\d\d-\d\d-\d\d)?\s*\z/i,
|
653
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+([\w\-]+)\s+team\s*(\d\d\d\d-\d\d-\d\d)?\s*\z/i
|
654
|
+
team_name = $3.downcase
|
655
|
+
date = $4.to_s
|
656
|
+
date = Date.today.strftime("%Y/%m/%d") if date.empty?
|
657
|
+
see_vacations_team(user, team_name, date)
|
658
|
+
|
230
659
|
else
|
231
660
|
return false
|
232
661
|
end
|
@@ -19,6 +19,7 @@ class SlackSmartBot
|
|
19
19
|
# help: _shortcut Spanish Account_
|
20
20
|
# help: _Spanish Account_
|
21
21
|
# help: <https://github.com/MarioRuiz/slack-smart-bot#shortcuts|more info>
|
22
|
+
# help: command_id: :add_shortcut
|
22
23
|
# help:
|
23
24
|
def add_shortcut(dest, user, typem, for_all, shortcut_name, command, command_to_run, global)
|
24
25
|
save_stats(__method__)
|
@@ -63,7 +64,7 @@ class SlackSmartBot
|
|
63
64
|
end
|
64
65
|
}
|
65
66
|
end
|
66
|
-
if !
|
67
|
+
if !is_admin?(from) and @shortcuts[:all].include?(shortcut_name) and !@shortcuts[from].include?(shortcut_name)
|
67
68
|
respond "Only the creator of the shortcut can modify it", dest
|
68
69
|
elsif found_other
|
69
70
|
respond "You cannot create a shortcut for all with the same name than other user is using", dest
|
@@ -35,11 +35,12 @@ class SlackSmartBot
|
|
35
35
|
# helpadmin: _add routine example on Tuesdays at 09:00 #SREChannel !run db cleanup_
|
36
36
|
# helpadmin: _add routine example on weekdays at 22:00 suggest command_
|
37
37
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
38
|
+
# helpadmin: command_id: :add_routine
|
38
39
|
# helpadmin:
|
39
40
|
def add_routine(dest, from, user, name, type, number_time, period, command_to_run, files, silent, channel, routine_type)
|
40
41
|
save_stats(__method__)
|
41
42
|
if files.nil? or files.size == 0 or (files.size > 0 and config.masters.include?(from))
|
42
|
-
if
|
43
|
+
if is_admin?
|
43
44
|
if @routines.key?(@channel_id) && @routines[@channel_id].key?(name)
|
44
45
|
respond "I'm sorry but there is already a routine with that name.\nCall `see routines` to see added routines", dest
|
45
46
|
else
|
@@ -5,13 +5,14 @@ class SlackSmartBot
|
|
5
5
|
# helpadmin: `use rules on CHANNEL_NAME`
|
6
6
|
# helpadmin: It will allow to use the specific rules from this channel on the CHANNEL_NAME
|
7
7
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#extending-rules-to-other-channels|more info>
|
8
|
+
# helpadmin: command_id: :extend_rules
|
8
9
|
# helpadmin:
|
9
10
|
def extend_rules(dest, user, from, channel, typem)
|
10
11
|
save_stats(__method__)
|
11
12
|
unless typem == :on_extended
|
12
13
|
if config.on_master_bot
|
13
14
|
respond "You cannot use the rules from Master Channel on any other channel.", dest
|
14
|
-
elsif !
|
15
|
+
elsif !is_admin? #not admin
|
15
16
|
respond "Only admins can extend the rules. Admins on this channel: #{config.admins}", dest
|
16
17
|
else
|
17
18
|
#todo: add pagination for case more than 1000 channels on the workspace
|
@@ -6,10 +6,11 @@ class SlackSmartBot
|
|
6
6
|
# helpadmin: the bot will pause so it will listen only to admin commands
|
7
7
|
# helpadmin: You can use this command only if you are an admin user
|
8
8
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
9
|
+
# helpadmin: command_id: :pause_bot
|
9
10
|
# helpadmin:
|
10
11
|
def pause_bot(dest, from)
|
11
12
|
save_stats(__method__)
|
12
|
-
if
|
13
|
+
if is_admin?
|
13
14
|
respond "This bot is paused from now on. You can start it again: start this bot", dest
|
14
15
|
respond "zZzzzzZzzzzZZZZZZzzzzzzzz", dest
|
15
16
|
@status = :paused
|
@@ -7,10 +7,11 @@ class SlackSmartBot
|
|
7
7
|
# helpadmin: Examples:
|
8
8
|
# helpadmin: _pause routine example_
|
9
9
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
10
|
+
# helpadmin: command_id: :pause_routine
|
10
11
|
# helpadmin:
|
11
12
|
def pause_routine(dest, from, name)
|
12
13
|
save_stats(__method__)
|
13
|
-
if
|
14
|
+
if is_admin?
|
14
15
|
if !config.on_master_bot and dest[0] == "D"
|
15
16
|
respond "It's only possible to pause routines from MASTER channel from a direct message with the bot.", dest
|
16
17
|
elsif @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
|
@@ -10,10 +10,11 @@ class SlackSmartBot
|
|
10
10
|
# helpadmin: Examples:
|
11
11
|
# helpadmin: _kill routine example_
|
12
12
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
13
|
+
# helpadmin: command_id: :remove_routine
|
13
14
|
# helpadmin:
|
14
15
|
def remove_routine(dest, from, name)
|
15
16
|
save_stats(__method__)
|
16
|
-
if
|
17
|
+
if is_admin?
|
17
18
|
if @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
|
18
19
|
@routines[@channel_id][name][:thread].exit
|
19
20
|
@routines[@channel_id].delete(name)
|