Awesome
shelltwit
shelltwit updates your twitter status while at the command line.
It's a good example of twitter API calls with xAuth. As of Jun-05-2017 it uses PIN-based authorization
shelltwit running on Windows
shelltwit running on Linux (WSL2)
Little more (?) info about it at the original blog post
Build
The repo contains a single .NET solution, which reference newly created twitterlib NuGet package. After downloading the repo just build the sln with Visual Studio 2019 (or higher). You can also use VSCode and use the ./build.sh script for building the project.
This build has been tested on Ubuntu WSL, Windows and MacOs, so it works on my machine.
After building the code just run it as you would usually run a dotnet console app:
dotnet Sebagomez.Shelltwit.dll
For obvious security reasons I don't have the app Key and Secrets embeded in the code. If you want to run the app with your own crdentials you can setup two Environment variables named TWITTER_API_KEY
and TWITTER_API_SECRET
. With these, shelltwit will run as your registered twitter app.
Docker
In order to build your own container you must run the following command
docker run -e "TWITTER_API_KEY=<Your Twitter Key>" -e "TWITTER_API_SECRET=<Your Twitter Secret>" -it --name twit sebagomez/shelltwit
Copy and paste the provided URL in your favorite browser, authorize the app to access twitter on your behalf and copy and paste the provided PIN in the command line waiting for it.
Now you have a container with the needed credentials to access the Twitter API.
We'll now commit those changes into a new image:
docker commit twit mytwit
And that's it, you can now call commands inside the newly created image as follows:
docker run --rm mytwit --help
🐤 Sebagomez.Shelltwit version 9.3.1.0
Copyright 2022 @SebaGomez
Usage: twit [options] | <status> [<mediaPath>]
Options:
-c|--clear clears user stored credentials
-t|--timeline [count] show user's timeline, optionally set how many twits to display (up to 200)
-q|--query <query> query twits containing words
-m|--mentions show user's mentions
-u|--user <handle> show another user's timeline
-k|--track <track> live status with a specific track
-s|--streamed <handle> streamed user timeline
-l|--likes user's likes (fka favorites)
-d|--dm <handle> <message> direct message to user
-x|--dm-list last 20 DM messages
-h|--help show this help
status:
status to update at twitter.com
mediaPath:
full path, between brackets, to the media files (up to four) to upload.
Edit: You can also use the following command to copy your existing credentials into your docker container
docker cp ./last.usr twit:/twit
docker cp ./sebagomez.data twit:/twit