Giter VIP home page Giter VIP logo

lulbot's Introduction

GroupMe NodeJS Callback Bot for DaddyLeagues Integration

Introduction

This guide was partially written by me in order to more easily get your code up and running without needing a lot of the technical knowledge necessary to create a bot. Most of the code and half of the readme was forked from https://github.com/groupme/bot-tutorial-nodejs and modified for my own needs. I've gotten a lot of requests from people to implement the bot in their GroupMe, but I don't have the time to do them all so I'm writing this guide as the guide in the previous Git is unfollowable without further explanation. This is meant to be used to setup a bot to integrate Daddyleagues more easily with GroupMe.

Any questions can be directed to /u/SharpObject on Reddit.

Requirements:

  • GroupMe account
  • Heroku account

Getting Started

First, create a Heroku App:

Go to: https://dashboard.heroku.com/apps

Use your login credentials to log in.

Plus Sign to Create new Heroku

Click on the 'Plus Sign' as shown above.

Then click 'Create New App'.

Choose a name, or don't I prefer not to, and then click 'Create App'

The name of your app should appear in the URL, for example: In https://dashboard.heroku.com/apps/safe-scrubland-8523/deploy/heroku-git, the name is 'safe-scrubland-8523'

Find the name of your app and remember it.

Next, create a GroupMe Bot:

Go to: https://dev.groupme.com/session/new

Use your GroupMe credentials to log into the developer site.

Log into dev.groupme.com

Once you have successfully logged in, go to https://dev.groupme.com/bots/new

Create your new bot

Fill out the form to create your new bot:

  • Select the group where you want the bot to live
  • Give your bot a name
  • Paste in the url to your newly deply heroku app
    • http://your-app-name-here.herokuapp.com/
    • For example, mine would be http://safe-scrubland-8523.herokuapp.com
  • (Optional) Give your bot an avatar by providing a url to an image
  • Click submit

Find your Bot ID:

Go here to view all of your bots: https://dev.groupme.com/bots

Click on the one you just created.

Select your new bot

On your Bot's page, copy the Bot ID

Copy your Bot ID

Add your Bot ID to your Heroku app:

Go here to see all of your Heroku apps and select the one you just created before:

https://dashboard-next.heroku.com/apps

Select your heroku app

On your app page, click settings in the top navigation:

Go to your app's settings

On your app's setting page, find the Config Vars section and click the Reveal Config Vars button:

Reveal your environment variables

Then click edit:

Edit your environment variables

Fill out the form to add an environment variable to your app:

  • In the "key" field type: BOT_ID
  • In the "value" field paste your Bot ID that you copied in the previous steps
  • Click the save button

Add the Bot ID environment variable

Now you must connect Github to your Heroku Account.

First you must fork the initial code from my account.

Sign into Github, go to this link https://github.com/batorobe/bot-tutorial-nodejs-rMCF, and click the 'Fork' button in the upper right corner

Fork button

Now sign into Heroku to see all of your Heroku apps and select the one you just created before:

https://dashboard-next.heroku.com/apps

Click on your app.

On your app page, click deploy in the top navigation bar.

There should be three buttons at the top, Heroku Git/Connect to GitHub/DropBox

Deploy, Github, Search

Click Connect to Github

Sign in to Github and click Search

There should only be one 'repo' that comes up, and if you have more than one I assume you know how to do this.

Click on the repo to connect to it.

Deploy Branch

Scroll all the way down to 'Manual Deploy' and click 'Deploy Branch'

All done, test out the bot in your GroupMe

How To Make The Code Your Own

This may require some coding knowledge to get working, but basically how it works is you have a 'regex' variable at the top which stores what you want the bot to respond to, and then code below which actually responds to the code.

Sign in to Github

Find where you forked the code

Click on bot.js

Click on bot.js

Edit Bot.js

Click on the pencil to edit the code

In order to add more commands follow these steps:

  • Create the regex command in the following way, i.e, botRegexSb = /^\/sub/;
    botRegex[x] where [x] is some two to three letter combination to help you remember what the code does.
    /^\/[y]/; where [y] is what you want the command to be.
    Your command should look like [x] = [y] Paste the command after the last command you see, usually botRegexWk = /^\/users/; if this is your first command added, the semi-colon is important.
  • Create the part of the bot that actually responds to the command *The template looks as follows:
    else if(request.text && botDuck.test(request.text)) {
    this.res.writeHead(200);
    postMessage("http://media3.giphy.com/media/YCseTHF2I6CCA/giphy.gif");
    this.res.end();
    }
    
 *Replace `botDuck` with the command you created in the first step, i.e., botRegexSb, call it [x]  
 *Replace what's inside `postMessage("")` with what you want, say [y]  
 *What you should have is:
else if(request.text && [x].test(request.text)) {
this.res.writeHead(200);
postMessage("[y]");
this.res.end();
}
[x] should be where what you called your regex variable, and [y] will be what you want the bot to say in chat.  

Paste this code after the curly brackets of the last command, but before the code that looks like:

else { console.log("don't care"); this.res.writeHead(200); this.res.end(); } ```

Redeploy your code on Heroku and you should be all set!

lulbot's People

Contributors

batorobe avatar jhodge521 avatar petemcgrath avatar

Watchers

 avatar

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.