Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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