Skip to content

Instantly share code, notes, and snippets.

@MizukiSonoko
Last active March 28, 2017 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MizukiSonoko/30628cbb2c6fe58c3e402763014c37f3 to your computer and use it in GitHub Desktop.
Save MizukiSonoko/30628cbb2c6fe58c3e402763014c37f3 to your computer and use it in GitHub Desktop.
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