Skip to content

A simple tweeting bot for Twitter with media and poll support

License

Notifications You must be signed in to change notification settings

blazsmaster/daily-twitter-bot

Repository files navigation

daily-twitter-bot

badge:ts-node badge:twitter-user badge:discord-user npm:package-version gh:issues gh:license

Preview

Console:

Twitter (thx for the follow 😀):

Install packages

$ npm install

You need to install nodejs version 16.x.x or higher.

Check your version:

$ node --version

Setup

Step #1

Go to Twitter for Developers and sign up to developer account.

Fill out the pages with information.

⚠️ You need to verify your phone number and email address!

Step #2

Go to Developer Portal then click on the Projects & Apps menu.

Select or create your project, then create an App. If your created it, click on it and navigate to the Keys & Tokens tab.

You will see this:

At Consumer Keys click on the Regenerate button, then click on Yes, regenrate.

API Key = CONSUMER_KEY

API Key Secret = CONSUMER_SECRET

Rename .env.EXAMPLE to .env then paste the keys into it:

CONSUMER_KEY=key
CONSUMER_SECRET=key

You got back to the previous page. Now generate Access Token and Secret for user.

Access Token = ACCESS_TOKEN

Access Token Secret = ACCESS_TOKEN_SECRET

Save your keys into .env:

ACCESS_TOKEN=key
ACCESS_TOKEN_SECRET=key

You did it! 🎉 :D

Usage

Run

Two functions in the comment at the bottom of the index.ts file.

run({ onlyOnce: true }); // set true or false (read more in index.ts)
runDaily(); // the run function but repeated every 24 hours automatically

Remove the comment from the ones you want to use.

Run the script with this command:

$ ts-node index

If not working, use this:

$ npm install ts-node typescript -g

Media files

⚠️ IMPORTANT: read meta.hint.js in data folder before doing anything.

You can put any image or video into the data folder.

After putting the files, you need to assign manually the files to descriptions and other options in meta.json.

Some example:

// text with poll
{
  "files": [],
  "text": "👋🏻 Hey there! Check out my new pic",
  "poll": {
    "duration": 120,
    "options": ["Selection A", "Selection B", "Selection C", "Selection D"]
  },
  "isTweeted": false
}
// text with media
{
  "files": ["index.jpg"],
  "text": "👋🏻 Hey there! Check out my new pic",
  "isTweeted": false
}
// only media
{
  "files": ["video.mp4"],
  "text": "",
  "isTweeted": false
}
// only text
{
  "files": [],
  "text": "👋🏻 Hey there! Check out my new pic",
  "isTweeted": false
}
// text with linebrakes
{
  "files": [],
  "text": "👋🏻 Hey there!\n\n#helloworld\nthis is another line", // multiline supported: \n for linebreak
  "isTweeted": false
}

Information

if you have any questions, just open an issue here: Issues 100% not a rick roll

About

A simple tweeting bot for Twitter with media and poll support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published