python-twitter icon indicating copy to clipboard operation
python-twitter copied to clipboard

How to remove preview from a tweet that contain a link ?

Open bitsycore opened this issue 5 years ago • 5 comments

Hello

I have a bot that tweet commits from a github git with the commit message and a link to the commit. But there is the annoying preview and I can't find how to remove it. Any idea and way of doing it ?

Thank's

bitsycore avatar Feb 12 '20 13:02 bitsycore

I have looked into this and it seems if you add HTTPS:// before the link it will not show in the tweet but it will also not create a body text! Let me know if this works for you.

For example: Google.com will create a preview but https://google.com will not.

Bracciata avatar May 12 '20 16:05 Bracciata

I had https in the link since the start :/ https://twitter.com/GodotCommits

bitsycore avatar May 12 '20 16:05 bitsycore

Do you mind posting a snippet of the code?

Bracciata avatar May 12 '20 16:05 Bracciata

Ahhh I see. So for Google.com it fixes it. For youtube.com there is never a preview and for Github it does not. I will continue to look into this.

Bracciata avatar May 12 '20 16:05 Bracciata

Yeah no prob here a "simplified" version

def format_commit_message(commits):
	return commits.message + " " if len(commits.message) < 200 else commits.message[0:200] + " ... "

api.PostUpdate(format_commit_message(commits) + repo.remotes.origin.url + "/commit/" + commits.hexsha)
# repo.remotes.origin.url = https://github.com/godotengine/godot

# if config.log:
## Log
print("------------------------------------")
print(format_commit_message(commits))
print("URL : " + repo.remotes.origin.url + "/commit/" + commits.hexsha)

# Example log output
# Add WebSocket debugger, use it for Javascript.
#
# URL : https://github.com/godotengine/godot/commit/3097c2da963fe355c81816a74824170b6dce697c

bitsycore avatar May 12 '20 16:05 bitsycore