/swarm_to_slack_with_twitter.py Secret
Last active
March 28, 2017 02:27
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
from parse import * | |
from twitter import Api | |
import slackweb | |
api = Api( | |
consumer_key='****', | |
consumer_secret='****', | |
access_token_key='****', | |
access_token_secret='****' | |
) | |
def post(location): | |
# Web integration のURL | |
slack = slackweb.Slack(url="https://hooks.slack.com/services/********") | |
slack.notify(text="僕は今、{location}にいるよ".format(location=location), channel="#times_mizuki") | |
def main(): | |
for line in api.GetUserStream(): | |
if 'source' in line and 'Foursquare' in line['source']: | |
res = parse("I'm at {} https:{}", line['text']) | |
if res: | |
post(res[0].split(" in ")[0]) | |
else: | |
res = parse("{}(@ {}){}", line['text']) | |
if res: | |
post(res[1].split(" in ")[0]) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment