Skip to content

Instantly share code, notes, and snippets.

@Seanmatthews
Last active January 11, 2017 16:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seanmatthews/f4576232e9944c20d7d099cd34c65d5a to your computer and use it in GitHub Desktop.
Save Seanmatthews/f4576232e9944c20d7d099cd34c65d5a to your computer and use it in GitHub Desktop.
Slack user keepalive
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sean.python.slacktive</string>
<key>Program</key>
<string>/Users/sean/src/slacktive/slacktive.py</string>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
  1. Put slacktive.py somewhere on your system, then change the path in slacktive.plist
  2. Put com.sean.python.slacktive.plist in ~/Library/LaunchAgents/
  3. Add your token to com.sean.python.slacktive.plist (see file comments)
  4. launchctl load ~/Library/LaunchAgents/com.sean.python.slactive.plist
import os
import time
from requests import post
while True:
# Replace x's with your user token.
# Token available from https://api.slack.com/docs/oauth-test-tokens
r = post("https://slack.com/api/users.setActive", data = {'token': 'xxxxxxxxxxxxxxxxx'})
if r.status_code is not 200:
break
time.sleep(25*60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment