Skip to content

Instantly share code, notes, and snippets.

@Seanmatthews

Seanmatthews/SLACKTIVE.md

Last active Jan 11, 2017
Embed
What would you like to do?
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