-
-
Save MizukiSonoko/30628cbb2c6fe58c3e402763014c37f3 to your computer and use it in GitHub Desktop.
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