Skip to content

Instantly share code, notes, and snippets.

@openfly
Created March 4, 2015 03:01
Show Gist options
  • Save openfly/9e6361b1367a027a897a to your computer and use it in GitHub Desktop.
Save openfly/9e6361b1367a027a897a to your computer and use it in GitHub Desktop.
Lemur bot for slack
#!/usr/bin/env python
import flickrapi
import time
from pyslack import SlackClient
api_key = u'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
api_secret = u'YYYYYYYYYYYYYYYYYYY'
flickr = flickrapi.FlickrAPI(api_key, api_secret)
client = SlackClient('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz')
photos = flickr.photos_search(tags='lemurs')
for photo in photos[0]:
print photo.get('title')
print photo.get('secret')
photo_id = photo.get('id')
urls = flickr.photos_getSizes(photo_id=photo_id)
imgurl = urls.find("sizes").findall("size")[1].get('source')
print imgurl
client.chat_post_message('#alt_fan_lemurs', imgurl, username='Lemurs')
{u'ok': 1, u'timestamp': u'1392000237000006'}
time.sleep(1200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment