Awesome Open Source
Awesome Open Source

My Groupme Bot Imgflip

NPM version JavaScript Style Guide

A my-groupme-bot plugin which integrates with Imgflip for meme generation from user input.

Install

Install with npm:

$ npm i my-groupme-bot-imgflip --save

Usage

Example:

User: /pigeon
Bot: Usage: /pigeon guy, butterfly, is this a pigeon?
User: /pigeon groupme bot programmers, a module for a memebot, is this the greatest module ever?
Bot:

Example

Code:

const bot = require('my-groupme-bot')
const imgflip = require('my-groupme-bot-imgflip')

bot
  .use(imgflip({
    imgflip: {
      username: 'YOUR_IMGFLIP_USERNAME',
      password: 'YOUR_IMGFLIP_PASSWORD'
    },
    groupme: {
      accessToken: 'YOUR_GROUPME_ACCESS_TOKEN'
    }
  }))
  .config('YOUR_BOT_ID')
  .imgflip(100777631, 'pigeon', 'Is this a pigeon?', ['guy', 'butterfly', 'is this a pigeon?'], a => a.map(i => i.toUpperCase()))
  .listen(process.env.PORT)

Methods

require('my-groupme-bot-imgflip')(opts) -> MyGroupMeBotPlugin

Returns a my-groupme-bot plugin configured with the given options.

Parameters:

  • opts :
    {
      imgflip: {
        username: string,
        password: string
      },
      groupme: {
        accessToken: string
      }
    }
    
    An options object containing your Imgflip username and password, and your GroupMe access token.

bot.imgflip(id, name, desc, example, transform) -> bot

Adds a command to the bot which allows users to fill out the meme with the specified id.

Parameters:

  • id : number - The id of the meme to fill out. The top 100 memes can be found at this link.
  • name : string - The name to use for the command.
  • description : string | undefined | null - A description for the command. Will be displayed by the help command if the help function is called on the bot. Pass null or undefined for no description.
  • example : Array<string> - An array of strings which indicates the number of arguments expected for the meme as well as indicating which argument is for which label of the image. The array is joined by commas for displaying the usage as shown in the example.
  • transform : (args : Array<string>) -> Array<string> (Optional) - A function which maps the arguments given by the user to be used for the labeling the meme. The example above capitalizes the provided strings. The returned array can be of a different length than the original array.

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Install dev dependencies:

$ npm i -d && npm test

Author

Tomer Aberbach

License

MIT Tomer Aberbach


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,513,654
Nodejs (53,956
Api (22,029
Bot (12,094
Npm (5,711
Chatbot (3,449
Chat (3,259
Npm Package (2,765
Memes (658
Npm Module (573
Related Projects