tommeagher / heroku_ebooks

An archive of a script to generate Markov chains and to post to an _ebooks account on Twitter using Heroku. No longer actively supported.
264 stars 163 forks source link

Fix Issue #7 (Drop attribution) #20

Closed sparky005 closed 7 years ago

sparky005 commented 7 years ago

Hey! This is a pull request to fix issue #7 (Drop Attribution?) The code adds another function remove_credit which takes the text of the ebook tweet and searches it to see if the second-to-last word is 'via' or 'says'. If so, it removes that and anything after. The logic here being that 'via' or 'says' style RTs will always have 'via' or 'says' as their second to last word (the last word being the username)

The function gets called twice, once after the initial ebook_tweet is generated and once again if the tweet is determined to be too short and additional text is added. This is so that if the first tweet had a 'via' credit, it still gets removed, along with the second tweet's 'via' credit (if any.)

This is my first real PR, so I welcome feedback / improvements / whatever else. Thanks!

tommeagher commented 7 years ago

Thanks for this New Year's Day pull request, @sparky005! Let me take a look at this over the next couple days to see if there's any questions I have. Then I'll try to merge as soon as I can.