Giter Site home page Giter Site logo

thinc5 / thought-bot Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.23 MB

Discord bot that uses the twitter api to come up with its own "original" thoughts.

License: GNU General Public License v3.0

TypeScript 99.50% Dockerfile 0.50%
typescript nodejs thoughts thoughtbot twitter discord chat-bot

thought-bot's Introduction

ThoughtBot

About

A Discord bot made using TypeScript and Node.js that uses the Twitter API to request and store tweets at a specified interval, then processes those tweets using a Markov chain to generate a tweet of its own.

Usage

  • Looks for environment variables for initialisation it’s easiest to just place these into a .env file at the root of the project or modify the host’s environment variables through the provided interface (e.g. Heroku Config vars).
  • These are:
Name Description
BOT_CLIENT_ID The client id for the bot provided by Discord
DISCORD_TOKEN Token provided by Discord
TWITTER_CONSUMER_KEY Consumer key provided by Twitter
TWITTER_CONSUMER_SECRET Twitter consumer secret key provided by Twitter
TWITTER_BEARER_TOKEN Generated by the user
COMMAND_PREFIX The desired command prefix e.g. % command
DB_LOCATION Expected path of the sqlite database
NUMBER_OF_HASHTAGS Number of hashtags to grab at each cycle
UPDATE_INTERVAL_MINS Delay between grab cycles

To start just run npm start or make it your container's entry point.

Commands

The prefix will change depending on the one you specified however for the following examples we will use %.

Command Description
% help Retrieve a list of all registered commands.
% randomtweet [query] Grab a random tweet matching provided query
% trendinghashtags [woeid] Get the trending tweets in a provided woeid (can be found at http://woeid.rosselliot.co.nz/)
% register (Requires admin role or equivalent) Registers current channel to receive the daily digest for the pointed to location (Defaults to LA)
% unregister (Requires admin role or equivalent) Unregister channel from target channels

Adding a command

To add a command simply ensure that it extends AbstractCommand and is found in the commands directory, if there are no errors it should be automatically loaded on startup.

What I've learnt

  • TypeScript
  • Async/await and callbacks
  • Node.js and npm (including writing debug and prod scripts in package.json)
  • Dynamic Modules (Loading all commands in a given directory at runtime instead of manually importing them)
  • Simple SQL and migrations (SQLite)
  • API consumption (twitter and discord)
  • Timed events via javascript (using setInterval and setTimeout)
  • Managing and loading environment variables to keep secrets (API keys, database credentials...)
  • Dealing with commercial cloud hosted virtual production environments e.g. Heorku

Future of ThoughtBot

I am not planning to continue adding features to ThoughtBot, however I would like to continue to fix existing issues and polish existing features. Some of these goals are:

  • Create my own Markov chain implementation in C++ and compile to wasm.
  • Move to a hosted database (MongoDB or PostgreSQL)

Feel free to make a pull request or issue if you feel you have anything to contribute.

Licence

This project is licensed under GNU GPL3!

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.