Skip to content

MeBots/mebotsjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mebots

NPM package summary for mebots

A JavaScript interface to the MeBots API.

Usage

First install with npm or your favorite package manager:

npm install mebots

Import into your project:

const mebots = require('mebots');
// Alternative:
const Bot = require('mebots').Bot;
// If you choose this option, simply instantiate the bot as `new Bot(...)` below.

Instantiate your bot by passing the shortname and token:

// var or let should work too
const bot = new mebots.Bot('your_bot_shortname', 'token (at top of page while editing your bot)')

You will likely want to store the token in an environment variable or config file of some sort. At any rate, don't commit it to GitHub! :)

Finally, use a promise structure to fetch the instance and post a message, using the id field to fulfill the bot_id key as discussed in GroupMe's documentation here!

bot.getInstance(receivedGroupId).then((instance) => {
    options = { // the parameters you're passing to
        // ...
        'bot_id': instance.id,
    };
    // Perform request just like you normally would!
});

Feel free to open an issue if you need help!

See this repository for an example of a fully-functioning GroupMe bot in JavaScript using the MeBots API.

Authorship

Erik Boesen

About

JavaScript wrapper for the MeBots API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published