Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Slack Deleted Message logged
from slackclient import SlackClient
from datetime import datetime
import time
slack_token = 'xoxb-token-goes-here'
sc = SlackClient(slack_token)
if sc.rtm_connect():
while True:
events = sc.rtm_read()
for event in events:
if event['type'] == 'message' and 'subtype' in event and event['subtype'] == 'message_deleted':
prev_msg = event['previous_message']
user_info = sc.api_call("", user=prev_msg['user'])
username = user_info['user']['name']
with open('/home/joe/www/slack/deleted.html', 'a') as lf:
lf.write("<p><b>{}</b> ({}) (deleted at <i>{}</i>): {}</p>\n".format(user_info['user']['real_name'], user_info['user']['name'],, prev_msg['text']))
except Exception:
print("error occured, having a nap and then marching on")
print("Connection Failed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.