This project consists of building a twitter bot that sends daily updates of my 100 days of code progress. It should be able to help me remember to commit updates on my 100-Days-of-code Github repository while simplifying my twitting workflow to publish my progress.
- When locally executed, the program checks a specified twitter account and repo to verify the update status.
- Reads through a detailed file inside the GitHub user's fork of 100-days-of-code: https://github.com/carlosmicro/100-days-of-code
- Checks for the '**Twitter:RXDYY' mark in the repo's record to identify a valid update.
- For the specified user, It checks the correct repo update against the last update available on twitter.
- If the repo update is ahead of the twitter account, it will tweet the specified update automatically.
- If no valid message content updated is available on the repository, it will compile a report message.
- In the rare case that twitter is ahead of the GitHub repository file, the bot gives a console message. Next release feature: Bot updates the GitHub repository to match the updates.
- At the end of execution, the bot will send a detailed report of all performed actions to a specified email account.
- Ruby, HTML
- Rubocop, Stickler, Rspec
- VS Code
To get a local copy up and running, follow these simple example steps.
To deploy a fully functional local copy, you must install the following dependencies/libraries:
- Twitter API Gem: Managing Twitter search and Twitter updates (tweets)
- Octokit Github Api Gem: Wrapper used to interact with github.com
- Pony Gem: Used for email handling.
- Clone this repository in your local environment
- Located on the root of repository execute
bundle install
This action will install all the required dependencies.
See the details below to modify and include all your access keys and values in the root file .env
- Configure at the
.env
file your twitter handler and searching hash (Ideally this should be your user and 100-Days-of-code hash)
# Main variables - Change this to adjust the searching handler and searching hash
export CONFIG_USER=<@your-own-user-handler>
export CONFIG_TWEET_HASH=#100daysofCode
- Configure at the
.env
file your twitter development account and consumer/access key/secret/tokens.
For Twitter: Crete a developer's account and generate the following keys
Link for Twitter development account creation
# Twitter access values for tester_carlos account
export CONFIG_CONSUMER_KEY=<your own keys>
export CONFIG_CONSUMER_SECRET=<your own keys>
export CONFIG_ACCESS_TOKEN=<your own keys>
export CONFIG_ACCESS_TOCKEN_SECRET =<your own keys>
- Configure at the
.env
file your octokit access constants for your GitHub account
# Octokit Access Constants
export GITLOG=<github_user>
export GITPASS=<account password
export GITREPO=<github_user>/<repo name>
export FILEPATH=/<file_name_at_root>
- Configure at the
.env
file your pony email access constants.
For pony email, SMTP email server is configured in lib/robo_duties.rb file
# email - Gmail account data
export EMAIL_LOGIN=<your own login>
export EMAIL_PASS=<your own pass>
# Current SMTP email parameters are defined for GMAIL. Change them to your requirement.
def mail_init(message)
{ to: '<your own email address>',
subject: '',
headers: { 'Content-Type' => 'text/html' },
body: " #{message}",
via: :smtp, via_options: {
address: 'smtp.gmail.com',
port: '587',
user_name: EMAIL_LOGIN,
password: EMAIL_PASS,
authentication: :plain,
domain: 'gmail.com'
} }
end
- To start the program, run
bin/./main.rb
at the root of your repositories local copy
- Assuming EnviVars are correctly defined, login into the update file https://github.com/carlosmicro/100-days-of-code/blob/master/r1-log.md
- Login into the twitter test account and erase all the tweets.
- Execute the bot
bin/./main.rb
- The local prompt should show the following response:
checking last tweet update on #100daysofCodeTest for handle: @tester_carlos
failing to get a valid tweet published with #100daysofCodeTest hash... for user @tester_carlos
building into report to @tester_carlos
checking github @carlosmicro/100-days-of-code
getting : R1D14 - 'R1D14.Worked in final details of LagarBot...'
twitting available update in repo R1D14.
email sent
- Soon after this prompt is received, the twitter account should update to:
For further testing purposes, this bot could be deployed in a small server like raspberry pi 3.
In this server, a cronjob could be defined to execute the lagarbot
program every 24 hs, to ensure a daily check of progress updates to the #100-days-of-code community.
👤 Carlos Anriquez
- Github: @canriquez
- Twitter: @cranriquez
- Linkedin: linkedin
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- Twitter API Gem
- Octokit Github Api Gem
- Pony Gem
- @microverse / The Corgis
- My Family!
This project is MIT licensed.