Created
February 10, 2017 17:20
-
-
Save gnilchee/5e3afe162c37d012ca77429b7a511827 to your computer and use it in GitHub Desktop.
Using weatherman.py post current conditions to Slack channel using user API token.
This file contains hidden or 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
#!/usr/bin/env python3 | |
from slackclient import SlackClient | |
from configparser import ConfigParser | |
from weatherman import WeatherAPI | |
config = ConfigParser() | |
config.read('api_secrets.conf') | |
SLACK_TOKEN = config['slack']['SLACK_API_TOKEN'] | |
weather = WeatherAPI.get_current_conditions(90210) | |
announce = "[WEATHER BOT] {}".format(weather) | |
sc = SlackClient(SLACK_TOKEN) | |
sc.api_call( | |
"chat.postMessage", | |
channel="#channel", | |
text="{}".format(announce), | |
as_user=True | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment