joealcorn / TweetPoster

a reddit bot
http://www.reddit.com/u/TweetPoster
MIT License
54 stars 13 forks source link

Support for multi-part tweets? #11

Closed InfernoZeus closed 9 years ago

InfernoZeus commented 9 years ago

I couldn't find any information on whether this is already supported, but being able to detect multi-part tweets would be awesome. E.g. these two tweets:

We regret to inform that we will not be attending Starladder as we were unable to obtain our visas in time. (1/2)

The Ukrainian embassy was closed from the 1st to the 10th due to the new year (2/2)

https://twitter.com/CDECgaming/status/554940186832814080 https://twitter.com/CDECgaming/status/554940524163911680

joealcorn commented 9 years ago

It's not possible to figure out which tweet another is in response to unless they've actually replied to the tweet. Anything else is going to be error prone and probably not that useful anyway. As it stands, the bot mirrors the linked tweet as well as the chain of tweets it's a reply to, like so, which covers most cases.

InfernoZeus commented 9 years ago

I wrote up a comment about using regex to detect the (1/2) at the end, and then getting the users recent tweets and checking if the next one had (2/2), but I realised that the tweets being linked to won't always be the user's most recent tweets.

I haven't done anything with the Twitter API (or used Python in a while), but I'll have a poke around and see if I get anywhere.

InfernoZeus commented 9 years ago

I've done some very early prototyping here: https://github.com/InfernoZeus/TweetPoster/commit/9a97f3eb6680340fdc6b6640b94391b56099769b It works (http://www.reddit.com/r/InfernoZeus/comments/2soyk1/example_multipart_tweet/) but is very buggy - for example, I've no idea what will happen if subsequent parts are actually replies to the previous one. Probably post them in this order:

I also had to add in some extremely basic filtering so I could run tests in my own private subreddit.

Let me know if you have any thoughts :)