Permalink
Please sign in to comment.
Showing
with
369 additions
and 107 deletions.
- +36 −0 default.json
- +29 −0 fetchChannelId.py
- +144 −54 slackbotExercise.py
- +160 −53 slackbotExercise.py.orig
36
default.json
| @@ -0,0 +1,36 @@ | ||
| +{ | ||
| + "teamDomain": "yourDomainHere", | ||
| + "channelName": "general", | ||
| + "channelId": "channelIdHere", | ||
| + "timeBetweenCallouts": { | ||
| + "minTime": 5, | ||
| + "maxTime": 15, | ||
| + "units": "minutes" | ||
| + }, | ||
| + "exercises": [ | ||
| + { | ||
| + "name": "pushups", | ||
| + "minReps": 15, | ||
| + "maxReps": 20, | ||
| + "units": "reps" | ||
| + }, | ||
| + { | ||
| + "name": "planks", | ||
| + "minReps": 40, | ||
| + "maxReps": 60, | ||
| + "units": "seconds" | ||
| + }, | ||
| + { | ||
| + "name": "wall sit", | ||
| + "minReps": 30, | ||
| + "maxReps": 50, | ||
| + "units": "seconds" | ||
| + }, | ||
| + { | ||
| + "name": "chair dips", | ||
| + "minReps": 15, | ||
| + "maxReps": 30, | ||
| + "units": "reps" | ||
| + } | ||
| + ] | ||
| +} |
| @@ -0,0 +1,29 @@ | ||
| +''' | ||
| +A quick script to fetch the id of a channel you want to use. | ||
| + | ||
| +USAGE: python fetchChannelId.py <channel_name> | ||
| +''' | ||
| + | ||
| +import requests | ||
| +import sys | ||
| +import os | ||
| +import json | ||
| + | ||
| +# Environment variables must be set with your tokens | ||
| +USER_TOKEN_STRING = os.environ['SLACK_USER_TOKEN_STRING'] | ||
| +URL_TOKEN_STRING = os.environ['SLACK_URL_TOKEN_STRING'] | ||
| + | ||
| +HASH = "%23" | ||
| + | ||
| +channelName = sys.argv[1] | ||
| + | ||
| +params = {"token": USER_TOKEN_STRING } | ||
| + | ||
| +# Capture Response as JSON | ||
| +response = requests.get("https://slack.com/api/channels.list", params=params) | ||
| +channels = json.loads(response.text, encoding='utf-8')["channels"] | ||
| + | ||
| +for channel in channels: | ||
| + if channel["name"] == channelName: | ||
| + print channel["id"] | ||
| + break |
Oops, something went wrong.
0 comments on commit
f84981c