Skip to content

Instantly share code, notes, and snippets.

@emad
Last active October 24, 2018 23:20
Show Gist options
  • Save emad/7b9eb3df46a19ed0a982201cf77dbce8 to your computer and use it in GitHub Desktop.
Save emad/7b9eb3df46a19ed0a982201cf77dbce8 to your computer and use it in GitHub Desktop.
keep my slack status in phase with the moon
import urllib
import json
import datetime
def emoji_phase(t):
emoji = [
":new_moon:", ":waxing_crescent_moon:",
":first_quarter_moon:",
":waxing_gibbous_moon:",":full_moon:",
":waning_gibbous_moon:", ":last_quarter_moon:",
":waning_crescent_moon:"]
start = datetime.datetime(1999, 8, 11)
diff = t - start
offset = int(round((diff.days % 29.530588853)/ 29.530588853 * len(emoji))) % len(emoji)
return emoji[offset]
token = "NOT-MY-ACTUAL-TOKEN"
url = "https://slack.com/api/users.profile.set"
data = json.dumps(dict(
status_emoji=emoji_phase(datetime.datetime.now()),
status_text= "book 2 of the emad chronicles"))
args = dict(token=token, profile=data)
print url + '?' + urllib.urlencode(args)
@emad
Copy link
Author

emad commented Oct 24, 2018

To create an access token, create an app (https://api.slack.com/apps) and give it Modify user’s profile users.profile:write permission.
Install that into your workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment