YoloSwagTeam / t2m

Twitter to Mastodon timeline forwarding tool
GNU General Public License v3.0
76 stars 15 forks source link

Some tweets cut-off #5

Closed ghost closed 7 years ago

ghost commented 7 years ago

Some tweets are cut-off and at the end replaced with a link to the original tweet on Twitter.

Here's an example where it goes wrong:

Here's an example where it is goes OK:

Psycojoker commented 7 years ago

Yes, this is the twitter API who is providing cut-off content sometime, I have no idea if this can easily fixed :/

ghost commented 7 years ago

That's bad news. Than I close this issue, cause I assume you can't hack the Twitter API server ;-)

ghost commented 7 years ago

I see this can maybe be fixed: https://twittercommunity.com/t/retrieve-full-tweet-when-truncated-non-retweet/75542

When using tweepy, the tweet_mode=extended part of the call is set like this: tweepy.Cursor(api.search,q='to%3ANASA', tweet_mode='extended').items(limit) That should work!

Reopening.

ghost commented 7 years ago

I found this too: https://github.com/bear/python-twitter/issues/420#issuecomment-265728214

I tried to implement this myself, but I get a lot of errors. My python knowledge is letting me down.

ghost commented 7 years ago

@Psycojoker I fixed it myself. I don't think this is the right approach for everyone, so I let you to implemented it.

Somehow this gave a syntax error on the , t = twitter.Api(**yaml.safe_load(open("conf.yaml")),tweet_mode='extended')

So I add it to a new line in conf.yaml: tweet_mode: "extended"

But now I received this error:

File "./t2m", line 92, in forward
    if i.text.startswith("@"):
AttributeError: 'NoneType' object has no attribute 'startswith'

I found the solution here: https://dev.twitter.com/overview/api/upcoming-changes-to-tweets (search for tweet_mode=extended) I had to replace i.text with i.full_text in the script.

Now it works! Tweets are not longer truncated.

I will close this issue when it is also solved for other people.

Psycojoker commented 7 years ago

Hey :)

Thanks for your investigation! I've pushed a fix on master based on your work, could you test it and tell me if it works for you plz?

ghost commented 7 years ago

Thanks. I see I needed a space after the comma.

I tested it, but there are no tweets to forward right now. But no error messages, so I'm going to close this. Thanks again!

ghost commented 7 years ago

Works!

Psycojoker commented 7 years ago

I see I needed a space after the comma.

The bug was that you've put it at the end of the argument call, after the kwargs argument (the one with **), but a kwargs argument should always be the last one.

Good news :) I'm informing the others one.

ghost commented 7 years ago

Maybe this also solved the retweet-issue #4 (although I don't use retweets anymore). I will close that and if someone they can make a new one.