Skip to content

Commit

Permalink
[slack] Add ephemeral message when select 1 found
Browse files Browse the repository at this point in the history
- Basic assistance of catching raw SQL SELECT 1 and sending a "only visible to you" message for user in channel
  • Loading branch information
Harshg999 committed May 6, 2021
1 parent 2072ae3 commit b881e9d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions desktop/core/src/desktop/lib/botserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ def handle_on_message(channel_id, bot_id, text, user_id):
bot_message = 'Hi <@{user}> :wave:'.format(user=user_id)
_send_message(channel_id, bot_message)

if text and 'select 1' in text.lower():
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)
_send_ephemeral_message(channel_id, user_id, raw_sql_message)


def _send_ephemeral_message(channel_id, user_id, raw_sql_message):
try:
slack_client.chat_postEphemeral(channel=channel_id, user=user_id, text=raw_sql_message)
except Exception as e:
raise PopupException(_("Error posting ephemeral message"), detail=e)


def handle_on_link_shared(channel_id, message_ts, links, user_id):
for item in links:
Expand Down

0 comments on commit b881e9d

Please sign in to comment.