This project is for building my own Twitter bot that publishes different famous quotes with a random emoji on Twitter feed every hour. It's built with a Twitter gem. This application can be run on your local PC, and also you can deploy it with Heroku.
A list of commonly used resources that I find helpful is listed in the acknowledgments.
- About the Project
- Sample Bot
- Getting Started
- How to use
- Author
- Contributing
- Show your support
- License
- Acknowledgements
To get a local copy up and running follow these simple example steps.
- On the project GitHub page, navigate to the main page of the repository.
- Under the repository name, locate and click on a green button named
Code
. - Copy the project URL as displayed.
- If you're running the Windows Operating System, open your command prompt. On Linux, Open your terminal.
- Change the current working directory to the location where you want the cloned directory to be made. Leave as it is if the current location is where you want the project to be.
- Type git clone, and then paste the URL you copied in Step 3.
e.g. $ git clone https://github.com/yourUsername/yourProjectName - Press Enter. Your local copy will be created.
- Go to Twitter account for developers, and Login or Signup
- Scroll down and click "Get started"
- Click "Apply for a developer account", then move to Developer Portal
- In the "Standalone Apps" section, click "Create App"
- Answer some required questions so that you can create your first Twitter App
- Once you create it, go back to Developer Portal and click the setting icon next to the App name that you just created
- In the "Settings" section, change the "App permissions" into "Read and Write"
- Click the "keys and tokens" tab on top of the page, then copy and save API key & secret(consumer key and secret) and Access token & secret
- Create your Twitter App following the above section
- On your computer, open the terminal and go to the project folder eg:
cd Desktop/my-twitter-bot
- On your terminal, enter
bundle install
- Go to bin/main.rb and replace ENV['...'] into your real Keys and tokens that you just saved in the step 8 on above direction
- Enter
ruby ./bin/main.rb
to run the code - Go to your Twitter feed and check if the tweet is correctly tweeted
- On your local computer, go to the folder you just cloned or downloaded, and enter
git init
in your Terminal or Comand Prompt - Create a Github repo for your project and register it as your remote repository
eg:
git remote add YOUR_REPOSITORY_PATH
- Login or create an account for Heroku
- Go to the personal dashboard and click "New > Create new app"
- Enter the App name and create it
- Go to "Config Vars" in the "Settings" tab, and add your Twitter App's keys and tokens that you just saved in the step 8 on above direction
- On your bin/main.rb file, replace the client config from real keys and tokens to like 'ENV['KEYS TITLE']'
- Now, commit your files and push it to your Github repository
eg:
git add -A
,git commit -m "some comments"
,git push origin branch_name
- Go to "Deployment method" in the "Deploy" tab, and connect your Github repo of your project
- Click deploy and check your Twitter account to make sure if it publishes your bot tweet correctly
- Go to the line
sleep
inside a loop in bin/main.rb - Now, it's set 3600 that means it's done every 1 hour, you can change the number whatever you like to set the interval
- It's based on the second, so if you want to post your tweet every 1 min, you can change the number to 60 eg:
sleep 60
👤 Yoko Saka
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Give a ⭐️ if you like this project!
This project is MIT licensed.