GithubHelp home page GithubHelp logo

freecodecamp / 100daysofcode-twitter-bot Goto Github PK

View Code? Open in Web Editor NEW
282.0 27.0 110.0 964 KB

Twitter bot for #100DaysOfCode

Home Page: https://twitter.com/_100DaysOfCode

License: BSD 3-Clause "New" or "Revised" License

JavaScript 99.29% Procfile 0.71%
twitter-bot twitter-api nodejs 100daysofcode

100daysofcode-twitter-bot's Introduction

Helping developers who participate in #100DaysOfCode to engage on Twitter.

License (3-Clause BSD) styled with prettier Connect with us on Slack Discord GitHub issues GitHub pull requests

follow on Twitter

Features

Retweets and likes tweets

Screenshot1

Sends a thank-you reply to new followers

Screenshot2

Congratulates users on starting/finishing #100DaysOfCode

Imgur

Tweets back encouragement if a #100DaysOfCode tweet has negative sentiment

Imgur

Tracks user interaction via LevelDB to give users daily encouragement

Uses a cron-like job scheduler to tweet 'Project of the Day'

Blacklist Spammers who abuse [#100DaysOfCode]

freeCodeCamp challenges and Help Channels (such as Slack, Discord, etc.) are merged in an API to constantly tweet links for new joiners/followers


Contributing

This bot manipulates tweets and streams by connecting to the Twitter API via the twit npm package. Please refer to the twit documentation to make substantial changes.

You can help by:

  • Solving existing issues
  • Adding more functionalities to the bot (see issues)
  • Pointing out bugs/errors

For any of the above, please create an issue so that it can be addressed. New to GitHub issues? You can familiarize yourself with them using GitHub's guide.

Setup

  • You will need your own Twitter account for testing, since the bot tweets from this account. Generate your Twitter API keys by creating a new app.
  • Fork this repository.
  • Create an .env file and add in your API keys and Twitter handle, like so:
TWITTER_CONSUMER_KEY=xxxxxxxxxxxxxxxxxxxxdMhxg
TWITTER_CONSUMER_SECRET=xxxxxxxxxxxxxxxxxxxxkFNNj1H107PFv1mvWwEM6CZH0fjymV
TWITTER_ACCESS_TOKEN=xxxxxxxxx-xxxxxxxxxxxxxxxxxxxxecKpi90bFhdsGG2N7iII
TWITTER_ACCESS_TOKEN_SECRET=xxxxxxxxxxxxxxxxxxxxZAU8wNKAPU8Qz2c0PhOo43cGO
QUERY_STRING=#someTestHashtag
TWITTER_USERNAME=YourTestTwitterAccountName

Make the Change

  • Change any hashtags to #someTestHashtag to avoid spamming the community hashtag.
  • Run npm/yarn test to check all keys are available before you start. ๐Ÿ‘
  • Make your suggested change.
  • Ensure code style follows existing code (run npm run format to apply preferred formatting).
  • Create a pull request.

License

BSD 3-Clause License

Copyright (c) 2018 - Present, freeCodeCamp. All rights reserved.

100daysofcode-twitter-bot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

100daysofcode-twitter-bot's Issues

Update docs to the KCD README pattern

README pattern

Optimal README layout from Kent Dodds source:

  1. Title + tagline + logo?
  2. Badges
  3. The problem
  4. The solution
  5. TOC
  6. Installation
  7. Usage
  8. FAQ
  9. Inspiration
  10. Alternatives
  11. Contributors
  12. License

Encouragement for users not to day 100 yet

What if we had something to where the bot would encourage someone to continue their 100DaysofCode? Maybe if they haven't posted in 7+ days and haven't posted Day 100 they would get a tweet mention that encouraged them to keep on going??

Use `in_reply_to_status_id:`

For replies from the bit suggest using in_reply_to_status_id: in the reply, this will give the user a bit of context as to why the bot is tweeting them with an inspirational quote. Example here:

bot.post('statuses/update', {
  status: '@ScottDevTweets I reply to you yes!',
  in_reply_to_status_id: '860900406381211649'
}, (err, data, response) => {
  if (err) {
    console.log(err)
  } else {
    console.log(`${data.text} tweeted!`)
  }
})

A modification on this will need o be added to the sentiment.js module

Contributing needs work

The contributing.md needs to have some work done.

Can I suggest adding in how to make a PR

Maybe take details from one of @QuincyLarson's Medium articles from the guides app?

Or point to the fCC Guides app locations??

Getting this to run issue and deploying with zeit question/issue

I got this to deploy, however it's acting strange,
it's starting to build okay, but gives me an error

(node:116) UnhandledPromiseRejectionWarning: OpenError: IO error: /home/nowuser/src/src/helpers/blacklistUsersDb/LOCK: No such file or directory
    at /home/nowuser/src/node_modules/levelup/lib/levelup.js:91:23
    at /home/nowuser/src/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
    at /home/nowuser/src/node_modules/deferred-leveldown/deferred-leveldown.js:20:21
    at /home/nowuser/src/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
    at /home/nowuser/src/node_modules/abstract-leveldown/abstract-leveldown.js:41:14
(node:116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
No open port found. Make sure 'npm start' creates an HTTP server on a port (any).
More details: https://err.sh/now-cli/no-open-port-found
====================
TWEET COUNTER=100
====================
...

it seems to just loop with the tweet counter...

Any help would be appreciated!

Thanks!

Welcome bot! Respond to the user when committing to 100DaysOfCode

In the Medium article there's a call to arms where the user will tweet their commitment to the challenge:

I'm publicly committing to the 100DaysOfCode Challenge

The bot can reply with a welcome message, this is sort of an extension to the abandoned API:

#15
#66

This could be a quick win however by using stream.on('tweet' and match the specific (or exact) phrase

Blacklist these Users from Twitter

I am opening this issue to block Twitter accounts who spam #100DaysOfCode and are retweeted by the bot. Please list Twitter handlers here and will update the list in production either weekly or bi-weekly basis.

Amend slack channel url

The current slack channel url has expired

This is a good first issue

Change it to 100xcode.slack.com

Consider adding development branch

Please consider adding a development branch and possibly a branch for adding patches to

Also please consider adding the following protection on branches master, development and patch so they are protected:

image

Thanks

Remove yarn.lock file

to keep consistent use of npm over all development modes and the introduction of package-lock.json since npm@5.

Thoughts on using .stream

Thoughts on using bot.stream('statuses/filter' in place of search?

So, in place of having:

setInterval(retweet, retweetFrequency) 

Then the search function in the retweet module and the parameter passed in with the search terms. Why not have all the search terms in a search parameter?

const trackStream = bot.stream('statuses/filter', {
  track: trackWords
})
trackStream.on('tweet', retweet)

There would possibly need to be some form of filter so as not to RT absolutely everything that is tweeted, but with this method, we can track more than just 100DaysOfCode tag

Moar badges

Add Prettier badge

Add in the Prettier badge in the readme:

Add this line below the license badge>

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

For the badge to look like this: styled with prettier

Label it as a good first issue and help wanted @amandeepmittal please


Also add in the Twitter follow intent button:

Adding the following HTML into the README.me

<p>
  <a href="https://twitter.com/intent/follow?screen_name=_100DaysOfCode">
    <img src="https://img.shields.io/twitter/follow/shields_io.svg?style=social"
      alt="follow on Twitter"></a>
</p>

You will have a follow on Twitter badge:

follow on Twitter

Consider adding .github community folder

Adding a .github folder to contain all the GitHub community files will help declutter the root of the project.

Files that can be added to the .github folder:

CODE_OF_CONDUCT
CONTRIBUTING
LICENCE
PR_TEMPLETE
ISSUE_TEMPLATE

Incoming PR for this as well ๐Ÿ‘

The 2nd ul in the contributing sections setup section of the readme goes to a 404 page

Do you want to request a ๐Ÿš€ feature or report a ๐Ÿ› bug?

(Write your answer here.)
minor bug

๐Ÿค” Expected Behaviour

(Write what you thought would happen.)
I thought i would go to the place i need to generate an api key but it leads to a 404 page.

๐Ÿ˜• Current Behaviour

(Write what happened. Please add screenshots.)
I got a 404 page when i clicked on the 2nd ul in the contributing sections setup section of the readme. The ul that states "Generate your Sentiment API key here."

๐ŸŒ Your Environment

Software Version
node
npm
yarn (if you use Yarn)
Operating system

๐Ÿ’ป Steps to Reproduce

(Write your steps here.)
click on the link in the setup section of the readme that states "Generate your Sentiment API key here."

๐Ÿ’ก Possible Solution

(Write your solution here.)
fix the link to the proper url to generate a api key, i dont know which link that should be linked to but i suspect you do.

Thanks to @miljan-fsd from parcel-react-app for the template ๐Ÿ‘Œ

Sentiment API down or out of service

Looks like the Mashape API for sentiment has been down for the last few days now.

image

Not sure wen it's going to be back up ๐Ÿคทโ€โ™‚๏ธ

Keys left in ignition

API keys in config.js again, I have submitted PR to use .env require('dotenv') so API keys can be ignored in future ๐Ÿ˜„

Added #53 for this

Remove engines

Node is defaulted to 8 in now so maybe do away with this if deploying to now with next release?

"engines": {
    "node": "~6.1.0",
    "npm": "~.3.8.6"
  },

config.js to be included in .gitignore

Just a thought that the Twitter keys for this are regenerated and kept private so that someone with not the best intentions could post what they like?

As it stands anyone can take this code and post what they like to the @_100DaysOfCode account on Twitter

Bot tweets opt out

Give #100DaysOfCode community members the option to opt out of receiving tweets from the bot.

They could just block the bot or mute it if they prefer but I think this will be a nice way to let users know that we're thinking of them and they can still follow the bot and see its posts in their stream so then be able to encourage other community members without getting tweeted at by the bot.

opt out reply 'something' to stop the bot

Something to that effect, this will have to go into a persistent datastore LevelDB is probably the best option.

Use GraphCool for backend

Using GraphCool to store the data the bot uses for things like:

  • The Project of the Day, items could be tweeted sequentially and not repeated
  • Inspirational quote items could be tweeted sequentially and not repeated
  • Encouragement via the sentiment API could be better handled and use more than a key value pair
  • Retweets can be checked so the bot is not retweeting a popular tweet

Check follower relationship before tweeting

Check relationship and if user has already been thanked for following the account

This should probably go into one of the database enhancements as the info needs to be persisted.

Standardise call timers

So as I understand it, 100DoC bot is calling functions in two differing ways which seem the samey

setImmediate(checkIfFirstOrLastDay, 720000);

bot.js#L148

And

setInterval(favoriteTweet, 960000);

bot.js#L93

and I'm asking for clarification here just as much as agreement but, is there not one way we could agree to use just one for consistency?

and also I have no idea what 960000 and 720000 milliseconds are and have to go convert them

can we agree on the

setInterval(favoriteTweet, 1000 * 60 * howeverManayMinutes);

So anyone reading can quickly see how long the interval is?

Thanks.

Project of the day.

It is a suggestion of a project that one can develop on that day. It can be a simple things of a skill to develop through that 1 hour.

Add tests for env variables

to avoid this:

==================== 
TWEET COUNTER=100 
==================== 
==================== 
TWEET COUNTER=100 
==================== 
==================== 
TWEET COUNTER=100 
==================== 
==================== 
TWEET COUNTER=100 
==================== 
==================== 
TWEET COUNTER=100 
====================

These parameters need to be tested ๐Ÿ™ƒ

const randomMin = parseInt(param.tweetTimeOutMin)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.