piroor / tweet.sh

Twitter client written in simple Bash script
MIT License
237 stars 46 forks source link
bash hacktoberfest shellscript twitter

tweet.sh, a Twitter client written in simple Bash script

A one-file bash script Twitter Client (depending on some helper commands). This project is mainly started to demonstrating my shell scripting skills, so only limited features of Twitter APIs are supported.

Setup

You need to prepare API keys at first. Go to the front page, create a new app, and generate a new access token.

Then put them as a key file at ~/.tweet.client.key, with the format:

MY_SCREEN_NAME=xxxxxxxxxxxxxxxxxxx
MY_LANGUAGE=xx
CONSUMER_KEY=xxxxxxxxxxxxxxxxxxx
CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

If there is a key file named tweet.client.key or .tweet.client.key in the current directory, tweet.sh will load it. Otherwise, the file ~/.tweet.client.key will be used as the default key file.

Moreover, you can give those information via environment variables without a key file.

$ export MY_SCREEN_NAME=xxxxxxxxxxxxxxxxxxx
$ export MY_LANGUAGE=xx
$ export CONSUMER_KEY=xxxxxxxxxxxxxxxxxxx
$ export CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ export ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ export ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ ./tweet.sh post "Hello!"

This form will be useful to implement a bot program.

And, this script uses some external commands. You need to install them via package system on your environment: apt, yum or something. Required commands are:

Usage

$ ./tweet.sh [command] [...arguments]

Available commands are: