slack-smart-bot 1.10.0 → 1.11.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 +91 -21
- 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 +18 -13
- data/lib/slack/smart-bot/comm/send_msg_user.rb +12 -11
- data/lib/slack/smart-bot/comm.rb +2 -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_team.rb +80 -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_share.rb +1 -1
- data/lib/slack/smart-bot/commands/general/delete_team.rb +34 -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/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 +6 -4
- 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 +252 -0
- data/lib/slack/smart-bot/commands/general/share_messages.rb +1 -1
- data/lib/slack/smart-bot/commands/general/update_team.rb +109 -0
- data/lib/slack/smart-bot/commands/general_bot_commands.rb +271 -10
- 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 +400 -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/repl.rb +72 -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 +11 -2
- 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 +3 -2
- 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 +22 -7
- data/lib/slack/smart-bot/listen.rb +30 -30
- data/lib/slack/smart-bot/process.rb +38 -18
- data/lib/slack/smart-bot/process_first.rb +2 -2
- data/lib/slack/smart-bot/treat_message.rb +13 -17
- data/lib/slack/smart-bot/utils/build_help.rb +1 -1
- 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 +13 -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 +34 -18
- 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/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 +46 -43
- data/lib/slack/smart-bot/utils/save_status.rb +21 -6
- data/lib/slack/smart-bot/utils/update_access_channels.rb +8 -0
- data/lib/slack/smart-bot/utils/update_admins_channels.rb +8 -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.rb +8 -0
- data/lib/slack-smart-bot.rb +28 -10
- data/lib/slack-smart-bot_general_commands.rb +16 -1
- data/whats_new.txt +16 -29
- metadata +64 -19
- 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,6 +73,7 @@ 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
79
|
/\A\s*(add|create)\s+(:\w+:)\s+(announcement|statement|declaration|message)\s+(.+)\s*\z/i
|
@@ -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
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
127
|
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:\w+:\s+)?(announcements|statements|declarations|messages)\s+#([\w\-]+)\s*\z/i,
|
122
|
-
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:\w+:\s+)?(announcements|statements|declarations|messages)\s+<#(
|
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,255 @@ 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: `see teams`
|
392
|
+
# help: `see team TEAM_NAME`
|
393
|
+
# help: `team TEAM_NAME`
|
394
|
+
# help: `TEAM_NAME team`
|
395
|
+
# help: `which team @USER`
|
396
|
+
# help: `which team #CHANNEL`
|
397
|
+
# help: `which team TEXT_TO_SEARCH_ON_INFO`
|
398
|
+
# help: `which team does @USER belongs to?`
|
399
|
+
# help: It will display all teams or the team specified.
|
400
|
+
# help: In case a specific team it will show also the availability of the members.
|
401
|
+
# help: Examples:
|
402
|
+
# help: _see teams_
|
403
|
+
# help: _see team Sales_
|
404
|
+
# help: _Dev team_
|
405
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
406
|
+
# help: command_id: :see_teams
|
407
|
+
# help:
|
408
|
+
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
|
409
|
+
name = $1.to_s.downcase
|
410
|
+
see_teams(user, name)
|
411
|
+
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
|
412
|
+
search = $3.to_s.downcase
|
413
|
+
see_teams(user, '', search)
|
414
|
+
|
415
|
+
# help: ----------------------------------------------
|
416
|
+
# help: `update team TEAM_NAME NEW_TEAM_NAME`
|
417
|
+
# help: `update team TEAM_NAME : NEW_INFO`
|
418
|
+
# help: `update team TEAM_NAME add MEMBER_TYPE @USER`
|
419
|
+
# help: `update team TEAM_NAME add CHANNEL_TYPE #CHANNEL`
|
420
|
+
# help: `update team TEAM_NAME delete MEMBER_TYPE @USER`
|
421
|
+
# help: `update team TEAM_NAME delete CHANNEL_TYPE #CHANNEL`
|
422
|
+
# help: `update team TEAM_NAME delete @USER`
|
423
|
+
# help: `update team TEAM_NAME delete #CHANNEL`
|
424
|
+
# help: It will update a team with the info supplied.
|
425
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to update a team.
|
426
|
+
# help: Examples:
|
427
|
+
# help: _update team sales salesff_
|
428
|
+
# help: _update team salesff : Support for customers_
|
429
|
+
# help: _update sales team delete @sarah @peter_
|
430
|
+
# help: _update team sales delete public #sales_
|
431
|
+
# help: _update team sales delete #sales_support_
|
432
|
+
# help: _update sales team add public #salesff_
|
433
|
+
# help: _update sales team add qa @john @ben @ana_
|
434
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
435
|
+
# help: command_id: :update_team
|
436
|
+
# help:
|
437
|
+
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
|
438
|
+
name = $1.downcase
|
439
|
+
new_name = $2.downcase
|
440
|
+
update_team(user, name, new_name: new_name)
|
441
|
+
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
|
442
|
+
name = $1.downcase
|
443
|
+
new_info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
444
|
+
update_team(user, name, new_info: new_info)
|
445
|
+
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
|
446
|
+
name = $1.downcase
|
447
|
+
delete_opts = $3
|
448
|
+
update_team(user, name, delete_opts: delete_opts)
|
449
|
+
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
|
450
|
+
name = $1.downcase
|
451
|
+
add_opts = $2
|
452
|
+
update_team(user, name, add_opts: add_opts)
|
453
|
+
|
454
|
+
# help: ----------------------------------------------
|
455
|
+
# help: `ping team TEAM_NAME MEMBER_TYPE MESSAGE`
|
456
|
+
# help: `contact team TEAM_NAME MEMBER_TYPE MESSAGE`
|
457
|
+
# help: ping: It will send the MESSAGE naming all available members of the MEMBER_TYPE supplied.
|
458
|
+
# help: contact: It will send the MESSAGE naming all members of the MEMBER_TYPE supplied.
|
459
|
+
# help: In case MEMBER_TYPE is 'all' it will name 10 random members of the team
|
460
|
+
# help: Examples:
|
461
|
+
# help: _ping team sales development How is the status on the last feature_
|
462
|
+
# help: _contact team sales qa Please finish testing of dev02 feature before noon_
|
463
|
+
# help: _contact team qa all Check the test failures please_
|
464
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
465
|
+
# help: command_id: :ping_team
|
466
|
+
# help: command_id: :contact_team
|
467
|
+
# help:
|
468
|
+
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
|
469
|
+
type = $1.downcase.to_sym
|
470
|
+
name = $2.downcase
|
471
|
+
member_type = $3.downcase
|
472
|
+
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
|
473
|
+
if message == ''
|
474
|
+
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
|
475
|
+
end
|
476
|
+
ping_team(user, type, name, member_type, message)
|
477
|
+
|
478
|
+
# help: ----------------------------------------------
|
479
|
+
# help: `delete team TEAM_NAME`
|
480
|
+
# help: It will delete the supplied team.
|
481
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a team.
|
482
|
+
# help: Examples:
|
483
|
+
# help: _delete team sales_
|
484
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
485
|
+
# help: command_id: :delete_team
|
486
|
+
# help:
|
487
|
+
when /\A\s*(delete|remove)\s+team\s+([\w\-]+)\s*\z/i, /\A\s*(delete|remove)\s+([\w\-]+)\s+team\s*\z/i
|
488
|
+
name = $2.downcase
|
489
|
+
delete_team(user, name)
|
490
|
+
|
230
491
|
else
|
231
492
|
return false
|
232
493
|
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)
|
@@ -9,15 +9,16 @@ class SlackSmartBot
|
|
9
9
|
# helpadmin: Examples:
|
10
10
|
# helpadmin: _run routine example_
|
11
11
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
12
|
+
# helpadmin: command_id: :run_routine
|
12
13
|
# helpadmin:
|
13
14
|
|
14
15
|
def run_routine(dest, from, name)
|
15
16
|
save_stats(__method__)
|
16
|
-
if
|
17
|
+
if is_admin?
|
17
18
|
if !config.on_master_bot and dest[0] == "D"
|
18
19
|
respond "It's only possible to run routines from MASTER channel from a direct message with the bot.", dest
|
19
20
|
elsif @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
|
20
|
-
File.delete "#{config.path}/routines/#{@channel_id}/#{name}_output.txt" if File.
|
21
|
+
File.delete "#{config.path}/routines/#{@channel_id}/#{name}_output.txt" if File.exist?("#{config.path}/routines/#{@channel_id}/#{name}_output.txt")
|
21
22
|
if @routines[@channel_id][name][:file_path] != ""
|
22
23
|
if @routines[@channel_id][name][:file_path].match?(/\.rb$/i)
|
23
24
|
ruby = "ruby "
|
@@ -10,10 +10,11 @@ class SlackSmartBot
|
|
10
10
|
# helpadmin: Examples:
|
11
11
|
# helpadmin: _see routine result example_
|
12
12
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
13
|
+
# helpadmin: command_id: :see_result_routine
|
13
14
|
# helpadmin:
|
14
15
|
def see_result_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
|
if File.exist?("#{config.path}/routines/#{@channel_id}/#{name}_output.txt")
|
19
20
|
msg = "*Results from routine run #{File.mtime("#{config.path}/routines/#{@channel_id}/#{name}_output.txt")}*\n"
|
@@ -6,29 +6,30 @@ class SlackSmartBot
|
|
6
6
|
# helpadmin: In case of `all` and on the master channel, it will show all the routines from all channels
|
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#routines|more info>
|
9
|
+
# helpadmin: command_id: :see_routines
|
9
10
|
# helpadmin:
|
10
11
|
def see_routines(dest, from, user, all)
|
11
12
|
save_stats(__method__)
|
12
|
-
if
|
13
|
+
if is_admin?
|
13
14
|
if all
|
14
15
|
routines = {}
|
15
16
|
if config.on_master_bot
|
16
|
-
Dir["#{config.path}/routines/routines_*.
|
17
|
-
|
18
|
-
unless
|
19
|
-
routines.merge!(
|
17
|
+
Dir["#{config.path}/routines/routines_*.yaml"].each do |rout|
|
18
|
+
routine = YAML.load(File.read(rout))
|
19
|
+
unless routine.is_a?(FalseClass)
|
20
|
+
routines.merge!(routine)
|
20
21
|
end
|
21
22
|
end
|
22
23
|
else
|
23
24
|
respond "To see all routines on all channels you need to run the command on the master channel.\nI'll display only the routines on this channel.", dest
|
24
|
-
routines = @routines
|
25
|
+
routines = @routines
|
25
26
|
end
|
26
27
|
else
|
27
28
|
if @rules_imported.key?(user.name) and @rules_imported[user.name].key?(user.name) and dest[0] == "D"
|
28
|
-
|
29
|
-
routines =
|
29
|
+
routines = YAML.load(File.read("#{config.path}/routines/routines_#{@rules_imported[user.name][user.name]}.yaml"))
|
30
|
+
routines = {} if routines.is_a?(FalseClass)
|
30
31
|
else
|
31
|
-
routines = @routines
|
32
|
+
routines = @routines
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -6,10 +6,11 @@ class SlackSmartBot
|
|
6
6
|
# helpadmin: the bot will start to listen
|
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: :start_bot
|
9
10
|
# helpadmin:
|
10
11
|
def start_bot(dest, from)
|
11
12
|
save_stats(__method__)
|
12
|
-
if
|
13
|
+
if is_admin?
|
13
14
|
respond "This bot is running and listening from now on. You can pause again: pause this bot", dest
|
14
15
|
@status = :on
|
15
16
|
unless config.on_master_bot
|
@@ -8,11 +8,12 @@ class SlackSmartBot
|
|
8
8
|
# helpadmin: Examples:
|
9
9
|
# helpadmin: _start routine example_
|
10
10
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#routines|more info>
|
11
|
+
# helpadmin: command_id: :start_routine
|
11
12
|
# helpadmin:
|
12
13
|
|
13
14
|
def start_routine(dest, from, name)
|
14
15
|
save_stats(__method__)
|
15
|
-
if
|
16
|
+
if is_admin?
|
16
17
|
if !config.on_master_bot and dest[0] == "D"
|
17
18
|
respond "It's only possible to start routines from MASTER channel from a direct message with the bot.", dest
|
18
19
|
elsif @routines.key?(@channel_id) and @routines[@channel_id].key?(name)
|
@@ -4,12 +4,13 @@ class SlackSmartBot
|
|
4
4
|
# helpadmin: `stop using rules on CHANNEL_NAME`
|
5
5
|
# helpadmin: it will stop using the extended rules on the specified channel.
|
6
6
|
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#extending-rules-to-other-channels|more info>
|
7
|
+
# helpadmin: command_id: :stop_using_rules_on
|
7
8
|
# helpadmin:
|
8
9
|
|
9
10
|
def stop_using_rules_on(dest, user, from, channel, typem)
|
10
11
|
save_stats(__method__)
|
11
12
|
unless typem == :on_extended
|
12
|
-
if !
|
13
|
+
if !is_admin?
|
13
14
|
respond "Only admins can extend or stop using the rules. Admins on this channel: #{config.admins}", dest
|
14
15
|
else
|
15
16
|
get_bots_created()
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class SlackSmartBot
|
2
|
+
|
3
|
+
# helpadmin: ----------------------------------------------
|
4
|
+
# helpadmin: `delete message URL`
|
5
|
+
# helpadmin: It will delete the SmartBot message supplied
|
6
|
+
# 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
|
7
|
+
# helpadmin: command_id: :delete_message
|
8
|
+
# helpadmin:
|
9
|
+
def delete_message(from, typem, url)
|
10
|
+
save_stats(__method__)
|
11
|
+
channel, ts = url.scan(/\/archives\/(\w+)\/(\w\d+)/)[0]
|
12
|
+
if config.masters.include?(from) and typem==:on_dm and !channel.nil? #master admin user
|
13
|
+
ts = "#{ts[0..-7]}.#{ts[-6..-1]}"
|
14
|
+
succ = delete(channel, ts)
|
15
|
+
if succ
|
16
|
+
react :heavy_check_mark
|
17
|
+
else
|
18
|
+
react :x
|
19
|
+
end
|
20
|
+
else
|
21
|
+
respond "Only master admin users on a private conversation with the SmartBot can delete SmartBot messages"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -4,6 +4,7 @@ class SlackSmartBot
|
|
4
4
|
# helpadmin: `get bot logs`
|
5
5
|
# helpadmin: To see the bot logs
|
6
6
|
# 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
|
7
|
+
# helpadmin: command_id: :get_bot_logs
|
7
8
|
# helpadmin:
|
8
9
|
def get_bot_logs(dest, from, typem)
|
9
10
|
save_stats(__method__)
|