Skip to content

Instantly share code, notes, and snippets.

@lukasvermeer
Last active August 29, 2015 14:12
Show Gist options
  • Save lukasvermeer/a070038c5ba3b16b21f0 to your computer and use it in GitHub Desktop.
Save lukasvermeer/a070038c5ba3b16b21f0 to your computer and use it in GitHub Desktop.
Johan envisioned a Twitter bot that introduces people who say "X, said no one ever" to people who've said X. Here's a start.
Max:Said No One Ever lukas$ date && python ___SNOE.py
Thu Dec 25 13:50:35 CET 2014
---
@ezafar3 Tweeted: "Awesome weather today #SaidNoOneEver"
- http://twitter.com/ezafar3/status/548089419648208896
@BrittanyRiitano Said: "Melbourne definitely delivered the awesome weather today for chrissy!"
- http://twitter.com/BrittanyRiitano/status/548012278457446400
---
@ezafar3 Tweeted: "Awesome weather today #SaidNoOneEver"
- http://twitter.com/ezafar3/status/548089419648208896
@edwardyyh Said: "Thank God for this awesome weather today, perfect day to just relax on the bed, drink and listen to music. http://t.co/BYlieq2QRA"
- http://twitter.com/edwardyyh/status/547944805074878464
---
@Lisamccabe62 Tweeted: "Diet starts today.... #SaidNoOneEver"
- http://twitter.com/Lisamccabe62/status/548063122725281792
@cloneywill Said: "my diet starts today :) #christmasdrinks !!! http://t.co/4GJ89cjT3f"
- http://twitter.com/cloneywill/status/548074970543562752
---
@Lisamccabe62 Tweeted: "Diet starts today.... #SaidNoOneEver"
- http://twitter.com/Lisamccabe62/status/548063122725281792
@_cokahina Said: "it's Christmas meaning my prom diet starts today 😭 see ya when i have Chanel Iman's exact figure"
- http://twitter.com/_cokahina/status/548008028877094912
---
@Lisamccabe62 Tweeted: "Diet starts today.... #SaidNoOneEver"
- http://twitter.com/Lisamccabe62/status/548063122725281792
@iamkretlemmor Said: "and my diet starts today, seriously 😊"
- http://twitter.com/iamkretlemmor/status/547920434247643136
---
@Lisamccabe62 Tweeted: "Diet starts today.... #SaidNoOneEver"
- http://twitter.com/Lisamccabe62/status/548063122725281792
@juliablondieee Said: "diet starts today💪 no exceptions"
- http://twitter.com/juliablondieee/status/547827444401852416
---
@Lisamccabe62 Tweeted: "Diet starts today.... #SaidNoOneEver"
- http://twitter.com/Lisamccabe62/status/548063122725281792
@PattyCaitt Said: "My familys face when i say "my diet starts today" http://t.co/YPNaBhZ9JU"
- http://twitter.com/PattyCaitt/status/547823794879217664
# Based on https://twitter.com/jugander/status/534178436453900288
import tweepy, re
CONSUMER_KEY = '<insert key>'
CONSUMER_SECRET = '<insert secret>'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
api = tweepy.API(auth)
SNOE_STRING = ' #saidnooneever'
twts = api.search(q=SNOE_STRING)
for s in twts:
t = re.match('^(.*)'+SNOE_STRING+'$', s.text, flags=re.IGNORECASE) # Limit to tweets ending with hashtag.
rt = re.match('^RT (.*)$', s.text) # Skip RT's.
at = re.match('^.?@(.*)$', s.text) # Skip @-replies.
if t and not rt and not at:
snoes = api.search(q=t.group(1)) # Find matching tweets.
for es in snoes:
m = re.match('^(.*)'+t.group(1)+'(.*)$', es.text, flags=re.IGNORECASE)
nope = re.match('^(.*)'+SNOE_STRING+'$', es.text, flags=re.IGNORECASE)
nort = re.match('^RT (.*)$', es.text, flags=re.IGNORECASE) # Skip RT's.
if m and not nope and not nort:
print '---'
print '@' + s.user.screen_name + ' Tweeted: \"'+s.text+'\"'
print ' - http://twitter.com/' + s.user.screen_name + '/status/' + str(s.id)
print '@' + es.user.screen_name + ' Said: \"'+es.text+'\"'
print ' - http://twitter.com/' + es.user.screen_name + '/status/' + str(es.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment