A my-groupme-bot plugin which integrates with Imgflip for meme generation from user input.
Install with npm:
$ npm i my-groupme-bot-imgflip --save
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:
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)
require('my-groupme-bot-imgflip')(opts) -> MyGroupMeBotPlugin
Returns a my-groupme-bot plugin configured with the given options.
Parameters:
opts
:An options object containing your Imgflip username and password, and your GroupMe access token.{ imgflip: { username: string, password: string }, groupme: { accessToken: string } }
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 thehelp
function is called on the bot. Passnull
orundefined
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.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Install dev dependencies:
$ npm i -d && npm test
Tomer Aberbach