Skip to content

Commit b881e9d

Browse files
committed
[slack] Add ephemeral message when select 1 found
- Basic assistance of catching raw SQL SELECT 1 and sending a "only visible to you" message for user in channel
1 parent 2072ae3 commit b881e9d

File tree

1 file changed

+11
-0
lines changed
  • desktop/core/src/desktop/lib/botserver

1 file changed

+11
-0
lines changed

desktop/core/src/desktop/lib/botserver/views.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ def handle_on_message(channel_id, bot_id, text, user_id):
9393
bot_message = 'Hi <@{user}> :wave:'.format(user=user_id)
9494
_send_message(channel_id, bot_message)
9595

96+
if text and 'select 1' in text.lower():
97+
raw_sql_message = 'Hi <@{user}>\nInstead of copy/pasting SQL, now you can send Editor links which unfurls in a rich preview!'.format(user=user_id)
98+
_send_ephemeral_message(channel_id, user_id, raw_sql_message)
99+
100+
101+
def _send_ephemeral_message(channel_id, user_id, raw_sql_message):
102+
try:
103+
slack_client.chat_postEphemeral(channel=channel_id, user=user_id, text=raw_sql_message)
104+
except Exception as e:
105+
raise PopupException(_("Error posting ephemeral message"), detail=e)
106+
96107

97108
def handle_on_link_shared(channel_id, message_ts, links, user_id):
98109
for item in links:

0 commit comments

Comments
 (0)