{"componentChunkName":"component---src-templates-blog-post-template-js","path":"/2017/01/04/twitter-mctwitbot/","result":{"data":{"mdx":{"id":"84bfef4c-ca4e-5e68-850f-952257b511aa","frontmatter":{"title":"Twitter McTwitBot","date":"2017 January 4th","cover":null},"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"date\": \"2017-01-04T00:00:00.000Z\",\n  \"title\": \"Twitter McTwitBot\",\n  \"tags\": [\"information\", \"guide\"],\n  \"published\": true\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"I must say this was great to do and a nice little introduction to node\\nand npm.\"), mdx(\"p\", null, mdx(\"span\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"640px\"\n    }\n  }), \"\\n      \", mdx(\"a\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/4e760024e20f5dd223ad0d382a5bd481/6af66/twitter-bird.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": [\"noopener\"]\n  }), \"\\n    \", mdx(\"span\", _extends({\n    parentName: \"a\"\n  }, {\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"100%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/svg+xml,%3csvg%20xmlns=\\\\'http://www.w3.org/2000/svg\\\\'%20width=\\\\'400\\\\'%20height=\\\\'400\\\\'%3e%3cpath%20d=\\\\'M7%207L5%208v192c0%20174%200%20193%202%20194%202%203%20384%203%20386%200%202-1%202-20%202-194V8l-2-1C389%204%2011%204%207%207m250%2048c-40%208-67%2046-61%2086l1%204h-3l-16-2c-47-7-86-27-120-61L44%2068l-2%206c-14%2031-6%2066%2020%2088l5%205c-2%201-19-4-31-9-6-2%202%2028%2010%2040%2010%2015%2029%2029%2042%2032%204%200%205%202%202%202l-9%201H60l9%2018c13%2018%2034%2031%2055%2032l4%201a144%20144%200%2001-94%2031H20l31%2016a209%20209%200%2000215-28c48-40%2078-105%2078-168v-8l6-5c10-7%2030-30%2030-32l-6%202-32%208h-2l2-2c11-7%2028-30%2028-37l-10%204c-10%205-26%2011-32%2012-4%200-5%200-9-4a74%2074%200%2000-62-18\\\\'%20fill=\\\\'%23d3d3d3\\\\'%20fill-rule=\\\\'evenodd\\\\'/%3e%3c/svg%3e')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  })), \"\\n  \", mdx(\"picture\", {\n    parentName: \"a\"\n  }, \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/4e760024e20f5dd223ad0d382a5bd481/60a22/twitter-bird.webp 160w\", \"/static/4e760024e20f5dd223ad0d382a5bd481/4c812/twitter-bird.webp 320w\", \"/static/4e760024e20f5dd223ad0d382a5bd481/0ba47/twitter-bird.webp 640w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/webp\"\n  })), \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/4e760024e20f5dd223ad0d382a5bd481/69538/twitter-bird.png 160w\", \"/static/4e760024e20f5dd223ad0d382a5bd481/72799/twitter-bird.png 320w\", \"/static/4e760024e20f5dd223ad0d382a5bd481/6af66/twitter-bird.png 640w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/png\"\n  })), \"\\n        \", mdx(\"img\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"className\": \"gatsby-resp-image-image\",\n    \"src\": \"/static/4e760024e20f5dd223ad0d382a5bd481/6af66/twitter-bird.png\",\n    \"alt\": \"twitter logo\",\n    \"title\": \"twitter logo\",\n    \"loading\": \"lazy\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    }\n  })), \"\\n      \"), \"\\n  \"), \"\\n    \")), mdx(\"p\", null, \"I got to doing this from finding it on \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"GitHub\"), \" I\\nthink I was looking for the Twitter icon in bootstrap whilst working\\non my\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"http://codepen.io/spences10/full/dOaYbP/\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Random Quote Generator\"), \" I\\nstumbled across the\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/mobeets/twitter-bot-bootstrap\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"twitter-bot-bootstrap\"), \"\\n(as you do) so after stalling with my progress on the freeCodeCamp(\\uD83D\\uDD25)\\nzipline for a Wikipedia viewer I decided to give the Twitter bot a try\\nand managed to create it and add it to \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://heroku.com\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Heroku\"), \"\\n\\uD83C\\uDF89\\u201D\"), mdx(\"p\", null, \"This app didn\\u2019t work as well as expected though \\uD83D\\uDE26, so I then decided\\nto take a look at \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/amanhimself\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"@amanhimself\"), \"\\u2019s\\nTwitter bot he had created for the\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://medium.freecodecamp.com/start-2017-with-the-100daysofcode-improved-and-updated-18ce604b237b\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"#100DaysOfCode\"), \"\\nchallenge, which I just happen to be taking part in.\"), mdx(\"p\", null, \"So with his great documentation\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://hackernoon.com/create-a-simple-twitter-bot-with-node-js-5b14eb006c08\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"here\"), \"\\nand\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://community.risingstack.com/how-to-make-a-twitter-bot-with-node-js/\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"here\"), \"\\nI managed to cobble together my own Twitter-bot which I use on my\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/spences10\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"@spences10\"), \" Twitter account\"), mdx(\"blockquote\", null, mdx(\"p\", {\n    parentName: \"blockquote\"\n  }, \"If you\\u2019r wondering about the post name\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://en.wikipedia.org/wiki/RRS_Sir_David_Attenborough#Boaty_McBoatface_Naming_Controversy\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"check here\"), \".\")), mdx(\"h2\", {\n    \"id\": \"technologies-used\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h2\"\n  }, {\n    \"href\": \"#technologies-used\",\n    \"aria-label\": \"technologies used permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Technologies used\"), mdx(\"p\", null, \"Preamble out of the way, now I can walk through what was used.\"), mdx(\"h3\", {\n    \"id\": \"cloud-9\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#cloud-9\",\n    \"aria-label\": \"cloud 9 permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Cloud 9\"), mdx(\"p\", null, \"I love this development environment, I soon became a fan of\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://c9.io/?redirect=0\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"c9\"), \" when trying to install Ruby on my\\nwindows machine and then again after installing Node.js on my computer\\nfor the first time.\"), mdx(\"h3\", {\n    \"id\": \"nodejs\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#nodejs\",\n    \"aria-label\": \"nodejs permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Node.js\"), mdx(\"p\", null, \"I already had this installed on my c9 environment so I just had to\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"npm install --save twit\"), \" then I was up and running\"), mdx(\"h3\", {\n    \"id\": \"heroku\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#heroku\",\n    \"aria-label\": \"heroku permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Heroku\"), mdx(\"p\", null, \"I didn\\u2019t really get what Heroku was until I started this project but\\nonce I\\u2019d read the guides it was quite straightforward and the\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://devcenter.heroku.com/articles/heroku-cli\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Heroku CLI\"), \" was\\nalready installed on c9 i checked with \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"heroku --version\"), \" before\\nattempting to install it.\"), mdx(\"h3\", {\n    \"id\": \"github\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#github\",\n    \"aria-label\": \"github permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"GitHub\"), mdx(\"p\", null, \"You can deploy straight from your c9 environment to Heroku and there\\nare loads of other integration tools you can use which I haven\\u2019t had\\ntime to look into yet. It\\u2019s good practice to have your code on a\\nrepository somewhere and GitHub is widely used.\"), mdx(\"h3\", {\n    \"id\": \"twitter\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#twitter\",\n    \"aria-label\": \"twitter permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Twitter\"), mdx(\"p\", null, \"You will need to set up a Twitter application from the\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://apps.twitter.com/app/new\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Twitter dev portal\")), mdx(\"hr\", null), mdx(\"p\", null, \"All of the information above is in addition to the guides given by\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://github.com/amandeepmittal\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"Aman\"), \" the stuff I\\u2019m going to go\\nthrough now my experience with deploying to Heroku, you may want to\\nhost the app somewhere different.\"), mdx(\"h2\", {\n    \"id\": \"my-approach\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h2\"\n  }, {\n    \"href\": \"#my-approach\",\n    \"aria-label\": \"my approach permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"My Approach\"), mdx(\"p\", null, \"Use \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"node bot.js\"), \" to test locally, in\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/amanhimself\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"@amanhimself\"), \"\\u2019s example it will\\ntweet and favourite straight away then go on a timer.\"), mdx(\"p\", null, \"Deploy to Heroku \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"git push heroku master\")), mdx(\"p\", null, \"This is after I have added the changes to Git with a commit message\\nand pushed the changes to my repo, here\\u2019s the terminal commands:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {}), \"$ git add .\\n$ git commit -m 'my detailed commit message'\\n$ git push origin master\\n$ git push heroku master\\n\")), mdx(\"p\", null, \"The final command will build the app on Heroku for you with output\\nlike this:\"), mdx(\"p\", null, mdx(\"span\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"640px\"\n    }\n  }), \"\\n      \", mdx(\"a\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/e6709064251e6da785769309afc79bc5/b6529/heroku-build.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": [\"noopener\"]\n  }), \"\\n    \", mdx(\"span\", _extends({\n    parentName: \"a\"\n  }, {\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"119.92373689227836%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/svg+xml,%3csvg%20xmlns=\\\\'http://www.w3.org/2000/svg\\\\'%20width=\\\\'400\\\\'%20height=\\\\'480\\\\'%3e%3cpath%20d=\\\\'M152%20375v3h-1l-1-1-1-1c-2-2-4-1-4%201h-1c-1-2-4-3-4-1h-7c0-2-3-1-3%201-1%202%200%203%202%203v-2l2%202c0%203%201%203%203%200l3-1%202%201v-2l3%201c0%201%201%201%201-1%201-2%201-2%201%200s2%203%202%201h1l2%201%202-1h1l2%201v-2l2-1c0-2-3-2-4-1h-1c0-2-2-3-2-1\\\\'%20fill=\\\\'%23d3d3d3\\\\'%20fill-rule=\\\\'evenodd\\\\'/%3e%3c/svg%3e')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  })), \"\\n  \", mdx(\"picture\", {\n    parentName: \"a\"\n  }, \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/e6709064251e6da785769309afc79bc5/60a22/heroku-build.webp 160w\", \"/static/e6709064251e6da785769309afc79bc5/4c812/heroku-build.webp 320w\", \"/static/e6709064251e6da785769309afc79bc5/0ba47/heroku-build.webp 640w\", \"/static/e6709064251e6da785769309afc79bc5/e46b2/heroku-build.webp 960w\", \"/static/e6709064251e6da785769309afc79bc5/983e9/heroku-build.webp 1049w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/webp\"\n  })), \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/e6709064251e6da785769309afc79bc5/69538/heroku-build.png 160w\", \"/static/e6709064251e6da785769309afc79bc5/72799/heroku-build.png 320w\", \"/static/e6709064251e6da785769309afc79bc5/6af66/heroku-build.png 640w\", \"/static/e6709064251e6da785769309afc79bc5/d9199/heroku-build.png 960w\", \"/static/e6709064251e6da785769309afc79bc5/b6529/heroku-build.png 1049w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/png\"\n  })), \"\\n        \", mdx(\"img\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"className\": \"gatsby-resp-image-image\",\n    \"src\": \"/static/e6709064251e6da785769309afc79bc5/6af66/heroku-build.png\",\n    \"alt\": \"heroku-build\",\n    \"title\": \"heroku-build\",\n    \"loading\": \"lazy\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    }\n  })), \"\\n      \"), \"\\n  \"), \"\\n    \")), mdx(\"blockquote\", null, mdx(\"p\", {\n    parentName: \"blockquote\"\n  }, \"I know this isn\\u2019t standard practice for GitHub and I am in the\\nprocess of understanding how to branch and use Pull Requests so bear\\nwith me \\uD83D\\uDE04\")), mdx(\"p\", null, \"The first gotcha for me was the Heroku \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"Procfile\"), \" I couldn\\u2019t\\nunderstand why it kept timing out, this was because it was trying to\\nrun the default \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"web\"), \" process instead of the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"worker\"), \" process which is\\nwhats needed for the bot.\"), mdx(\"p\", null, \"After getting the bare bones set up on part 1 I then got to playing\\naround with the timings and the query strings used by the bot, this is\\nwhere things started to go a bit\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://en.oxforddictionaries.com/definition/us/off-piste\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"off-piste\")), mdx(\"p\", null, mdx(\"span\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"640px\"\n    }\n  }), \"\\n      \", mdx(\"a\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/fbc1a377390f70936083b745c2298b88/00172/heroku-error-output.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": [\"noopener\"]\n  }), \"\\n    \", mdx(\"span\", _extends({\n    parentName: \"a\"\n  }, {\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"26.14942528735632%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/svg+xml,%3csvg%20xmlns=\\\\'http://www.w3.org/2000/svg\\\\'%20width=\\\\'400\\\\'%20height=\\\\'105\\\\'/%3e')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  })), \"\\n  \", mdx(\"picture\", {\n    parentName: \"a\"\n  }, \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/fbc1a377390f70936083b745c2298b88/60a22/heroku-error-output.webp 160w\", \"/static/fbc1a377390f70936083b745c2298b88/4c812/heroku-error-output.webp 320w\", \"/static/fbc1a377390f70936083b745c2298b88/0ba47/heroku-error-output.webp 640w\", \"/static/fbc1a377390f70936083b745c2298b88/e46b2/heroku-error-output.webp 960w\", \"/static/fbc1a377390f70936083b745c2298b88/bdcfb/heroku-error-output.webp 1044w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/webp\"\n  })), \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/fbc1a377390f70936083b745c2298b88/69538/heroku-error-output.png 160w\", \"/static/fbc1a377390f70936083b745c2298b88/72799/heroku-error-output.png 320w\", \"/static/fbc1a377390f70936083b745c2298b88/6af66/heroku-error-output.png 640w\", \"/static/fbc1a377390f70936083b745c2298b88/d9199/heroku-error-output.png 960w\", \"/static/fbc1a377390f70936083b745c2298b88/00172/heroku-error-output.png 1044w\"],\n    \"sizes\": \"(max-width: 640px) 100vw, 640px\",\n    \"type\": \"image/png\"\n  })), \"\\n        \", mdx(\"img\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"className\": \"gatsby-resp-image-image\",\n    \"src\": \"/static/fbc1a377390f70936083b745c2298b88/6af66/heroku-error-output.png\",\n    \"alt\": \"heroku-error-output\",\n    \"title\": \"heroku-error-output\",\n    \"loading\": \"lazy\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    }\n  })), \"\\n      \"), \"\\n  \"), \"\\n    \")), mdx(\"p\", null, \"For quite a while I couldn\\u2019t understand why I was getting so many\\nerrors, with a whole lot of \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"console.log(var)\"), \" throughout the code I\\ncame to the conclusion that that the query string I was using:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {}), \"var queryString = '#100DaysOfCode, #GitHub, #VSCode';\\n\")), mdx(\"p\", null, \"You can get the logs from Heroku when you app is running by typing:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {}), \"$ herouku logs -t\\n\")), mdx(\"p\", null, \"This will give you your logs back from Heroku so you can add all the\\ndebug lines you want in there to determine whats going on.\"), mdx(\"p\", null, \"I was getting the errors pictured so I started to play with the query\\nstring and just using one value at a time which didn\\u2019t cause any\\nerrors so I decided to pass one value at a time by adding the Gist\\nbelow.\"), mdx(\"script\", {\n    src: \"https://gist.github.com/spences10/46d9981a805786e7c965cf292b9cb3ae.js\"\n  }), mdx(\"p\", null, \"This worked, for a while then the same errors started creeping in, I\\nthen noticed that the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"retweet\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"favoriteTweet\"), \" were on a timer\\nbut using the same random text from the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"queryString\"), \" which was about\\nas much use as the previous piece of code as it was a one time\\ninitialisation \", \"[or initialization]\", \" so the same string was being used\\nmultiple times causing the errors.\"), mdx(\"p\", null, \"So after some head scratching and playing around with the code, [and\\ntweeting \", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://twitter.com/amanhimself\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"@amanhimself\"), \" numerous\\ntimes] Aman suggested that I use the npm package\\n\", mdx(\"a\", _extends({\n    parentName: \"p\"\n  }, {\n    \"href\": \"https://www.npmjs.com/package/unique-random-array\",\n    \"target\": \"_blank\",\n    \"rel\": \"noopener\"\n  }), \"unique-random-array\"), \"\\nto return a random string value from the string list.\"), mdx(\"p\", null, \"So I added the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"var\"), \" in:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {}), \"var uniqueRandomArray = require('unique-random-array');\\n\")), mdx(\"p\", null, \"Built the query string:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"var queryString = uniqueRandomArray([\\n  '100daysofcode',\\n  'freecodecamp',\\n  'github',\\n  'vscode',\\n  'visual studio code',\\n  'nodejs',\\n  'node.js',\\n  'vuejs',\\n  'vue.js',\\n  'inferno_js',\\n  'inferno.js',\\n  'jekyll',\\n])\\n\")), mdx(\"p\", null, \"Then just replaced the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"queryString\"), \" string with the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"queryString()\"), \"\\nmethod.\"), mdx(\"p\", null, \"Some other things to note that I discovered when playing around with\\nthe bot is the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"retweet\"), \" and \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"favoriteTweet\"), \" function \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"params\"), \" was the\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"result_type:\"), \" options, here\\u2019s my comments copy pasted from the\\nTwitter dev portal:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {}), \"// result_type: options, mixed, recent, popular\\n// * mixed : Include both popular and real time results in the response.\\n// * recent : return only the most recent results in the response\\n// * popular : return only the most popular results in the response.\\n\")), mdx(\"p\", null, \"The next stage for this could be to use the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"unique-random-array\"), \"\\npackage to change that value too.\"), mdx(\"p\", null, \"That\\u2019s it for now, I still have a weird bug where if I follow someone\\nand then someone else follows me the bot decides to tweet back to\\nitself!\"), mdx(\"p\", null, mdx(\"span\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"556px\"\n    }\n  }), \"\\n      \", mdx(\"a\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"gatsby-resp-image-link\",\n    \"href\": \"/static/3ef852faec12d3d88877168c9b5f344e/96638/yes-tweet-yourself.png\",\n    \"style\": {\n      \"display\": \"block\"\n    },\n    \"target\": \"_blank\",\n    \"rel\": [\"noopener\"]\n  }), \"\\n    \", mdx(\"span\", _extends({\n    parentName: \"a\"\n  }, {\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"14.20863309352518%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/svg+xml,%3csvg%20xmlns=\\\\'http://www.w3.org/2000/svg\\\\'%20width=\\\\'400\\\\'%20height=\\\\'57\\\\'%3e%3cpath%20d=\\\\'M11%209l-1%2017v16l3%201c3%201%2013-1%2014-2l3-1h2c1-1%201-1%201%201-1%202-1%202%205%202%207-1%207-1%207-19%200-10%200-13-2-14-2-2-30-3-32-1\\\\'%20fill=\\\\'%23d3d3d3\\\\'%20fill-rule=\\\\'evenodd\\\\'/%3e%3c/svg%3e')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  })), \"\\n  \", mdx(\"picture\", {\n    parentName: \"a\"\n  }, \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/3ef852faec12d3d88877168c9b5f344e/60a22/yes-tweet-yourself.webp 160w\", \"/static/3ef852faec12d3d88877168c9b5f344e/4c812/yes-tweet-yourself.webp 320w\", \"/static/3ef852faec12d3d88877168c9b5f344e/80afe/yes-tweet-yourself.webp 556w\"],\n    \"sizes\": \"(max-width: 556px) 100vw, 556px\",\n    \"type\": \"image/webp\"\n  })), \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/3ef852faec12d3d88877168c9b5f344e/69538/yes-tweet-yourself.png 160w\", \"/static/3ef852faec12d3d88877168c9b5f344e/72799/yes-tweet-yourself.png 320w\", \"/static/3ef852faec12d3d88877168c9b5f344e/96638/yes-tweet-yourself.png 556w\"],\n    \"sizes\": \"(max-width: 556px) 100vw, 556px\",\n    \"type\": \"image/png\"\n  })), \"\\n        \", mdx(\"img\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"className\": \"gatsby-resp-image-image\",\n    \"src\": \"/static/3ef852faec12d3d88877168c9b5f344e/96638/yes-tweet-yourself.png\",\n    \"alt\": \"yes-tweet-yourself\",\n    \"title\": \"yes-tweet-yourself\",\n    \"loading\": \"lazy\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    }\n  })), \"\\n      \"), \"\\n  \"), \"\\n    \")), mdx(\"h3\", {\n    \"id\": \"coming-up\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h3\"\n  }, {\n    \"href\": \"#coming-up\",\n    \"aria-label\": \"coming up permalink\",\n    \"className\": \"anchor-toc before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Coming up\"), mdx(\"p\", null, \"More stuff with the \", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \".stream()\"), \" function, like auto follow back and\\nbetter replies.\"));\n}\n;\nMDXContent.isMDXComponent = true;","excerpt":"I must say this was great to do and a nice little introduction to node\nand npm. I got to doing this from finding it on  GitHub  I\nthink I…","tableOfContents":{"items":[{"url":"#technologies-used","title":"Technologies used","items":[{"url":"#cloud-9","title":"Cloud 9"},{"url":"#nodejs","title":"Node.js"},{"url":"#heroku","title":"Heroku"},{"url":"#github","title":"GitHub"},{"url":"#twitter","title":"Twitter"}]},{"url":"#my-approach","title":"My Approach","items":[{"url":"#coming-up","title":"Coming up"}]}]},"timeToRead":3,"fields":{"slug":"/2017/01/04/twitter-mctwitbot/","editLink":"https://github.com/spences10/thelocalhost.blog/edit/authoring/posts/2017/01/04/twitter-mctwitbot/index.md"}}},"pageContext":{"slug":"/2017/01/04/twitter-mctwitbot/","previous":{"id":"a345317b-5454-5569-9b00-4f9dad37996f","excerpt":"Since setting up this blog I haven't really bothered with Jekyll any\nmore than just forking Barry Clarke's repo of Jekyll Now and adding\nthese posts as and when the feeling takes me. So I got to checking out Barry's blog and his Jekyll Now templates…","frontmatter":{"title":"Starting again with Jekyll","date":"2016-12-17T00:00:00.000Z"},"fields":{"slug":"/2016/12/17/starting-again-with-jekyll/"}},"next":{"id":"e6e1c0c4-6063-5832-a0e3-1b256750c67d","excerpt":"I know why Linus called it that now! If you're reading this there's a good chance you know at least the\nbasics of Git but if like me and you are the only person making\nchanges to your repos then there's a good chance that you just use\n git push…","frontmatter":{"title":"Git and GitHub","date":"2017-01-05T00:00:00.000Z"},"fields":{"slug":"/2017/01/05/git-and-github/"}}}}}