Deleting tweets and likes in C#

#c-sharp #twitter #api #automation #github

Written by Anders Marzi Tornblad

I am not very active on Twitter, and I'm mostly there to follow some people in tech and politics that interest me. Sometimes I react to content by liking or retweeting things, and sometime I click "like" as a way to just save that content for later. I very rarely tweet things of my own.

I don't really want to keep too much stuff laying around in my profile, so every now and then I delete old tweets and likes using various free online services, like TweetDelete. One problem with doing this is that I have to give access to my Twitter account to some service that I don't have any insight into. I'm not accusing any service of misusing my Twitter data, but any such service is a potential threat to my security and integrity, especially non-open-source services.

Also, those services don't offer me the flexibility I want. For example, the more popular a tweet is (the more likes and retweets it has) the longer I would like to keep it.So I thought I would write a tool myself, that could delete old tweets and likes, based on their amount of interaction.

Reinventing the wheel

I decided to write this in C# and .NET 5 and run it in GitHub Actions as a scheduled event. After some googling, I found a .NET 5 Twitter API component that I would use, called Tweetinvi.

The latest version of the code is always available in the GitHub repository.