Last active
October 24, 2018 23:20
-
-
Save emad/7b9eb3df46a19ed0a982201cf77dbce8 to your computer and use it in GitHub Desktop.
keep my slack status in phase with the moon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.