slack-smart-bot 1.13.1 → 1.14.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 +100 -4
- data/lib/slack/smart-bot/ai/open_ai/connect.rb +61 -0
- data/lib/slack/smart-bot/ai/open_ai/models.rb +21 -0
- data/lib/slack/smart-bot/ai/open_ai/send_gpt_chat.rb +24 -0
- data/lib/slack/smart-bot/ai/open_ai/send_image_edit.rb +23 -0
- data/lib/slack/smart-bot/ai/open_ai/send_image_generation.rb +18 -0
- data/lib/slack/smart-bot/ai/open_ai/send_image_variation.rb +22 -0
- data/lib/slack/smart-bot/ai/open_ai/whisper_transcribe.rb +21 -0
- data/lib/slack/smart-bot/ai.rb +8 -0
- data/lib/slack/smart-bot/comm/get_channel_members.rb +15 -13
- data/lib/slack/smart-bot/comm/get_channels.rb +31 -29
- data/lib/slack/smart-bot/comm/respond_thread.rb +2 -2
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_chat.rb +40 -0
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_edit_image.rb +66 -0
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_generate_image.rb +65 -0
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_models.rb +37 -0
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_variations_image.rb +84 -0
- data/lib/slack/smart-bot/commands/general/ai/open_ai/open_ai_whisper.rb +51 -0
- data/lib/slack/smart-bot/commands/general/bot_help.rb +1 -0
- data/lib/slack/smart-bot/commands/general/personal_settings.rb +38 -0
- data/lib/slack/smart-bot/commands/general/poster.rb +107 -104
- data/lib/slack/smart-bot/commands/general/public_holidays.rb +116 -114
- data/lib/slack/smart-bot/commands/general/set_public_holidays.rb +6 -2
- data/lib/slack/smart-bot/commands/general/teams/add_team.rb +87 -0
- data/lib/slack/smart-bot/commands/general/teams/delete_team.rb +69 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team.rb +136 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/add_memo_team_comment.rb +37 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/delete_memo_team.rb +83 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/see_memo_team.rb +97 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/see_memos_team.rb +304 -0
- data/lib/slack/smart-bot/commands/general/teams/memos/set_memo_status.rb +66 -0
- data/lib/slack/smart-bot/commands/general/teams/ping_team.rb +104 -0
- data/lib/slack/smart-bot/commands/general/teams/see_teams.rb +236 -0
- data/lib/slack/smart-bot/commands/general/teams/see_vacations_team.rb +183 -0
- data/lib/slack/smart-bot/commands/general/teams/update_team.rb +137 -0
- data/lib/slack/smart-bot/commands/general_bot_commands.rb +905 -741
- data/lib/slack/smart-bot/commands/on_bot/general/bot_stats.rb +379 -353
- data/lib/slack/smart-bot/commands/on_bot/repl.rb +87 -189
- data/lib/slack/smart-bot/commands/on_bot/repl_client.rb +233 -0
- data/lib/slack/smart-bot/commands/on_master/admin_master/exit_bot.rb +17 -4
- data/lib/slack/smart-bot/commands.rb +26 -10
- data/lib/slack/smart-bot/process.rb +14 -3
- data/lib/slack/smart-bot/process_first.rb +36 -2
- data/lib/slack/smart-bot/treat_message.rb +28 -0
- data/lib/slack/smart-bot/utils/check_vacations.rb +1 -0
- data/lib/slack/smart-bot/utils/create_routine_thread.rb +1 -1
- data/lib/slack/smart-bot/utils/display_calendar.rb +17 -10
- data/lib/slack/smart-bot/utils/encryption/decrypt.rb +23 -0
- data/lib/slack/smart-bot/utils/encryption/encrypt.rb +27 -0
- data/lib/slack/smart-bot/utils/{encryption_get_key_iv.rb → encryption/encryption_get_key_iv.rb} +12 -8
- data/lib/slack/smart-bot/utils/get_help.rb +3 -1
- data/lib/slack/smart-bot/utils/get_personal_settings.rb +14 -0
- data/lib/slack/smart-bot/utils/get_teams.rb +2 -2
- data/lib/slack/smart-bot/utils/get_vacations.rb +2 -2
- data/lib/slack/smart-bot/utils/save_stats.rb +3 -1
- data/lib/slack/smart-bot/utils/update_personal_settings.rb +18 -0
- data/lib/slack/smart-bot/utils/update_teams.rb +1 -1
- data/lib/slack/smart-bot/utils/update_vacations.rb +1 -1
- data/lib/slack/smart-bot/utils.rb +5 -3
- data/lib/slack-smart-bot.rb +12 -0
- data/whats_new.txt +13 -14
- metadata +63 -15
- data/lib/slack/smart-bot/commands/general/add_memo_team.rb +0 -117
- data/lib/slack/smart-bot/commands/general/add_team.rb +0 -81
- data/lib/slack/smart-bot/commands/general/delete_memo_team.rb +0 -69
- data/lib/slack/smart-bot/commands/general/delete_team.rb +0 -55
- data/lib/slack/smart-bot/commands/general/ping_team.rb +0 -100
- data/lib/slack/smart-bot/commands/general/see_memos_team.rb +0 -202
- data/lib/slack/smart-bot/commands/general/see_teams.rb +0 -230
- data/lib/slack/smart-bot/commands/general/see_vacations_team.rb +0 -136
- data/lib/slack/smart-bot/commands/general/set_memo_status.rb +0 -58
- data/lib/slack/smart-bot/commands/general/update_team.rb +0 -131
- data/lib/slack/smart-bot/utils/decrypt.rb +0 -15
- data/lib/slack/smart-bot/utils/encrypt.rb +0 -15
@@ -1,768 +1,932 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
case command
|
14
|
-
# help: ----------------------------------------------
|
15
|
-
# help: `bot help`
|
16
|
-
# help: `bot help COMMAND`
|
17
|
-
# help: `bot rules`
|
18
|
-
# help: `bot rules COMMAND`
|
19
|
-
# help: `bot help expanded`
|
20
|
-
# help: `bot rules expanded`
|
21
|
-
# help: `bot what can I do?`
|
22
|
-
# help: it will display this help. For a more detailed help call `bot help expanded` or `bot rules expanded`.
|
23
|
-
# help: if COMMAND supplied just help for that command
|
24
|
-
# help: you can use the option 'expanded' or the alias 'extended'
|
25
|
-
# help: `bot rules` will show only the specific rules for this channel.
|
26
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-help|more info>
|
27
|
-
# help: command_id: :bot_help
|
28
|
-
# help:
|
29
|
-
|
30
|
-
# help: ----------------------------------------------
|
31
|
-
# help: `for NUMBER times every NUMBER minutes COMMAND`
|
32
|
-
# help: `for NUMBER times every NUMBER seconds COMMAND`
|
33
|
-
# help: `NUMBER times every NUMBER minutes COMMAND`
|
34
|
-
# help: `NUMBER times every NUMBER seconds COMMAND`
|
35
|
-
# help: It will run the command every NUMBER minutes or seconds for NUMBER times.
|
36
|
-
# help: max 24 times. min every 10 seconds. max every 60 minutes.
|
37
|
-
# help: Call `quit loop LOOP_ID` to stop the loop.
|
38
|
-
# help: aliases for minutes: m, minute, minutes
|
39
|
-
# help: aliases for seconds: s, sc, second, seconds
|
40
|
-
# help: Examples:
|
41
|
-
# help: _for 5 times every 1 minute ^ruby puts Time.now_
|
42
|
-
# help: _10 times every 30s !ruby puts Time.now_
|
43
|
-
# help: _24 times every 60m !get sales today_
|
44
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#loops|more info>
|
45
|
-
# help: command_id: :create_loop
|
46
|
-
# help:
|
47
|
-
|
48
|
-
# help: ----------------------------------------------
|
49
|
-
# help: `quit loop LOOP_ID`
|
50
|
-
# help: It will stop the loop with the id LOOP_ID.
|
51
|
-
# help: Only the user who created the loop or an admin can stop it.
|
52
|
-
# help: aliases for loop: iterator, iteration
|
53
|
-
# help: aliases for quit: stop, exit, kill
|
54
|
-
# help: Examples:
|
55
|
-
# help: _quit loop 1_
|
56
|
-
# help: _stop iterator 12_
|
57
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#loops|more info>
|
58
|
-
# help: command_id: :quit_loop
|
59
|
-
|
60
|
-
# help: ----------------------------------------------
|
61
|
-
# help: `Hi Bot`
|
62
|
-
# help: `Hi Smart`
|
63
|
-
# help: `Hello Bot` `Hola Bot` `Hallo Bot` `What's up Bot` `Hey Bot` `Hæ Bot`
|
64
|
-
# help: `Hello THE_NAME_OF_THE_BOT`
|
65
|
-
# help: Bot starts listening to you if you are on a Bot channel
|
66
|
-
# help: After that if you want to avoid a single message to be treated by the smart bot, start the message by -
|
67
|
-
# help: Also apart of Hello you can use _Hallo, Hi, Hola, What's up, Hey, Hæ_
|
68
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
69
|
-
# help: command_id: :hi_bot
|
70
|
-
# help:
|
71
|
-
when /\A\s*(Hello|Hallo|Hi|Hola|What's\sup|Hey|Hæ)\s+(#{@salutations.join("|")})\s*$/i
|
72
|
-
hi_bot(user, dest, user.name, display_name)
|
73
|
-
|
74
|
-
# help: ----------------------------------------------
|
75
|
-
# help: `Bye Bot`
|
76
|
-
# help: `Bye Smart`
|
77
|
-
# help: `Bye NAME_OF_THE_BOT`
|
78
|
-
# help: Bot stops listening to you if you are on a Bot channel
|
79
|
-
# help: Also apart of Bye you can use _Bæ, Good Bye, Adiós, Ciao, Bless, Bless Bless, Adeu_
|
80
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
81
|
-
# help: command_id: :bye_bot
|
82
|
-
# help:
|
83
|
-
when /\A\s*(Bye|Bæ|Good\s+Bye|Adiós|Ciao|Bless|Bless\sBless|Adeu)\s+(#{@salutations.join("|")})\s*$/i
|
84
|
-
bye_bot(dest, user.name, display_name)
|
85
|
-
|
86
|
-
# help: ----------------------------------------------
|
87
|
-
# help: `add announcement MESSAGE`
|
88
|
-
# help: `add red announcement MESSAGE`
|
89
|
-
# help: `add green announcement MESSAGE`
|
90
|
-
# help: `add yellow announcement MESSAGE`
|
91
|
-
# help: `add white announcement MESSAGE`
|
92
|
-
# help: `add EMOJI announcement MESSAGE`
|
93
|
-
# help: It will store the message on the announcement list labeled with the color or emoji specified, white by default.
|
94
|
-
# help: aliases for announcement: statement, declaration, message
|
95
|
-
# help: Examples:
|
96
|
-
# help: _add green announcement :heavy_check_mark: All customer services are up and running_
|
97
|
-
# help: _add red declaration Customers db is down :x:_
|
98
|
-
# help: _add yellow statement Don't access the linux server without VPN_
|
99
|
-
# help: _add message `*Party* will start at *20:00* :tada:`_
|
100
|
-
# help: _add :heavy_exclamation_mark: message Pay attention all DB are on maintenance until 20:00 GMT_
|
101
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
102
|
-
# help: command_id: :add_announcement
|
103
|
-
# help:
|
104
|
-
when /\A\s*(add|create)\s+(red\s+|green\s+|white\s+|yellow\s+)?(announcement|statement|declaration|message)\s+(.+)\s*\z/i,
|
105
|
-
/\A\s*(add|create)\s+(:[\w\-]+:)\s+(announcement|statement|declaration|message)\s+(.+)\s*\z/i
|
106
|
-
type = $2.to_s.downcase.strip
|
107
|
-
type = 'white' if type == ''
|
108
|
-
message = $4
|
109
|
-
add_announcement(user, type, message)
|
110
|
-
|
111
|
-
|
112
|
-
# help: ----------------------------------------------
|
113
|
-
# help: `delete announcement ID`
|
114
|
-
# help: It will delete the message on the announcement list.
|
115
|
-
# help: aliases for announcement: statement, declaration, message
|
116
|
-
# help: Examples:
|
117
|
-
# help: _delete announcement 24_
|
118
|
-
# help: _delete message 645_
|
119
|
-
# help: _delete statement 77_
|
120
|
-
# help: _delete declaration 334_
|
121
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
122
|
-
# help: command_id: :delete_announcement
|
123
|
-
# help:
|
124
|
-
when /\A\s*(delete|remove)\s+(announcement|statement|declaration|message)\s+(\d+)\s*\z/i
|
125
|
-
message_id = $3
|
126
|
-
delete_announcement(user, message_id)
|
127
|
-
|
128
|
-
# help: ----------------------------------------------
|
129
|
-
# help: `see announcements`
|
130
|
-
# help: `see red announcements`
|
131
|
-
# help: `see green announcements`
|
132
|
-
# help: `see yellow announcements`
|
133
|
-
# help: `see white announcements`
|
134
|
-
# help: `see EMOJI announcements`
|
135
|
-
# helpmaster: `see announcements #CHANNEL`
|
136
|
-
# helpmaster: `see all announcements`
|
137
|
-
# help: It will display the announcements for the channel.
|
138
|
-
# help: aliases for announcements: statements, declarations, messages
|
139
|
-
# helpmaster: In case #CHANNEL it will display the announcements for that channel. Only master admins can use it from a DM with the Smartbot.
|
140
|
-
# helpmaster: In case 'all' it will display all the announcements for all channels. Only master admins can use it from a DM with the Smartbot.
|
141
|
-
# help: Examples:
|
142
|
-
# help: _see announcements_
|
143
|
-
# help: _see white messages_
|
144
|
-
# help: _see red statements_
|
145
|
-
# help: _see yellow declarations_
|
146
|
-
# help: _see messages_
|
147
|
-
# help: _see :heavy_exclamation_mark: messages_
|
148
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
149
|
-
# help: command_id: :see_announcements
|
150
|
-
# help:
|
151
|
-
when /\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
152
|
-
/\A\s*see\s+(all\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
153
|
-
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+#([\w\-]+)\s*\z/i,
|
154
|
-
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+<#(\w+)\|.*>\s*\z/i
|
155
|
-
|
156
|
-
type = $1.to_s.downcase.strip
|
157
|
-
channel = $3.to_s
|
158
|
-
|
159
|
-
see_announcements(user, type, channel)
|
160
|
-
|
161
|
-
|
162
|
-
# help: ----------------------------------------------
|
163
|
-
# help: `share messages /REGEXP/ on #CHANNEL`
|
164
|
-
# help: `share messages "TEXT" on #CHANNEL`
|
165
|
-
# xhelp: `share messages :EMOJI: on #CHANNEL`
|
166
|
-
# help: It will automatically share new messages published that meet the specified criteria.
|
167
|
-
# xhelp: In case :EMOJI: it will share the messages with the indicated reaction.
|
168
|
-
# help: SmartBot user and user adding the share need to be members on both channels.
|
169
|
-
# help: The Regexp will automatically add the parameters /im
|
170
|
-
# help: Only available on public channels.
|
171
|
-
# help: Examples:
|
172
|
-
# help: _share messages /(last\s+|previous\s+)sales\s+results\s+/ on #sales_
|
173
|
-
# help: _share messages "share post" on #announcements_
|
174
|
-
# xhelp: _share messages :tada: on #announcements_
|
175
|
-
# xhelp: _share messages :moneybag: from #sales_
|
176
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
177
|
-
# help: command_id: :share_messages
|
178
|
-
# help:
|
179
|
-
when /\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#\w+\|(.+)>\s*\z/i,
|
180
|
-
/\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#(\w+)\|>\s*\z/,
|
181
|
-
/\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+(.+)\s*\z/i
|
182
|
-
condition = $1
|
183
|
-
channel = $2
|
184
|
-
channel.gsub!('#','') # for the case the channel name is in plain text including #
|
185
|
-
channel = @channels_name[channel] if @channels_name.key?(channel)
|
186
|
-
channel_from = @channels_name[dest]
|
187
|
-
channel_to = channel
|
188
|
-
share_messages(user, channel_from, channel_to, condition)
|
189
|
-
|
190
|
-
# help: ----------------------------------------------
|
191
|
-
# help: `see shares`
|
192
|
-
# help: It will display the active shares from this channel.
|
193
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
194
|
-
# help: command_id: :see_shares
|
195
|
-
# help:
|
196
|
-
when /\A\s*see\s+shares\s*\z/i
|
197
|
-
see_shares()
|
198
|
-
|
199
|
-
# help: ----------------------------------------------
|
200
|
-
# help: `delete share ID`
|
201
|
-
# help: It will delete the share id specified.
|
202
|
-
# help: Examples:
|
203
|
-
# help: _delete share 24_
|
204
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
205
|
-
# help: command_id: :delete_share
|
206
|
-
# help:
|
207
|
-
when /\A\s*(delete|remove)\s+share\s+(\d+)\s*\z/i
|
208
|
-
share_id = $2
|
209
|
-
delete_share(user, share_id)
|
210
|
-
|
211
|
-
# help: ----------------------------------------------
|
212
|
-
# help: `see statuses`
|
213
|
-
# help: `see statuses #CHANNEL`
|
214
|
-
# help: `see status EMOJI`
|
215
|
-
# help: `see status EMOJI #CHANNEL`
|
216
|
-
# help: `see status EMOJI1 EMOJI99`
|
217
|
-
# help: `who is on vacation?`
|
218
|
-
# help: `who is on EMOJI`
|
219
|
-
# help: `who is on EMOJI #CHANNEL`
|
220
|
-
# help: `who is on EMOJI1 EMOJI99`
|
221
|
-
# help: `who is not on vacation?`
|
222
|
-
# help: `who is not on EMOJI`
|
223
|
-
# help: `who is available?`
|
224
|
-
# 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.
|
225
|
-
# 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.
|
226
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-statuses|more info>
|
227
|
-
# help: command_id: :see_statuses
|
228
|
-
# help:
|
229
|
-
when /\A\s*(see|get)\s+(statuses)()\s*\z/i,
|
230
|
-
/\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,
|
231
|
-
/\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,
|
232
|
-
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??()\s*\z/i,
|
233
|
-
/\A\s*(see|get)\s+(statuses)\s+#([\w\-]+)\s*\z/i,
|
234
|
-
/\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,
|
235
|
-
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+#([\w\-]+)\s*\z/i,
|
236
|
-
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+<#(\w+)\|.*>\s*\z/i,
|
237
|
-
/\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,
|
238
|
-
/\A\s*(see|get)\s+(statuses)\s+<#(\w+)\|.*>\s*\z/i,
|
239
|
-
/\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,
|
240
|
-
/\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
|
241
|
-
|
242
|
-
not_on = $1.match?(/who\s+(is|are)\s+not\s+on/i)
|
243
|
-
type = $2.downcase
|
244
|
-
channel = $3.to_s
|
245
|
-
if type == 'statuses'
|
246
|
-
types = []
|
247
|
-
elsif type =='vacation' or type == 'holiday'
|
248
|
-
types = [':palm_tree:']
|
249
|
-
elsif type == 'available' or type == 'active'
|
250
|
-
types = ['available']
|
251
|
-
else
|
252
|
-
type.gsub!(' ', '')
|
253
|
-
type.gsub!('::',': :')
|
254
|
-
types = type.split(' ')
|
255
|
-
end
|
256
|
-
see_statuses(user, channel, types, dest, not_on)
|
257
|
-
|
258
|
-
|
259
|
-
# help: ----------------------------------------------
|
260
|
-
# help: `see favorite commands`
|
261
|
-
# help: `see my favorite commands`
|
262
|
-
# help: `favorite commands`
|
263
|
-
# help: `my favorite commands`
|
264
|
-
# help: It will display the favorite commands.
|
265
|
-
# help: aliases for favorite: favourite, most used, fav
|
266
|
-
# helpmaster: You need to set stats to true to generate the stats when running the bot instance and get this info.
|
267
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-favorite-commands|more info>
|
268
|
-
# help: command_id: :see_favorite_commands
|
269
|
-
# help:
|
270
|
-
when /\A\s*(see\s+)?(my\s+)?(fav|favorite|favourite|most\s+used)\s+commands\s*\z/i
|
271
|
-
only_mine = $2.to_s!=''
|
272
|
-
see_favorite_commands(user, only_mine)
|
273
|
-
|
274
|
-
# helpadmin: ----------------------------------------------
|
275
|
-
# helpadmin: `add admin @user`
|
276
|
-
# helpadmin: It will add @user as an admin of the channel.
|
277
|
-
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
278
|
-
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
279
|
-
# helpadmin: command_id: :add_admin
|
280
|
-
# helpadmin:
|
281
|
-
when /\A\s*add\s+admin\s+<@(\w+)>\s*\z/i
|
282
|
-
admin_user = $1
|
283
|
-
add_admin(user, admin_user)
|
284
|
-
|
285
|
-
# help: ----------------------------------------------
|
286
|
-
# help: `see admins`
|
287
|
-
# help: `show admins`
|
288
|
-
# help: `who are admins?`
|
289
|
-
# help: It will show who are the admins of the channel.
|
290
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
291
|
-
# help: command_id: :see_admins
|
292
|
-
# help:
|
293
|
-
when /\A\s*(see|show)\s+admins\s*\z/i, /\A\s*who\s+are\s+(the\s+)?admins\??\s*\z/i
|
294
|
-
see_admins()
|
295
|
-
|
296
|
-
# helpadmin: ----------------------------------------------
|
297
|
-
# helpadmin: `remove admin @user`
|
298
|
-
# helpadmin: It will remove the admin privileges for @user on the channel.
|
299
|
-
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
300
|
-
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
301
|
-
# helpadmin: command_id: :remove_admin
|
302
|
-
# helpadmin:
|
303
|
-
when /\A\s*(remove|delete)\s+admin\s+<@(\w+)>\s*\z/i
|
304
|
-
admin_user = $2
|
305
|
-
remove_admin(user, admin_user)
|
306
|
-
|
307
|
-
# helpadmin: ----------------------------------------------
|
308
|
-
# helpadmin: `see command ids`
|
309
|
-
# helpadmin: It will display all available command ids.
|
310
|
-
# helpadmin: The command id can be used on `bot stats command COMMAND_ID`, `allow access COMMAND_ID` and `deny access COMMAND_ID`
|
311
|
-
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
312
|
-
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
313
|
-
# helpadmin: command_id: :see_command_ids
|
314
|
-
# helpadmin:
|
315
|
-
when /\A\s*(see|display|get)\s+command(\s+|_)ids?\s*\z/i
|
316
|
-
see_command_ids()
|
317
|
-
|
318
|
-
# helpadmin: ----------------------------------------------
|
319
|
-
# helpadmin: `allow access COMMAND_ID`
|
320
|
-
# helpadmin: `allow access COMMAND_ID @user1 @user99`
|
321
|
-
# helpadmin: It will allow the specified command to be used on the channel.
|
322
|
-
# helpadmin: If @user specified, only those users will have access to the command.
|
323
|
-
# helpadmin: Only admins of the channel can use this command
|
324
|
-
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
325
|
-
# helpadmin: command_id: :allow_access
|
326
|
-
# helpadmin:
|
327
|
-
when /\A\s*(allow|give)\s+access\s+(\w+)\s+(.+)\s*\z/i, /\A\s*(allow|give)\s+access\s+(\w+)()\s*\z/i
|
328
|
-
command_id = $2.downcase
|
329
|
-
opt = $3.to_s.split(' ')
|
330
|
-
allow_access(user, command_id, opt)
|
331
|
-
|
332
|
-
# helpadmin: ----------------------------------------------
|
333
|
-
# helpadmin: `deny access COMMAND_ID`
|
334
|
-
# helpadmin: It won't allow the specified command to be used on the channel.
|
335
|
-
# helpadmin: Only admins of the channel can use this command
|
336
|
-
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
337
|
-
# helpadmin: command_id: :deny_access
|
338
|
-
# helpadmin:
|
339
|
-
when /\A\s*deny\s+access(\s+rights)?\s+(\w+)\s*\z/i
|
340
|
-
command_id = $2.downcase
|
341
|
-
deny_access(user, command_id)
|
342
|
-
|
343
|
-
|
344
|
-
# help: ----------------------------------------------
|
345
|
-
# help: `see access COMMAND_ID`
|
346
|
-
# help: It will show the access rights for the specified command.
|
347
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
348
|
-
# help: command_id: :see_access
|
349
|
-
# help:
|
350
|
-
when /\A\s*(see|show)\s+access(\s+rights)?\s+(.+)\s*\z/i
|
351
|
-
command_id = $3.downcase
|
352
|
-
see_access(command_id)
|
353
|
-
|
354
|
-
# help: ----------------------------------------------
|
355
|
-
# help: `poster MESSAGE`
|
356
|
-
# help: `poster :EMOTICON_TEXT: MESSAGE`
|
357
|
-
# help: `poster :EMOTICON_TEXT: :EMOTICON_BACKGROUND: MESSAGE`
|
358
|
-
# help: `poster MINUTESm MESSAGE`
|
359
|
-
# help: It will create a poster with the message supplied. By default will be autodeleted 1 minute later.
|
360
|
-
# help: If you want the poster to be permanent then use the command `pposter`
|
361
|
-
# help: If minutes supplied then it will be deleted after the minutes specified. Maximum value 60.
|
362
|
-
# help: To see the messages on a mobile phone put the phone on landscape mode
|
363
|
-
# help: Max 15 characters. If the message is longer than that won't be treat it.
|
364
|
-
# help: Only letters from a to z, 0 to 9 and the chars: ? ! - + =
|
365
|
-
# help: To be displayed correctly use words with no more than 6 characters
|
366
|
-
# help: Examples:
|
367
|
-
# help: _poster nice work!_
|
368
|
-
# help: _poster :heart: nice work!_
|
369
|
-
# help: _poster :mac-spinning-wheel: :look: love!_
|
370
|
-
# help: _poster 25m :heart: woah!_
|
371
|
-
# help: command_id: :poster
|
372
|
-
# help:
|
373
|
-
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,
|
374
|
-
/\A(p)poster\s+()(:[^:]+:)\s+(:[^:]+:)(.+)\s*\z/i, /\A(p)poster\s+()(:.+:)\s+()(.+)\s*\z/i, /\A(p)poster\s+()()()(.+)\s*\z/i
|
375
|
-
permanent = $1.to_s != ''
|
376
|
-
minutes = $2.to_s
|
377
|
-
emoticon_text = $3
|
378
|
-
emoticon_bg = $4
|
379
|
-
text = $5
|
380
|
-
minutes = minutes.scan(/(\d+)/).join
|
381
|
-
|
382
|
-
if minutes == ''
|
383
|
-
minutes = 1
|
384
|
-
elsif minutes.to_i > 60
|
385
|
-
minutes = 60
|
386
|
-
end
|
387
|
-
|
388
|
-
save_stats :poster
|
389
|
-
if text.to_s.gsub(/\s+/, '').length > 15
|
390
|
-
respond "Too long. Max 15 chars", :on_thread
|
391
|
-
else
|
392
|
-
poster(permanent, emoticon_text, emoticon_bg, text, minutes)
|
1
|
+
class SlackSmartBot
|
2
|
+
|
3
|
+
# add here the general commands you will be using in any channel where The SmartBot is part of. Not necessary to use ! or ^, it will answer directly.
|
4
|
+
def general_bot_commands(user, command, dest, files = [])
|
5
|
+
|
6
|
+
begin
|
7
|
+
if config.simulate
|
8
|
+
display_name = user.profile.display_name
|
9
|
+
else
|
10
|
+
if user.profile.display_name.to_s.match?(/\A\s*\z/)
|
11
|
+
user.profile.display_name = user.profile.real_name
|
393
12
|
end
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
# help: `add team TEAM_NAME MEMBER_TYPE @USER1 @USER99 CHANNEL_TYPE #CHANNEL1 #CHANNEL99 : INFO`
|
398
|
-
# help: `add team TEAM_NAME MEMBER_TYPE1 @USER1 @USER99 MEMBER_TYPE99 @USER1 @USER99 CHANNEL_TYPE1 #CHANNEL1 #CHANNEL99 CHANNEL_TYPE99 #CHANNEL1 #CHANNEL99 : INFO`
|
399
|
-
# help: It will add a team with the info supplied.
|
400
|
-
# help: TEAM_NAME, TYPE: one word, a-z, A-Z, 0-9, - and _
|
401
|
-
# 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.
|
402
|
-
# help: Examples:
|
403
|
-
# 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_
|
404
|
-
# 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_
|
405
|
-
# help: _add team devweb qa @jim dev @johnja @cooke @luisa members #devweb support #devweb-support : We take care of the website_
|
406
|
-
# help: _add team sandex manager @sarah members #sandex : We take care of the sand_
|
407
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
408
|
-
# help: command_id: :add_team
|
409
|
-
# help:
|
410
|
-
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
|
411
|
-
name = $1.downcase
|
412
|
-
options = $2
|
413
|
-
info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
414
|
-
add_team(user, name, options, info)
|
415
|
-
|
416
|
-
# help: ----------------------------------------------
|
417
|
-
# help: `add TYPE to TEAM_NAME team : MESSAGE`
|
418
|
-
# help: `add private TYPE to TEAM_NAME team : MESSAGE`
|
419
|
-
# help: `add personal TYPE to TEAM_NAME team : MESSAGE`
|
420
|
-
# help: `add TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
421
|
-
# help: `add private TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
422
|
-
# help: `add personal TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
423
|
-
# help: It will add a memo to the team. The memos will be displayed with the team info.
|
424
|
-
# help: Only team members can add a memo.
|
425
|
-
# help: TYPE: memo, note, issue, task, feature, bug, jira, github
|
426
|
-
# help: TOPIC: one word, a-z, A-Z, 0-9, - and _
|
427
|
-
# help: If private then the memo will be only displayed to team members on a DM or the members channel.
|
428
|
-
# help: If personal then the memo will be only displayed to the creator on a DM.
|
429
|
-
# help: In case jira type supplied:
|
430
|
-
# help: The message should be an JQL URL, JQL string or an issue URL.
|
431
|
-
# help: To be able to use it you need to specify on the SmartBot settings the credentials.
|
432
|
-
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every JIRA issue
|
433
|
-
# help: In case github type supplied:
|
434
|
-
# help: The message should be a github URL. You can filter by state (open/closed/all) and labels
|
435
|
-
# help: To be able to use it you need to specify on the SmartBot settings the github token.
|
436
|
-
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every Github issue
|
437
|
-
# help: Examples:
|
438
|
-
# help: _add memo to sales team : Add tests for Michigan feature_
|
439
|
-
# help: _add private note to sales team : Bills will need to be deployed before Friday_
|
440
|
-
# help: _add memo to dev team web : Check last version_
|
441
|
-
# help: _add private bug to dev team SRE : Logs should not be accessible from outside VPN_
|
442
|
-
# help: _add memo sales team : Add tests for Michigan feature_
|
443
|
-
# help: _add memo team sales: Add tests for Michigan feature_
|
444
|
-
# help: _add personal memo team sales: Check my vacations_
|
445
|
-
# help: _add jira to sales team : labels = SalesT AND status != Done_
|
446
|
-
# help: _add github to sales team : PeterBale/SalesBoom/issues?state=open&labels=bug_
|
447
|
-
# help: _add github to sales team dev: PeterBale/DevProject/issues/71_
|
448
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
449
|
-
# help: command_id: :add_memo_team
|
450
|
-
# help:
|
451
|
-
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,
|
452
|
-
/\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
|
453
|
-
privacy = $1.to_s.strip.downcase
|
454
|
-
type = $2.downcase
|
455
|
-
team_name = $4.downcase
|
456
|
-
topic = $5.to_s.strip
|
457
|
-
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
458
|
-
add_memo_team(user, privacy, team_name, topic, type, message)
|
459
|
-
|
460
|
-
# help: ----------------------------------------------
|
461
|
-
# help: `delete memo ID from TEAM_NAME team`
|
462
|
-
# help: It will delete the supplied memo ID on the team specified.
|
463
|
-
# help: aliases for memo: note, issue, task, feature, bug, jira, github
|
464
|
-
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a memo.
|
465
|
-
# help: Examples:
|
466
|
-
# help: _delete memo 32 from sales team_
|
467
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
468
|
-
# help: command_id: :delete_memo_team
|
469
|
-
# help:
|
470
|
-
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,
|
471
|
-
/\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
|
472
|
-
memo_id = $3
|
473
|
-
team_name = $5.downcase
|
474
|
-
delete_memo_team(user, team_name, memo_id)
|
475
|
-
|
476
|
-
# help: ----------------------------------------------
|
477
|
-
# help: `set memo ID on TEAM_NAME team STATUS`
|
478
|
-
# help: `set STATUS on memo ID TEAM_NAME team`
|
479
|
-
# help: It will assign to the ID specified the emoticon status indicated.
|
480
|
-
# help: aliases for memo: note, issue, task, feature, bug
|
481
|
-
# help: This command will be only for memo, note, issue, task, feature, bug. Not for jira or github.
|
482
|
-
# help: You have to be a member of the team, the creator or a Master admin to be able to set a status.
|
483
|
-
# help: Examples:
|
484
|
-
# help: _set memo 32 on sales team :runner:_
|
485
|
-
# help: _set bug 7 on team sales :heavy_check_mark:_
|
486
|
-
# help: _set :runner: on memo 6 sales team_
|
487
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
488
|
-
# help: command_id: :set_memo_status
|
489
|
-
# help:
|
490
|
-
when /\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+team\s+([\w\-]+)\s+(:[\w\-]+:)\s*\z/i,
|
491
|
-
/\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+([\w\-]+)\s+team\s+(:[\w\-]+:)\s*\z/i
|
492
|
-
memo_id = $3
|
493
|
-
team_name = $4.downcase
|
494
|
-
status = $5
|
495
|
-
set_memo_status(user, team_name, memo_id, status)
|
496
|
-
|
497
|
-
when /\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+team\s+([\w\-]+)\s*\z/i,
|
498
|
-
/\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+([\w\-]+)\s+team\s*\z/i
|
499
|
-
memo_id = $4
|
500
|
-
team_name = $5.downcase
|
501
|
-
status = $2
|
502
|
-
set_memo_status(user, team_name, memo_id, status)
|
503
|
-
|
504
|
-
# help: ----------------------------------------------
|
505
|
-
# help: `see teams`
|
506
|
-
# help: `see team TEAM_NAME`
|
507
|
-
# help: `team TEAM_NAME`
|
508
|
-
# help: `TEAM_NAME team`
|
509
|
-
# help: `which team @USER`
|
510
|
-
# help: `which team #CHANNEL`
|
511
|
-
# help: `which team TEXT_TO_SEARCH_ON_INFO`
|
512
|
-
# help: `which team does @USER belongs to?`
|
513
|
-
# help: It will display all teams or the team specified.
|
514
|
-
# help: In case a specific team it will show also the availability of the members.
|
515
|
-
# help: Examples:
|
516
|
-
# help: _see teams_
|
517
|
-
# help: _see team Sales_
|
518
|
-
# help: _Dev team_
|
519
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
520
|
-
# help: command_id: :see_teams
|
521
|
-
# help:
|
522
|
-
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
|
523
|
-
name = $1.to_s.downcase
|
524
|
-
see_teams(user, name)
|
525
|
-
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
|
526
|
-
search = $3.to_s.downcase
|
527
|
-
see_teams(user, '', search)
|
528
|
-
|
13
|
+
display_name = user.profile.display_name
|
14
|
+
end
|
15
|
+
case command
|
529
16
|
# help: ----------------------------------------------
|
530
|
-
# help: `
|
531
|
-
# help: `
|
532
|
-
# help: `
|
533
|
-
# help: `
|
534
|
-
# help: `
|
535
|
-
# help: `
|
536
|
-
# help: `
|
537
|
-
# help: `
|
538
|
-
# help:
|
539
|
-
# help:
|
540
|
-
# help:
|
541
|
-
# help:
|
542
|
-
# help:
|
543
|
-
# help:
|
544
|
-
# help: _update team sales delete public #sales_
|
545
|
-
# help: _update team sales delete #sales_support_
|
546
|
-
# help: _update sales team add public #salesff_
|
547
|
-
# help: _update sales team add qa @john @ben @ana_
|
548
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
549
|
-
# help: command_id: :update_team
|
550
|
-
# help:
|
551
|
-
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
|
552
|
-
name = $1.downcase
|
553
|
-
new_name = $2.downcase
|
554
|
-
update_team(user, name, new_name: new_name)
|
555
|
-
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
|
556
|
-
name = $1.downcase
|
557
|
-
new_info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
558
|
-
update_team(user, name, new_info: new_info)
|
559
|
-
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
|
560
|
-
name = $1.downcase
|
561
|
-
delete_opts = $3
|
562
|
-
update_team(user, name, delete_opts: delete_opts)
|
563
|
-
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
|
564
|
-
name = $1.downcase
|
565
|
-
add_opts = $2
|
566
|
-
update_team(user, name, add_opts: add_opts)
|
17
|
+
# help: `bot help`
|
18
|
+
# help: `bot help COMMAND`
|
19
|
+
# help: `bot rules`
|
20
|
+
# help: `bot rules COMMAND`
|
21
|
+
# help: `bot help expanded`
|
22
|
+
# help: `bot rules expanded`
|
23
|
+
# help: `bot what can I do?`
|
24
|
+
# help: it will display this help. For a more detailed help call `bot help expanded` or `bot rules expanded`.
|
25
|
+
# help: if COMMAND supplied just help for that command
|
26
|
+
# help: you can use the option 'expanded' or the alias 'extended'
|
27
|
+
# help: `bot rules` will show only the specific rules for this channel.
|
28
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-help|more info>
|
29
|
+
# help: command_id: :bot_help
|
30
|
+
# help:
|
567
31
|
|
568
32
|
# help: ----------------------------------------------
|
569
|
-
# help: `
|
570
|
-
# help: `
|
571
|
-
# help:
|
572
|
-
# help:
|
573
|
-
# help:
|
33
|
+
# help: `for NUMBER times every NUMBER minutes COMMAND`
|
34
|
+
# help: `for NUMBER times every NUMBER seconds COMMAND`
|
35
|
+
# help: `NUMBER times every NUMBER minutes COMMAND`
|
36
|
+
# help: `NUMBER times every NUMBER seconds COMMAND`
|
37
|
+
# help: It will run the command every NUMBER minutes or seconds for NUMBER times.
|
38
|
+
# help: max 24 times. min every 10 seconds. max every 60 minutes.
|
39
|
+
# help: Call `quit loop LOOP_ID` to stop the loop.
|
40
|
+
# help: aliases for minutes: m, minute, minutes
|
41
|
+
# help: aliases for seconds: s, sc, second, seconds
|
574
42
|
# help: Examples:
|
575
|
-
# help:
|
576
|
-
# help:
|
577
|
-
# help:
|
578
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#
|
579
|
-
# help: command_id: :
|
580
|
-
# help:
|
581
|
-
# help:
|
582
|
-
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
|
583
|
-
type = $1.downcase.to_sym
|
584
|
-
name = $2.downcase
|
585
|
-
member_type = $3.downcase
|
586
|
-
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[\w]+\s+\w+\s+team\s+[\w\-]+\s+(.+)\s*\z/im).join
|
587
|
-
if message == ''
|
588
|
-
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[\w]+\s+team\s+\w+\s+[\w\-]+\s+(.+)\s*\z/im).join
|
589
|
-
end
|
590
|
-
ping_team(user, type, name, member_type, message)
|
43
|
+
# help: _for 5 times every 1 minute ^ruby puts Time.now_
|
44
|
+
# help: _10 times every 30s !ruby puts Time.now_
|
45
|
+
# help: _24 times every 60m !get sales today_
|
46
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#loops|more info>
|
47
|
+
# help: command_id: :create_loop
|
48
|
+
# help:
|
591
49
|
|
592
50
|
# help: ----------------------------------------------
|
593
|
-
# help: `
|
594
|
-
# help:
|
595
|
-
# help:
|
51
|
+
# help: `quit loop LOOP_ID`
|
52
|
+
# help: It will stop the loop with the id LOOP_ID.
|
53
|
+
# help: Only the user who created the loop or an admin can stop it.
|
54
|
+
# help: aliases for loop: iterator, iteration
|
55
|
+
# help: aliases for quit: stop, exit, kill
|
596
56
|
# help: Examples:
|
597
|
-
# help:
|
598
|
-
# help:
|
599
|
-
# help:
|
600
|
-
# help:
|
601
|
-
when /\A\s*(delete|remove)\s+team\s+([\w\-]+)\s*\z/i, /\A\s*(delete|remove)\s+([\w\-]+)\s+team\s*\z/i
|
602
|
-
name = $2.downcase
|
603
|
-
delete_team(user, name)
|
57
|
+
# help: _quit loop 1_
|
58
|
+
# help: _stop iterator 12_
|
59
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#loops|more info>
|
60
|
+
# help: command_id: :quit_loop
|
604
61
|
|
605
62
|
# help: ----------------------------------------------
|
606
|
-
# help: `
|
607
|
-
# help: `
|
608
|
-
# help: `
|
609
|
-
# help: `
|
610
|
-
# help:
|
611
|
-
# help:
|
612
|
-
# help:
|
613
|
-
# help:
|
614
|
-
# help:
|
615
|
-
# help: _see bugs from sales team_
|
616
|
-
# help: _see all memos from sales team webdev_
|
617
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
618
|
-
# help: command_id: :see_memos_team
|
63
|
+
# help: `Hi Bot`
|
64
|
+
# help: `Hi Smart`
|
65
|
+
# help: `Hello Bot` `Hola Bot` `Hallo Bot` `What's up Bot` `Hey Bot` `Hæ Bot`
|
66
|
+
# help: `Hello THE_NAME_OF_THE_BOT`
|
67
|
+
# help: Bot starts listening to you if you are on a Bot channel
|
68
|
+
# help: After that if you want to avoid a single message to be treated by the smart bot, start the message by -
|
69
|
+
# help: Also apart of Hello you can use _Hallo, Hi, Hola, What's up, Hey, Hæ_
|
70
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
71
|
+
# help: command_id: :hi_bot
|
619
72
|
# help:
|
620
|
-
|
621
|
-
|
622
|
-
type = $1.downcase.to_sym
|
623
|
-
name = $3.downcase
|
624
|
-
topic = $4.strip
|
625
|
-
see_memos_team(user, type: type, name: name, topic: topic)
|
626
|
-
|
627
|
-
# help: ----------------------------------------------
|
628
|
-
# help: `add vacation from YYYY/MM/DD to YYYY/MM/DD`
|
629
|
-
# help: `add vacation YYYY/MM/DD`
|
630
|
-
# help: `add sick from YYYY/MM/DD to YYYY/MM/DD`
|
631
|
-
# help: `add sick YYYY/MM/DD`
|
632
|
-
# help: `add sick child YYYY/MM/DD`
|
633
|
-
# help: `I'm sick today`
|
634
|
-
# help: `I'm on vacation today`
|
635
|
-
# help: It will add the supplied period to your plan.
|
636
|
-
# help: Instead of YYYY/MM/DD you can use 'today' or 'tomorrow' or 'next week'
|
637
|
-
# help: To see your plan call `see my time off`
|
638
|
-
# help: If you want to see the vacation plan for the team `see team NAME`
|
639
|
-
# help: Also you can see the vacation plan for the team for a specific period: `vacations team NAME YYYY/MM/DD`
|
640
|
-
# help: The SmartBot will automatically set the users status to :palm_tree:, :baby: or :face_with_thermometer: and the expiration date.
|
641
|
-
# help: Examples:
|
642
|
-
# help: _add vacation from 2022/10/01 to 2022/10/22_
|
643
|
-
# help: _add sick 2022/08/22_
|
644
|
-
# help: _add vacation tomorrow_
|
645
|
-
# help: _I'll be on vacation next week_
|
646
|
-
# help: _add sick baby today_
|
647
|
-
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
648
|
-
# help: command_id: :add_vacation
|
649
|
-
# help:
|
650
|
-
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,
|
651
|
-
/\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,
|
652
|
-
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d-\d\d-\d\d)()\s*\z/i,
|
653
|
-
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d\/\d\d\/\d\d)()\s*\z/i,
|
654
|
-
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(today|tomorrow|next\sweek)()\s*\z/i,
|
655
|
-
/\A\s*(I'm|I\s+am|I'll\s+be|I\s+will\s+be)\s+(sick|on\s+vacation)\s+(today|tomorrow|next\sweek)()\s*\z/i
|
656
|
-
type = $2
|
657
|
-
from = $3.downcase
|
658
|
-
to = $4
|
659
|
-
type = 'vacation' if type.match?(/vacation/)
|
660
|
-
add_vacation(user, type, from, to)
|
73
|
+
when /\A\s*(Hello|Hallo|Hi|Hola|What's\sup|Hey|Hæ)\s+(#{@salutations.join("|")})\s*$/i
|
74
|
+
hi_bot(user, dest, user.name, display_name)
|
661
75
|
|
662
76
|
# help: ----------------------------------------------
|
663
|
-
# help: `
|
664
|
-
# help: `
|
665
|
-
# help: `
|
666
|
-
# help:
|
667
|
-
# help:
|
668
|
-
# help:
|
669
|
-
# help:
|
670
|
-
# help:
|
671
|
-
#
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
77
|
+
# help: `Bye Bot`
|
78
|
+
# help: `Bye Smart`
|
79
|
+
# help: `Bye NAME_OF_THE_BOT`
|
80
|
+
# help: Bot stops listening to you if you are on a Bot channel
|
81
|
+
# help: Also apart of Bye you can use _Bæ, Good Bye, Adiós, Ciao, Bless, Bless Bless, Adeu_
|
82
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#how-to-access-the-smart-bot|more info>
|
83
|
+
# help: command_id: :bye_bot
|
84
|
+
# help:
|
85
|
+
when /\A\s*(Bye|Bæ|Good\s+Bye|Adiós|Ciao|Bless|Bless\sBless|Adeu)\s+(#{@salutations.join("|")})\s*$/i
|
86
|
+
bye_bot(dest, user.name, display_name)
|
87
|
+
|
88
|
+
# help: ----------------------------------------------
|
89
|
+
# help: `add announcement MESSAGE`
|
90
|
+
# help: `add red announcement MESSAGE`
|
91
|
+
# help: `add green announcement MESSAGE`
|
92
|
+
# help: `add yellow announcement MESSAGE`
|
93
|
+
# help: `add white announcement MESSAGE`
|
94
|
+
# help: `add EMOJI announcement MESSAGE`
|
95
|
+
# help: It will store the message on the announcement list labeled with the color or emoji specified, white by default.
|
96
|
+
# help: aliases for announcement: statement, declaration, message
|
97
|
+
# help: Examples:
|
98
|
+
# help: _add green announcement :heavy_check_mark: All customer services are up and running_
|
99
|
+
# help: _add red declaration Customers db is down :x:_
|
100
|
+
# help: _add yellow statement Don't access the linux server without VPN_
|
101
|
+
# help: _add message `*Party* will start at *20:00* :tada:`_
|
102
|
+
# help: _add :heavy_exclamation_mark: message Pay attention all DB are on maintenance until 20:00 GMT_
|
103
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
104
|
+
# help: command_id: :add_announcement
|
105
|
+
# help:
|
106
|
+
when /\A\s*(add|create)\s+(red\s+|green\s+|white\s+|yellow\s+)?(announcement|statement|declaration|message)\s+(.+)\s*\z/i,
|
107
|
+
/\A\s*(add|create)\s+(:[\w\-]+:)\s+(announcement|statement|declaration|message)\s+(.+)\s*\z/i
|
108
|
+
type = $2.to_s.downcase.strip
|
109
|
+
type = 'white' if type == ''
|
110
|
+
message = $4
|
111
|
+
add_announcement(user, type, message)
|
112
|
+
|
113
|
+
|
114
|
+
# help: ----------------------------------------------
|
115
|
+
# help: `delete announcement ID`
|
116
|
+
# help: It will delete the message on the announcement list.
|
117
|
+
# help: aliases for announcement: statement, declaration, message
|
118
|
+
# help: Examples:
|
119
|
+
# help: _delete announcement 24_
|
120
|
+
# help: _delete message 645_
|
121
|
+
# help: _delete statement 77_
|
122
|
+
# help: _delete declaration 334_
|
123
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
124
|
+
# help: command_id: :delete_announcement
|
125
|
+
# help:
|
126
|
+
when /\A\s*(delete|remove)\s+(announcement|statement|declaration|message)\s+(\d+)\s*\z/i
|
127
|
+
message_id = $3
|
128
|
+
delete_announcement(user, message_id)
|
129
|
+
|
130
|
+
# help: ----------------------------------------------
|
131
|
+
# help: `see announcements`
|
132
|
+
# help: `see red announcements`
|
133
|
+
# help: `see green announcements`
|
134
|
+
# help: `see yellow announcements`
|
135
|
+
# help: `see white announcements`
|
136
|
+
# help: `see EMOJI announcements`
|
137
|
+
# helpmaster: `see announcements #CHANNEL`
|
138
|
+
# helpmaster: `see all announcements`
|
139
|
+
# help: It will display the announcements for the channel.
|
140
|
+
# help: aliases for announcements: statements, declarations, messages
|
141
|
+
# helpmaster: In case #CHANNEL it will display the announcements for that channel. Only master admins can use it from a DM with the Smartbot.
|
142
|
+
# helpmaster: In case 'all' it will display all the announcements for all channels. Only master admins can use it from a DM with the Smartbot.
|
143
|
+
# help: Examples:
|
144
|
+
# help: _see announcements_
|
145
|
+
# help: _see white messages_
|
146
|
+
# help: _see red statements_
|
147
|
+
# help: _see yellow declarations_
|
148
|
+
# help: _see messages_
|
149
|
+
# help: _see :heavy_exclamation_mark: messages_
|
150
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#announcements|more info>
|
151
|
+
# help: command_id: :see_announcements
|
152
|
+
# help:
|
153
|
+
when /\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
154
|
+
/\A\s*see\s+(all\s+)?(announcements|statements|declarations|messages)()\s*\z/i,
|
155
|
+
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+#([\w\-]+)\s*\z/i,
|
156
|
+
/\A\s*see\s+(red\s+|green\s+|white\s+|yellow\s+|:[\w\-]+:\s+)?(announcements|statements|declarations|messages)\s+<#(\w+)\|.*>\s*\z/i
|
157
|
+
|
158
|
+
type = $1.to_s.downcase.strip
|
159
|
+
channel = $3.to_s
|
160
|
+
|
161
|
+
see_announcements(user, type, channel)
|
162
|
+
|
163
|
+
|
164
|
+
# help: ----------------------------------------------
|
165
|
+
# help: `share messages /REGEXP/ on #CHANNEL`
|
166
|
+
# help: `share messages "TEXT" on #CHANNEL`
|
167
|
+
# xhelp: `share messages :EMOJI: on #CHANNEL`
|
168
|
+
# help: It will automatically share new messages published that meet the specified criteria.
|
169
|
+
# xhelp: In case :EMOJI: it will share the messages with the indicated reaction.
|
170
|
+
# help: SmartBot user and user adding the share need to be members on both channels.
|
171
|
+
# help: The Regexp will automatically add the parameters /im
|
172
|
+
# help: Only available on public channels.
|
173
|
+
# help: Examples:
|
174
|
+
# help: _share messages /(last\s+|previous\s+)sales\s+results\s+/ on #sales_
|
175
|
+
# help: _share messages "share post" on #announcements_
|
176
|
+
# xhelp: _share messages :tada: on #announcements_
|
177
|
+
# xhelp: _share messages :moneybag: from #sales_
|
178
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
179
|
+
# help: command_id: :share_messages
|
180
|
+
# help:
|
181
|
+
when /\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#\w+\|(.+)>\s*\z/i,
|
182
|
+
/\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+<#(\w+)\|>\s*\z/,
|
183
|
+
/\A\s*share\s+messages\s+(\/.+\/|".+"|'.+')\s+on\s+(.+)\s*\z/i
|
184
|
+
condition = $1
|
185
|
+
channel = $2
|
186
|
+
channel.gsub!('#','') # for the case the channel name is in plain text including #
|
187
|
+
channel = @channels_name[channel] if @channels_name.key?(channel)
|
188
|
+
channel_from = @channels_name[dest]
|
189
|
+
channel_to = channel
|
190
|
+
share_messages(user, channel_from, channel_to, condition)
|
191
|
+
|
192
|
+
# help: ----------------------------------------------
|
193
|
+
# help: `see shares`
|
194
|
+
# help: It will display the active shares from this channel.
|
195
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
196
|
+
# help: command_id: :see_shares
|
197
|
+
# help:
|
198
|
+
when /\A\s*see\s+shares\s*\z/i
|
199
|
+
see_shares()
|
200
|
+
|
201
|
+
# help: ----------------------------------------------
|
202
|
+
# help: `delete share ID`
|
203
|
+
# help: It will delete the share id specified.
|
204
|
+
# help: Examples:
|
205
|
+
# help: _delete share 24_
|
206
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#share-messages|more info>
|
207
|
+
# help: command_id: :delete_share
|
208
|
+
# help:
|
209
|
+
when /\A\s*(delete|remove)\s+share\s+(\d+)\s*\z/i
|
210
|
+
share_id = $2
|
211
|
+
delete_share(user, share_id)
|
212
|
+
|
213
|
+
# help: ----------------------------------------------
|
214
|
+
# help: `see statuses`
|
215
|
+
# help: `see statuses #CHANNEL`
|
216
|
+
# help: `see status EMOJI`
|
217
|
+
# help: `see status EMOJI #CHANNEL`
|
218
|
+
# help: `see status EMOJI1 EMOJI99`
|
219
|
+
# help: `who is on vacation?`
|
220
|
+
# help: `who is on EMOJI`
|
221
|
+
# help: `who is on EMOJI #CHANNEL`
|
222
|
+
# help: `who is on EMOJI1 EMOJI99`
|
223
|
+
# help: `who is not on vacation?`
|
224
|
+
# help: `who is not on EMOJI`
|
225
|
+
# help: `who is available?`
|
226
|
+
# 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.
|
227
|
+
# 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.
|
228
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-statuses|more info>
|
229
|
+
# help: command_id: :see_statuses
|
230
|
+
# help:
|
231
|
+
when /\A\s*(see|get)\s+(statuses)()\s*\z/i,
|
232
|
+
/\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,
|
233
|
+
/\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,
|
234
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??()\s*\z/i,
|
235
|
+
/\A\s*(see|get)\s+(statuses)\s+#([\w\-]+)\s*\z/i,
|
236
|
+
/\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,
|
237
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+#([\w\-]+)\s*\z/i,
|
238
|
+
/\A\s*(who\s+is|who\s+are)\s+(available|active)\s*\??\s+<#(\w+)\|.*>\s*\z/i,
|
239
|
+
/\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,
|
240
|
+
/\A\s*(see|get)\s+(statuses)\s+<#(\w+)\|.*>\s*\z/i,
|
241
|
+
/\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,
|
242
|
+
/\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
|
243
|
+
|
244
|
+
not_on = $1.match?(/who\s+(is|are)\s+not\s+on/i)
|
245
|
+
type = $2.downcase
|
246
|
+
channel = $3.to_s
|
247
|
+
if type == 'statuses'
|
248
|
+
types = []
|
249
|
+
elsif type =='vacation' or type == 'holiday'
|
250
|
+
types = [':palm_tree:']
|
251
|
+
elsif type == 'available' or type == 'active'
|
252
|
+
types = ['available']
|
253
|
+
else
|
254
|
+
type.gsub!(' ', '')
|
255
|
+
type.gsub!('::',': :')
|
256
|
+
types = type.split(' ')
|
257
|
+
end
|
258
|
+
see_statuses(user, channel, types, dest, not_on)
|
259
|
+
|
260
|
+
|
261
|
+
# help: ----------------------------------------------
|
262
|
+
# help: `see favorite commands`
|
263
|
+
# help: `see my favorite commands`
|
264
|
+
# help: `favorite commands`
|
265
|
+
# help: `my favorite commands`
|
266
|
+
# help: It will display the favorite commands.
|
267
|
+
# help: aliases for favorite: favourite, most used, fav
|
268
|
+
# helpmaster: You need to set stats to true to generate the stats when running the bot instance and get this info.
|
269
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#see-favorite-commands|more info>
|
270
|
+
# help: command_id: :see_favorite_commands
|
271
|
+
# help:
|
272
|
+
when /\A\s*(see\s+)?(my\s+)?(fav|favorite|favourite|most\s+used)\s+commands\s*\z/i
|
273
|
+
only_mine = $2.to_s!=''
|
274
|
+
see_favorite_commands(user, only_mine)
|
275
|
+
|
276
|
+
# helpadmin: ----------------------------------------------
|
277
|
+
# helpadmin: `add admin @user`
|
278
|
+
# helpadmin: It will add @user as an admin of the channel.
|
279
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
280
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
281
|
+
# helpadmin: command_id: :add_admin
|
282
|
+
# helpadmin:
|
283
|
+
when /\A\s*add\s+admin\s+<@(\w+)>\s*\z/i
|
284
|
+
admin_user = $1
|
285
|
+
add_admin(user, admin_user)
|
286
|
+
|
287
|
+
# help: ----------------------------------------------
|
288
|
+
# help: `see admins`
|
289
|
+
# help: `show admins`
|
290
|
+
# help: `who are admins?`
|
291
|
+
# help: It will show who are the admins of the channel.
|
292
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
293
|
+
# help: command_id: :see_admins
|
294
|
+
# help:
|
295
|
+
when /\A\s*(see|show)\s+admins\s*\z/i, /\A\s*who\s+are\s+(the\s+)?admins\??\s*\z/i
|
296
|
+
see_admins()
|
297
|
+
|
298
|
+
# helpadmin: ----------------------------------------------
|
299
|
+
# helpadmin: `remove admin @user`
|
300
|
+
# helpadmin: It will remove the admin privileges for @user on the channel.
|
301
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
302
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
303
|
+
# helpadmin: command_id: :remove_admin
|
304
|
+
# helpadmin:
|
305
|
+
when /\A\s*(remove|delete)\s+admin\s+<@(\w+)>\s*\z/i
|
306
|
+
admin_user = $2
|
307
|
+
remove_admin(user, admin_user)
|
308
|
+
|
309
|
+
# helpadmin: ----------------------------------------------
|
310
|
+
# helpadmin: `see command ids`
|
311
|
+
# helpadmin: It will display all available command ids.
|
312
|
+
# helpadmin: The command id can be used on `bot stats command COMMAND_ID`, `allow access COMMAND_ID` and `deny access COMMAND_ID`
|
313
|
+
# helpadmin: Only creator of the channel, admins and master admins can use this command.
|
314
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#bot-management|more info>
|
315
|
+
# helpadmin: command_id: :see_command_ids
|
316
|
+
# helpadmin:
|
317
|
+
when /\A\s*(see|display|get)\s+command(\s+|_)ids?\s*\z/i
|
318
|
+
see_command_ids()
|
319
|
+
|
320
|
+
# helpadmin: ----------------------------------------------
|
321
|
+
# helpadmin: `allow access COMMAND_ID`
|
322
|
+
# helpadmin: `allow access COMMAND_ID @user1 @user99`
|
323
|
+
# helpadmin: It will allow the specified command to be used on the channel.
|
324
|
+
# helpadmin: If @user specified, only those users will have access to the command.
|
325
|
+
# helpadmin: Only admins of the channel can use this command
|
326
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
327
|
+
# helpadmin: command_id: :allow_access
|
328
|
+
# helpadmin:
|
329
|
+
when /\A\s*(allow|give)\s+access\s+(\w+)\s+(.+)\s*\z/i, /\A\s*(allow|give)\s+access\s+(\w+)()\s*\z/i
|
330
|
+
command_id = $2.downcase
|
331
|
+
opt = $3.to_s.split(' ')
|
332
|
+
allow_access(user, command_id, opt)
|
333
|
+
|
334
|
+
# helpadmin: ----------------------------------------------
|
335
|
+
# helpadmin: `deny access COMMAND_ID`
|
336
|
+
# helpadmin: It won't allow the specified command to be used on the channel.
|
337
|
+
# helpadmin: Only admins of the channel can use this command
|
338
|
+
# helpadmin: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
339
|
+
# helpadmin: command_id: :deny_access
|
340
|
+
# helpadmin:
|
341
|
+
when /\A\s*deny\s+access(\s+rights)?\s+(\w+)\s*\z/i
|
342
|
+
command_id = $2.downcase
|
343
|
+
deny_access(user, command_id)
|
344
|
+
|
345
|
+
|
346
|
+
# help: ----------------------------------------------
|
347
|
+
# help: `see access COMMAND_ID`
|
348
|
+
# help: It will show the access rights for the specified command.
|
349
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#control-who-has-access-to-a-command|more info>
|
350
|
+
# help: command_id: :see_access
|
351
|
+
# help:
|
352
|
+
when /\A\s*(see|show)\s+access(\s+rights)?\s+(.+)\s*\z/i
|
353
|
+
command_id = $3.downcase
|
354
|
+
see_access(command_id)
|
355
|
+
|
356
|
+
# help: ----------------------------------------------
|
357
|
+
# help: `poster MESSAGE`
|
358
|
+
# help: `poster :EMOTICON_TEXT: MESSAGE`
|
359
|
+
# help: `poster :EMOTICON_TEXT: :EMOTICON_BACKGROUND: MESSAGE`
|
360
|
+
# help: `poster MINUTESm MESSAGE`
|
361
|
+
# help: It will create a poster with the message supplied. By default will be autodeleted 1 minute later.
|
362
|
+
# help: If you want the poster to be permanent then use the command `pposter`
|
363
|
+
# help: If minutes supplied then it will be deleted after the minutes specified. Maximum value 60.
|
364
|
+
# help: To see the messages on a mobile phone put the phone on landscape mode
|
365
|
+
# help: Max 15 characters. If the message is longer than that won't be treat it.
|
366
|
+
# help: Only letters from a to z, 0 to 9 and the chars: ? ! - + =
|
367
|
+
# help: To be displayed correctly use words with no more than 6 characters
|
368
|
+
# help: Examples:
|
369
|
+
# help: _poster nice work!_
|
370
|
+
# help: _poster :heart: nice work!_
|
371
|
+
# help: _poster :mac-spinning-wheel: :look: love!_
|
372
|
+
# help: _poster 25m :heart: woah!_
|
373
|
+
# help: command_id: :poster
|
374
|
+
# help:
|
375
|
+
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,
|
376
|
+
/\A(p)poster\s+()(:[^:]+:)\s+(:[^:]+:)(.+)\s*\z/i, /\A(p)poster\s+()(:.+:)\s+()(.+)\s*\z/i, /\A(p)poster\s+()()()(.+)\s*\z/i
|
377
|
+
permanent = $1.to_s != ''
|
378
|
+
minutes = $2.to_s
|
379
|
+
emoticon_text = $3
|
380
|
+
emoticon_bg = $4
|
381
|
+
text = $5
|
382
|
+
minutes = minutes.scan(/(\d+)/).join
|
383
|
+
|
384
|
+
if minutes == ''
|
385
|
+
minutes = 1
|
386
|
+
elsif minutes.to_i > 60
|
387
|
+
minutes = 60
|
388
|
+
end
|
389
|
+
|
390
|
+
save_stats :poster
|
391
|
+
if text.to_s.gsub(/\s+/, '').length > 15
|
392
|
+
respond "Too long. Max 15 chars", :on_thread
|
393
|
+
else
|
394
|
+
poster(permanent, emoticon_text, emoticon_bg, text, minutes)
|
395
|
+
end
|
396
|
+
|
397
|
+
# help: ----------------------------------------------
|
398
|
+
# help: `add team TEAM_NAME members #TEAM_CHANNEL CHANNEL_TYPE #CHANNEL1 #CHANNEL99 : INFO`
|
399
|
+
# help: `add team TEAM_NAME MEMBER_TYPE @USER1 @USER99 CHANNEL_TYPE #CHANNEL1 #CHANNEL99 : INFO`
|
400
|
+
# help: `add team TEAM_NAME MEMBER_TYPE1 @USER1 @USER99 MEMBER_TYPE99 @USER1 @USER99 CHANNEL_TYPE1 #CHANNEL1 #CHANNEL99 CHANNEL_TYPE99 #CHANNEL1 #CHANNEL99 : INFO`
|
401
|
+
# help: It will add a team with the info supplied.
|
402
|
+
# help: TEAM_NAME, TYPE: one word, a-z, A-Z, 0-9, - and _
|
403
|
+
# 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.
|
404
|
+
# help: Examples:
|
405
|
+
# 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_
|
406
|
+
# 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_
|
407
|
+
# help: _add team devweb qa @jim dev @johnja @cooke @luisa members #devweb support #devweb-support : We take care of the website_
|
408
|
+
# help: _add team sandex manager @sarah members #sandex : We take care of the sand_
|
409
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
410
|
+
# help: command_id: :add_team
|
411
|
+
# help:
|
412
|
+
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
|
413
|
+
name = $1.downcase
|
414
|
+
options = $2
|
415
|
+
info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
416
|
+
add_team(user, name, options, info)
|
417
|
+
|
418
|
+
# help: ----------------------------------------------
|
419
|
+
# help: `add TYPE to TEAM_NAME team : MESSAGE`
|
420
|
+
# help: `add private TYPE to TEAM_NAME team : MESSAGE`
|
421
|
+
# help: `add personal TYPE to TEAM_NAME team : MESSAGE`
|
422
|
+
# help: `add TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
423
|
+
# help: `add private TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
424
|
+
# help: `add personal TYPE to TEAM_NAME team TOPIC : MESSAGE`
|
425
|
+
# help: It will add a memo to the team. The memos will be displayed with the team info.
|
426
|
+
# help: Only team members can add a memo.
|
427
|
+
# help: TYPE: memo, note, issue, task, feature, bug, jira, github
|
428
|
+
# help: TOPIC: one word, a-z, A-Z, 0-9, - and _
|
429
|
+
# help: If private then the memo will be only displayed to team members on a DM or the members channel.
|
430
|
+
# help: If personal then the memo will be only displayed to the creator on a DM.
|
431
|
+
# help: In case jira type supplied:
|
432
|
+
# help: The message should be an JQL URL, JQL string or an issue URL.
|
433
|
+
# help: To be able to use it you need to specify on the SmartBot settings the credentials.
|
434
|
+
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every JIRA issue
|
435
|
+
# help: In case github type supplied:
|
436
|
+
# help: The message should be a github URL. You can filter by state (open/closed/all) and labels
|
437
|
+
# help: To be able to use it you need to specify on the SmartBot settings the github token.
|
438
|
+
# help: In case no TOPIC is supplied then it will create automatically the topics from the labels specified on every Github issue
|
439
|
+
# help: Examples:
|
440
|
+
# help: _add memo to sales team : Add tests for Michigan feature_
|
441
|
+
# help: _add private note to sales team : Bills will need to be deployed before Friday_
|
442
|
+
# help: _add memo to dev team web : Check last version_
|
443
|
+
# help: _add private bug to dev team SRE : Logs should not be accessible from outside VPN_
|
444
|
+
# help: _add memo sales team : Add tests for Michigan feature_
|
445
|
+
# help: _add memo team sales: Add tests for Michigan feature_
|
446
|
+
# help: _add personal memo team sales: Check my vacations_
|
447
|
+
# help: _add jira to sales team : labels = SalesT AND status != Done_
|
448
|
+
# help: _add github to sales team : PeterBale/SalesBoom/issues?state=open&labels=bug_
|
449
|
+
# help: _add github to sales team dev: PeterBale/DevProject/issues/71_
|
450
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
451
|
+
# help: command_id: :add_memo_team
|
452
|
+
# help:
|
453
|
+
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,
|
454
|
+
/\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
|
455
|
+
privacy = $1.to_s.strip.downcase
|
456
|
+
type = $2.downcase
|
457
|
+
team_name = $4.downcase
|
458
|
+
topic = $5.to_s.strip
|
459
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
460
|
+
add_memo_team(user, privacy, team_name, topic, type, message)
|
461
|
+
|
462
|
+
# help: ----------------------------------------------
|
463
|
+
# help: `delete memo ID from TEAM_NAME team`
|
464
|
+
# help: It will delete the supplied memo ID on the team specified.
|
465
|
+
# help: aliases for memo: note, issue, task, feature, bug, jira, github
|
466
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a memo.
|
467
|
+
# help: Examples:
|
468
|
+
# help: _delete memo 32 from sales team_
|
469
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
470
|
+
# help: command_id: :delete_memo_team
|
471
|
+
# help:
|
472
|
+
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,
|
473
|
+
/\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
|
474
|
+
memo_id = $3
|
475
|
+
team_name = $5.downcase
|
476
|
+
delete_memo_team(user, team_name, memo_id)
|
477
|
+
|
478
|
+
# help: ----------------------------------------------
|
479
|
+
# help: `set memo ID on TEAM_NAME team STATUS`
|
480
|
+
# help: `set STATUS on memo ID TEAM_NAME team`
|
481
|
+
# help: It will assign to the ID specified the emoticon status indicated.
|
482
|
+
# help: aliases for memo: note, issue, task, feature, bug
|
483
|
+
# help: This command will be only for memo, note, issue, task, feature, bug. Not for jira or github.
|
484
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to set a status.
|
485
|
+
# help: Examples:
|
486
|
+
# help: _set memo 32 on sales team :runner:_
|
487
|
+
# help: _set bug 7 on team sales :heavy_check_mark:_
|
488
|
+
# help: _set :runner: on memo 6 sales team_
|
489
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
490
|
+
# help: command_id: :set_memo_status
|
491
|
+
# help:
|
492
|
+
when /\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+team\s+([\w\-]+)\s+(:[\w\-]+:)\s*\z/i,
|
493
|
+
/\A\s*(set)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+on\s+([\w\-]+)\s+team\s+(:[\w\-]+:)\s*\z/i
|
494
|
+
memo_id = $3
|
495
|
+
team_name = $4.downcase
|
496
|
+
status = $5
|
497
|
+
set_memo_status(user, team_name, memo_id, status)
|
498
|
+
|
499
|
+
when /\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+team\s+([\w\-]+)\s*\z/i,
|
500
|
+
/\A\s*(set)\s+(:[\w\-]+:)\s+on\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+([\w\-]+)\s+team\s*\z/i
|
501
|
+
memo_id = $4
|
502
|
+
team_name = $5.downcase
|
503
|
+
status = $2
|
504
|
+
set_memo_status(user, team_name, memo_id, status)
|
505
|
+
|
506
|
+
# help: ----------------------------------------------
|
507
|
+
# help: `team TEAM_NAME memo ID MESSAGE`
|
508
|
+
# help: `TEAM_NAME team memo ID MESSAGE`
|
509
|
+
# help: It will add a comment to the memo ID specified on the team specified.
|
510
|
+
# help: aliases for memo: note, issue, task, feature, bug
|
511
|
+
# help: Examples:
|
512
|
+
# help: _sales team memo 32 I have a question, is there any public data published?_
|
513
|
+
# help: _dev team task 77 putting this on hold until we get more info_
|
514
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
515
|
+
# help: command_id: :add_memo_team_comment
|
516
|
+
# help:
|
517
|
+
when /\A\s*team\s+([\w\-]+)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+(.+)\s*\z/im,
|
518
|
+
/\A\s*([\w\-]+)\s+team\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s+(.+)\s*\z/im
|
519
|
+
team_name = $1.downcase
|
520
|
+
memo_id = $3
|
521
|
+
message = $4.to_s.strip
|
522
|
+
add_memo_team_comment(user, team_name, memo_id, message)
|
523
|
+
|
524
|
+
# help: ----------------------------------------------
|
525
|
+
# help: `team TEAM_NAME memo ID`
|
526
|
+
# help: `TEAM_NAME team memo ID`
|
527
|
+
# help: It will show the memo ID specified on the team specified.
|
528
|
+
# help: aliases for memo: note, issue, task, feature, bug
|
529
|
+
# help: Examples:
|
530
|
+
# help: _sales team memo 32_
|
531
|
+
# help: _dev team task 77_
|
532
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
533
|
+
# help: command_id: :see_memo_team
|
534
|
+
# help:
|
535
|
+
when /\A\s*team\s+([\w\-]+)\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s*\z/i,
|
536
|
+
/\A\s*([\w\-]+)\s+team\s+(memo|note|issue|task|feature|bug)\s+(\d+)\s*\z/i
|
537
|
+
team_name = $1.downcase
|
538
|
+
memo_id = $3
|
539
|
+
see_memo_team(user, team_name, memo_id)
|
540
|
+
|
541
|
+
# help: ----------------------------------------------
|
542
|
+
# help: `see teams`
|
543
|
+
# help: `see team TEAM_NAME`
|
544
|
+
# help: `team TEAM_NAME`
|
545
|
+
# help: `TEAM_NAME team`
|
546
|
+
# help: `which team @USER`
|
547
|
+
# help: `which team #CHANNEL`
|
548
|
+
# help: `which team TEXT_TO_SEARCH_ON_INFO`
|
549
|
+
# help: `which team does @USER belongs to?`
|
550
|
+
# help: It will display all teams or the team specified.
|
551
|
+
# help: In case a specific team it will show also the availability of the members.
|
552
|
+
# help: Examples:
|
553
|
+
# help: _see teams_
|
554
|
+
# help: _see team Sales_
|
555
|
+
# help: _Dev team_
|
556
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
557
|
+
# help: command_id: :see_teams
|
558
|
+
# help:
|
559
|
+
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
|
560
|
+
name = $1.to_s.downcase
|
561
|
+
see_teams(user, name)
|
562
|
+
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
|
563
|
+
search = $3.to_s.downcase
|
564
|
+
see_teams(user, '', search)
|
565
|
+
|
566
|
+
# help: ----------------------------------------------
|
567
|
+
# help: `update team TEAM_NAME NEW_TEAM_NAME`
|
568
|
+
# help: `update team TEAM_NAME : NEW_INFO`
|
569
|
+
# help: `update team TEAM_NAME add MEMBER_TYPE @USER`
|
570
|
+
# help: `update team TEAM_NAME add CHANNEL_TYPE #CHANNEL`
|
571
|
+
# help: `update team TEAM_NAME delete MEMBER_TYPE @USER`
|
572
|
+
# help: `update team TEAM_NAME delete CHANNEL_TYPE #CHANNEL`
|
573
|
+
# help: `update team TEAM_NAME delete @USER`
|
574
|
+
# help: `update team TEAM_NAME delete #CHANNEL`
|
575
|
+
# help: It will update a team with the info supplied.
|
576
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to update a team.
|
577
|
+
# help: Examples:
|
578
|
+
# help: _update team sales salesff_
|
579
|
+
# help: _update team salesff : Support for customers_
|
580
|
+
# help: _update sales team delete @sarah @peter_
|
581
|
+
# help: _update team sales delete public #sales_
|
582
|
+
# help: _update team sales delete #sales_support_
|
583
|
+
# help: _update sales team add public #salesff_
|
584
|
+
# help: _update sales team add qa @john @ben @ana_
|
585
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
586
|
+
# help: command_id: :update_team
|
587
|
+
# help:
|
588
|
+
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
|
589
|
+
name = $1.downcase
|
590
|
+
new_name = $2.downcase
|
591
|
+
update_team(user, name, new_name: new_name)
|
592
|
+
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
|
593
|
+
name = $1.downcase
|
594
|
+
new_info = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/^[^:]+:\s*(.+)\s*$/im).join
|
595
|
+
update_team(user, name, new_info: new_info)
|
596
|
+
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
|
597
|
+
name = $1.downcase
|
598
|
+
delete_opts = $3
|
599
|
+
update_team(user, name, delete_opts: delete_opts)
|
600
|
+
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
|
601
|
+
name = $1.downcase
|
602
|
+
add_opts = $2
|
603
|
+
update_team(user, name, add_opts: add_opts)
|
604
|
+
|
605
|
+
# help: ----------------------------------------------
|
606
|
+
# help: `ping team TEAM_NAME MEMBER_TYPE MESSAGE`
|
607
|
+
# help: `contact team TEAM_NAME MEMBER_TYPE MESSAGE`
|
608
|
+
# help: ping: It will send the MESSAGE naming all available members of the MEMBER_TYPE supplied.
|
609
|
+
# help: contact: It will send the MESSAGE naming all members of the MEMBER_TYPE supplied.
|
610
|
+
# help: In case MEMBER_TYPE is 'all' it will name 10 random members of the team
|
611
|
+
# help: Examples:
|
612
|
+
# help: _ping team sales development How is the status on the last feature_
|
613
|
+
# help: _contact team sales qa Please finish testing of dev02 feature before noon_
|
614
|
+
# help: _contact team qa all Check the test failures please_
|
615
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
616
|
+
# help: command_id: :ping_team
|
617
|
+
# help: command_id: :contact_team
|
618
|
+
# help:
|
619
|
+
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
|
620
|
+
type = $1.downcase.to_sym
|
621
|
+
name = $2.downcase
|
622
|
+
member_type = $3.downcase
|
623
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[\w]+\s+\w+\s+team\s+[\w\-]+\s+(.+)\s*\z/im).join
|
624
|
+
if message == ''
|
625
|
+
message = Thread.current[:command_orig].to_s.gsub("\u00A0", " ").scan(/\A\s*[\w]+\s+team\s+\w+\s+[\w\-]+\s+(.+)\s*\z/im).join
|
626
|
+
end
|
627
|
+
ping_team(user, type, name, member_type, message)
|
628
|
+
|
629
|
+
# help: ----------------------------------------------
|
630
|
+
# help: `delete team TEAM_NAME`
|
631
|
+
# help: It will delete the supplied team.
|
632
|
+
# help: You have to be a member of the team, the creator or a Master admin to be able to delete a team.
|
633
|
+
# help: Examples:
|
634
|
+
# help: _delete team sales_
|
635
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
636
|
+
# help: command_id: :delete_team
|
637
|
+
# help:
|
638
|
+
when /\A\s*(delete|remove)\s+team\s+([\w\-]+)\s*\z/i, /\A\s*(delete|remove)\s+([\w\-]+)\s+team\s*\z/i
|
639
|
+
name = $2.downcase
|
640
|
+
delete_team(user, name)
|
641
|
+
|
642
|
+
# help: ----------------------------------------------
|
643
|
+
# help: `see MEMO_TYPE from TEAM_NAME team`
|
644
|
+
# help: `see MEMO_TYPE from TEAM_NAME team TOPIC`
|
645
|
+
# help: `see all memos from TEAM_NAME team`
|
646
|
+
# help: `see all memos from TEAM_NAME team TOPIC`
|
647
|
+
# help: It will show the memos of the team.
|
648
|
+
# help: If TOPIC is supplied it will show the memos of the topic.
|
649
|
+
# help: MEMO_TYPE: memos, notes, issues, tasks, features, bugs, jira, github. In case of 'all memos' will display all of any type.
|
650
|
+
# help: Examples:
|
651
|
+
# help: _see memos from sales team_
|
652
|
+
# help: _see bugs from sales team_
|
653
|
+
# help: _see all memos from sales team webdev_
|
654
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#teams|more info>
|
655
|
+
# help: command_id: :see_memos_team
|
656
|
+
# help:
|
657
|
+
when /\A\s*(see\s+)?(memo|note|issue|task|feature|bug|jira|github|all\s+memo)s?\s+(from\s+)?([\w\-]+)\s+team(.*)\s*\z/i,
|
658
|
+
/\A\s*(see\s+)?(memo|note|issue|task|feature|bug|jira|github|all\s+memo)s?\s+(from\s+)?team\s+([\w\-]+)(.*)\s*\z/i
|
659
|
+
type = $2.downcase.to_sym
|
660
|
+
name = $4.downcase
|
661
|
+
topic = $5.strip
|
662
|
+
see_memos_team(user, type: type, name: name, topic: topic)
|
663
|
+
|
664
|
+
# help: ----------------------------------------------
|
665
|
+
# help: `add vacation from YYYY/MM/DD to YYYY/MM/DD`
|
666
|
+
# help: `add vacation YYYY/MM/DD`
|
667
|
+
# help: `add sick from YYYY/MM/DD to YYYY/MM/DD`
|
668
|
+
# help: `add sick YYYY/MM/DD`
|
669
|
+
# help: `add sick child YYYY/MM/DD`
|
670
|
+
# help: `I'm sick today`
|
671
|
+
# help: `I'm on vacation today`
|
672
|
+
# help: It will add the supplied period to your plan.
|
673
|
+
# help: Instead of YYYY/MM/DD you can use 'today' or 'tomorrow' or 'next week'
|
674
|
+
# help: To see your plan call `see my time off`
|
675
|
+
# help: If you want to see the vacation plan for the team `see team NAME`
|
676
|
+
# help: Also you can see the vacation plan for the team for a specific period: `vacations team NAME YYYY/MM/DD`
|
677
|
+
# help: The SmartBot will automatically set the users status to :palm_tree:, :baby: or :face_with_thermometer: and the expiration date.
|
678
|
+
# help: Examples:
|
679
|
+
# help: _add vacation from 2022/10/01 to 2022/10/22_
|
680
|
+
# help: _add sick 2022/08/22_
|
681
|
+
# help: _add vacation tomorrow_
|
682
|
+
# help: _I'll be on vacation next week_
|
683
|
+
# help: _add sick baby today_
|
684
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
685
|
+
# help: command_id: :add_vacation
|
686
|
+
# help:
|
687
|
+
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,
|
688
|
+
/\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,
|
689
|
+
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d-\d\d-\d\d)()\s*\z/i,
|
690
|
+
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(\d\d\d\d\/\d\d\/\d\d)()\s*\z/i,
|
691
|
+
/\A\s*(add)\s+(sick|vacation|sick\s+baby|sick\s+child)\s+(today|tomorrow|next\sweek)()\s*\z/i,
|
692
|
+
/\A\s*(I'm|I\s+am|I'll\s+be|I\s+will\s+be)\s+(sick|on\s+vacation)\s+(today|tomorrow|next\sweek)()\s*\z/i
|
693
|
+
type = $2
|
694
|
+
from = $3.downcase
|
695
|
+
to = $4
|
696
|
+
type = 'vacation' if type.match?(/vacation/)
|
697
|
+
add_vacation(user, type, from, to)
|
698
|
+
|
699
|
+
# help: ----------------------------------------------
|
700
|
+
# help: `remove vacation ID`
|
701
|
+
# help: `remove vacation period ID`
|
702
|
+
# help: `remove sick period ID`
|
703
|
+
# help: `remove time off period ID`
|
704
|
+
# help: `delete vacation ID`
|
705
|
+
# help: It will remove the specified period from your vacations/sick periods.
|
706
|
+
# help: Examples:
|
707
|
+
# help: _remove vacation 20_
|
708
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
709
|
+
# help: command_id: :remove_vacation
|
710
|
+
# help:
|
711
|
+
when /\A\s*(delete|remove)\s+(vacation|sick|time\s+off)(\s+period)?\s+(\d+)\s*\z/i
|
712
|
+
vacation_id = $4
|
713
|
+
remove_vacation(user, vacation_id)
|
714
|
+
|
715
|
+
# help: ----------------------------------------------
|
716
|
+
# help: `see my vacations`
|
717
|
+
# help: `see my time off`
|
718
|
+
# help: `see vacations @USER`
|
719
|
+
# help: `see my vacations YEAR`
|
720
|
+
# help: It will display current and past time off.
|
721
|
+
# help: If you call this command on a DM, it will show your vacations for the year on a calendar.
|
722
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
723
|
+
# help: command_id: :see_vacations
|
724
|
+
# help:
|
725
|
+
when /\A\s*see\s+my\s+vacations\s*()\s*(\d{4})?\s*\z/i,
|
726
|
+
/\A\s*see\s+my\s+time\s+off\s*()\s*(\d{4})?\s*\z/i,
|
727
|
+
/\A\s*see\s+time\s+off\s+<@(\w+)>\s*\s*(\d{4})?\s*\z/i,
|
728
|
+
/\A\s*see\s+vacations\s+<@(\w+)>\s*(\d{4})?\s*\z/i
|
729
|
+
from_user = $1
|
730
|
+
year = $2
|
731
|
+
react :running
|
732
|
+
see_vacations(user, dest, from_user: from_user, year: year)
|
733
|
+
unreact :running
|
734
|
+
|
735
|
+
# help: ----------------------------------------------
|
736
|
+
# help: `vacations team NAME`
|
737
|
+
# help: `time off team NAME`
|
738
|
+
# help: `vacations team NAME YYYY/MM/DD`
|
739
|
+
# help: `time off team NAME YYYY/MM/DD`
|
740
|
+
# help: It will display the time off plan for the team specified.
|
741
|
+
# help: <https://github.com/MarioRuiz/slack-smart-bot#time-off-management|more info>
|
742
|
+
# help: command_id: :see_vacations_team
|
743
|
+
# help:
|
744
|
+
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,
|
745
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+([\w\-]+)\s+team\s*(\d\d\d\d\/\d\d\/\d\d)?\s*\z/i,
|
746
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+team\s+([\w\-]+)\s*(\d\d\d\d-\d\d-\d\d)?\s*\z/i,
|
747
|
+
/\A\s*(see\s+)?(vacations|time\s+off)\s+([\w\-]+)\s+team\s*(\d\d\d\d-\d\d-\d\d)?\s*\z/i
|
748
|
+
team_name = $3.downcase
|
749
|
+
date = $4.to_s
|
750
|
+
date = Date.today.strftime("%Y/%m/%d") if date.empty?
|
751
|
+
react :running
|
752
|
+
see_vacations_team(user, team_name, date)
|
753
|
+
unreact :running
|
754
|
+
|
755
|
+
# help: ----------------------------------------------
|
756
|
+
# help: `public holidays COUNTRY`
|
757
|
+
# help: `public holidays COUNTRY/STATE DATE`
|
758
|
+
# help: `calendar COUNTRY`
|
759
|
+
# help: `calendar COUNTRY/STATE DATE`
|
760
|
+
# help: It will display the public holidays for the country specified.
|
761
|
+
# help: If calendar then it will show the calendar for the country specified.
|
762
|
+
# help: STATE: optional. If not specified, it will return all the holidays for the country.
|
763
|
+
# help: DATE: optional. It can be supplied as YYYY or YYYY-MM or YYYY-MM-DD. If not specified, it will return all the holidays for current year.
|
764
|
+
# help: Examples:
|
765
|
+
# help: _public holidays United States_
|
766
|
+
# help: _public holidays United States/California_
|
767
|
+
# help: _public holidays United States/California 2023_
|
768
|
+
# help: _public holidays Iceland 2023-12_
|
769
|
+
# help: _public holidays India 2023-12-25_
|
770
|
+
# help: _calendar United States/California_
|
771
|
+
# help: command_id: :public_holidays
|
772
|
+
# help: command_id: :calendar_country
|
773
|
+
# help:
|
774
|
+
when /\A\s*(public\s+)?(holiday?|vacation|calendar)s?\s+(in\s+|on\s+)?([a-zA-Z\s]+)()()()()\s*\z/i,
|
775
|
+
/\A\s*(public\s+)?(holiday?|vacation|calendar)s?\s+(in\s+|on\s+)?([a-zA-Z\s]+)\/([a-zA-Z\s]+)()()()\s*\z/i,
|
776
|
+
/\A\s*(public\s+)?(holiday?|vacation|calendar)s?\s+(in\s+|on\s+)?([a-zA-Z\s]+)\/([a-zA-Z\s]+)\s+(\d{4})[\/\-]?(\d\d)?[\/\-]?(\d\d)?\s*\z/i,
|
777
|
+
/\A\s*(public\s+)?(holiday?|vacation|calendar)s?\s+(in\s+|on\s+)?([a-zA-Z\s]+)()\s+(\d{4})[\/\-]?(\d\d)?[\/\-]?(\d\d)?\s*\z/i
|
778
|
+
type = $2.downcase
|
779
|
+
country = $4
|
780
|
+
state = $5.to_s
|
781
|
+
year = $6.to_s
|
782
|
+
month = $7.to_s
|
783
|
+
day = $8.to_s
|
784
|
+
year = Date.today.year if year.to_s == ''
|
785
|
+
if type == 'calendar'
|
786
|
+
save_stats :calendar_country
|
787
|
+
state = "/#{state.downcase}" if state.to_s != ''
|
788
|
+
display_calendar('', year, country_region: "#{country.downcase}#{state}")
|
789
|
+
else
|
790
|
+
public_holidays(country, state, year, month, day)
|
791
|
+
end
|
792
|
+
|
793
|
+
# help: ----------------------------------------------
|
794
|
+
# help: `set public holidays to COUNTRY/STATE`
|
795
|
+
# help: It will set the public holidays for the country and state specified.
|
796
|
+
# help: If STATE is not specified, it will set the public holidays for the country.
|
797
|
+
# help: Examples:
|
798
|
+
# help: _set public holidays to Iceland_
|
799
|
+
# help: _set public holidays to United States/California_
|
800
|
+
# help: command_id: :set_public_holidays
|
801
|
+
# help:
|
802
|
+
when /\A\s*set\s+public\s+(holiday?|vacation)s?\s+to\s+([^\/]+)\/([^\/]+)\s*\z/i,
|
803
|
+
/\A\s*set\s+public\s+(holiday?|vacation)s?\s+to\s+([^\/]+)\s*\z/i
|
804
|
+
country = $2
|
805
|
+
state = $3.to_s
|
806
|
+
set_public_holidays(country, state, user)
|
807
|
+
|
808
|
+
# help: ----------------------------------------------
|
809
|
+
# help: `set personal settings SETTINGS_ID VALUE`
|
810
|
+
# help: `delete personal settings SETTINGS_ID`
|
811
|
+
# help: `get personal settings SETTINGS_ID`
|
812
|
+
# help: `get personal settings`
|
813
|
+
# help: It will set/delete/get the personal settings supplied for the user.
|
814
|
+
# help: Examples:
|
815
|
+
# help: _set personal settings ai.open_ai.access_token Xd33-343sAAddd42-3JJkjC0_
|
816
|
+
# help: command_id: :set_personal_settings
|
817
|
+
# help: command_id: :delete_personal_settings
|
818
|
+
# help: command_id: :get_personal_settings
|
819
|
+
# help:
|
820
|
+
when /\A\s*(set)\s+personal\s+(setting|config)s?\s+([\w\.]+)(\s*=?\s*)(.+)\s*\z/i,
|
821
|
+
/\A\s*(delete|get)\s+personal\s+(setting|config)s?\s+([\w\.]+)()()\s*\z/i,
|
822
|
+
/\A\s*(get)\s+personal\s+(setting|config)s?()()()\s*\z/i
|
823
|
+
settings_type = $1.downcase.to_sym
|
824
|
+
settings_id = $3.downcase
|
825
|
+
settings_value = $5.to_s
|
826
|
+
personal_settings(user, settings_type, settings_id, settings_value)
|
677
827
|
|
678
828
|
# help: ----------------------------------------------
|
679
|
-
# help: `
|
680
|
-
# help:
|
681
|
-
# help:
|
682
|
-
# help:
|
683
|
-
# help:
|
684
|
-
# help:
|
685
|
-
# help:
|
686
|
-
# help:
|
687
|
-
# help:
|
688
|
-
|
689
|
-
/\A\s
|
690
|
-
|
691
|
-
|
692
|
-
from_user = $1
|
693
|
-
year = $2
|
694
|
-
see_vacations(user, dest, from_user: from_user, year: year)
|
829
|
+
# help: `?w`
|
830
|
+
# help: `?w PROMPT`
|
831
|
+
# help: OpenAI: It will transcribe the audio file attached and performed the PROMPT indicated if supplied.
|
832
|
+
# help: Examples:
|
833
|
+
# help: _?w_
|
834
|
+
# help: _?w translate to spanish_
|
835
|
+
# help: _?w summarize_
|
836
|
+
# help: _?w translate to english and summarize_
|
837
|
+
# help: command_id: :open_ai_whisper
|
838
|
+
# help:
|
839
|
+
when /\A\s*\?w()\s*\z/im, /\A\s*\?w\s+(.+)\s*\z/im
|
840
|
+
message = $1.to_s.downcase
|
841
|
+
open_ai_whisper(message,files)
|
695
842
|
|
696
843
|
# help: ----------------------------------------------
|
697
|
-
# help: `
|
698
|
-
# help:
|
699
|
-
# help:
|
700
|
-
# help:
|
701
|
-
# help:
|
702
|
-
# help:
|
703
|
-
# help: command_id: :
|
704
|
-
# help:
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
/\A\s*(see\s+)?(vacations|time\s+off)\s+([\w\-]+)\s+team\s*(\d\d\d\d-\d\d-\d\d)?\s*\z/i
|
709
|
-
team_name = $3.downcase
|
710
|
-
date = $4.to_s
|
711
|
-
date = Date.today.strftime("%Y/%m/%d") if date.empty?
|
712
|
-
see_vacations_team(user, team_name, date)
|
713
|
-
|
844
|
+
# help: `?m`
|
845
|
+
# help: `?m MODEL`
|
846
|
+
# help: OpenAI: It will return the list of models available or the details of the model indicated.
|
847
|
+
# help: Examples:
|
848
|
+
# help: _?m_
|
849
|
+
# help: _?m gpt-3.5-turbo_
|
850
|
+
# help: command_id: :open_ai_models
|
851
|
+
# help:
|
852
|
+
when /\A\s*\?m()\s*\z/im, /\A\s*\?m\s+(.+)\s*\z/im
|
853
|
+
model = $1.to_s.downcase
|
854
|
+
open_ai_models(model)
|
714
855
|
|
715
856
|
# help: ----------------------------------------------
|
716
|
-
# help:
|
717
|
-
# help:
|
718
|
-
# help:
|
719
|
-
# help:
|
857
|
+
# help: `??i PROMPT`
|
858
|
+
# help: `?i PROMPT`
|
859
|
+
# help: `?ir`
|
860
|
+
# help: `?iv`
|
861
|
+
# help: `?ivNUMBER`
|
862
|
+
# help: `?ie PROMPT`
|
863
|
+
# help: OpenAI: i PROMPT -> It will generate an image based on the PROMPT indicated.
|
864
|
+
# help: If ??i is used, it will start from zero the session. If not all the previous prompts from the session will be used to generate the image.
|
865
|
+
# help: OpenAI: ir -> It will generate a new image using the session prompts.
|
866
|
+
# help: OpenAI: iv -> It will generate a variation of the last image generated.
|
867
|
+
# help: ivNUMBER -> It will generate the NUMBER of variations of the last image generated. NUMBER need to be between 1 and 9.
|
868
|
+
# help: If an image attached then it will generate the variations of the attached image.
|
869
|
+
# help: OpenAI: ie PROMPT -> It will edit the attached image with the supplied PROMPT. The supplied image need to be an image with a transparent area.
|
870
|
+
# help: The PROMPT need to explain the final result of the image.
|
720
871
|
# help: Examples:
|
721
|
-
# help:
|
722
|
-
# help:
|
723
|
-
# help:
|
724
|
-
# help:
|
725
|
-
# help:
|
726
|
-
# help: command_id: :
|
727
|
-
# help:
|
728
|
-
|
729
|
-
|
730
|
-
/\A\s*
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
872
|
+
# help: _??i man jumping from a red bridge_
|
873
|
+
# help: _?i wearing a red hat and blue shirt_
|
874
|
+
# help: _?ir_
|
875
|
+
# help: _?iv5_
|
876
|
+
# help: _?ie woman eating a blue apple_
|
877
|
+
# help: command_id: :open_ai_generate_image
|
878
|
+
# help: command_id: :open_ai_variations_image
|
879
|
+
# help: command_id: :open_ai_edit_image
|
880
|
+
# help:
|
881
|
+
when /\A\s*()\?i()\s\s*(.+)\s*\z/im, /\A\s*(\?\?)i()\s\s*(.+)\s*\z/im, /\A\s*()\?i(r)()\s*\z/im,
|
882
|
+
/\A\s*()\?i(v)()\s*\z/im, /\A\s*()\?i(v\d+)()\s*\z/im,
|
883
|
+
/\A\s*()\?i(e)\s+(.+)\s*\z/im,
|
884
|
+
/\A\s*()\?i(e)()\s*\z/im,
|
885
|
+
/\A\s*(\?\?)i()()\s*\z/im
|
886
|
+
delete_history = $1.to_s != ""
|
887
|
+
image_opt = $2.to_s.downcase
|
888
|
+
message = $3.to_s
|
889
|
+
if image_opt == '' or image_opt == 'r'
|
890
|
+
open_ai_generate_image(message, delete_history, repeat: image_opt=='r')
|
891
|
+
elsif image_opt.match?(/v\d*/i)
|
892
|
+
variations = image_opt.match(/v(\d*)/i)[1].to_i
|
893
|
+
open_ai_variations_image(message, variations, files)
|
894
|
+
elsif image_opt == 'e'
|
895
|
+
open_ai_edit_image(message, files)
|
896
|
+
end
|
897
|
+
|
740
898
|
# help: ----------------------------------------------
|
741
|
-
# help:
|
742
|
-
# help:
|
743
|
-
# help:
|
899
|
+
# help: `??`
|
900
|
+
# help: `?? PROMPT`
|
901
|
+
# help: `? PROMPT`
|
902
|
+
# help: OpenAI: Chat GPT will generate a response based on the PROMPT indicated.
|
903
|
+
# help: If ?? is used, it will start from zero the session. If not all the previous prompts from the session will be used to generate the response.
|
904
|
+
# help: You can share a message and use it as input for the supplied PROMPT.
|
744
905
|
# help: Examples:
|
745
|
-
# help:
|
746
|
-
# help:
|
747
|
-
# help:
|
906
|
+
# help: _??_
|
907
|
+
# help: _?? How much is two plus two_
|
908
|
+
# help: _? multiply it by pi number_
|
909
|
+
# help: command_id: :open_ai_chat
|
748
910
|
# help:
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
911
|
+
when /\A\s*(\?\?)\s*()\z/im, /\A\s*(\?\?)\s*(.+)\s*\z/im, /\A\s*()\?\s*(.+)\s*\z/im
|
912
|
+
delete_history = $1.to_s != ''
|
913
|
+
message = $2.to_s
|
914
|
+
#@logger.info "data: #{data}" #Jal
|
915
|
+
open_ai_chat(message, delete_history)
|
916
|
+
|
917
|
+
|
918
|
+
else
|
919
|
+
return false
|
920
|
+
end
|
921
|
+
return true
|
922
|
+
rescue => exception
|
923
|
+
if defined?(@logger)
|
924
|
+
@logger.fatal exception
|
925
|
+
respond "Unexpected error!! Please contact an admin to solve it: <@#{config.admins.join(">, <@")}>"
|
926
|
+
else
|
927
|
+
puts exception
|
928
|
+
end
|
756
929
|
return false
|
757
930
|
end
|
758
|
-
return true
|
759
|
-
rescue => exception
|
760
|
-
if defined?(@logger)
|
761
|
-
@logger.fatal exception
|
762
|
-
respond "Unexpected error!! Please contact an admin to solve it: <@#{config.admins.join(">, <@")}>"
|
763
|
-
else
|
764
|
-
puts exception
|
765
|
-
end
|
766
|
-
return false
|
767
931
|
end
|
768
932
|
end
|