app.post('/tableflip', function (req, res) { var channel, text, payload; if (req.body.token !== argv.token) { return res.status(401).send({ success: false, error: 'Invalid token.' }); } channel = req.body.channel_name === 'directmessage' ? req.body.channel_id : '#' + req.body.channel_name; text = req.body.text ? flip(req.body.text) : '┻━┻'; payload = { channel: channel, text: '(╯°□°)╯︵ ' + text, icon_emoji: ':rage1:' }; if (argv.norage) { delete payload.icon_emoji; } request.post({ url: argv.webhook, form: { payload: JSON.stringify(payload) } }, function (err, resp, body) { if (err) { return res.status(500).send({ success: false, error: err.message }); } res.end(); }); });
flip: function(args, callback) { // This command requires arguments. if (!args) { return callback(); } callback(null, flip(args)); },
"respond": function(ctx){ var command = ctx.command, text = ctx.args ; var flipped, guy; if (command === 'rageflip') { guy = '(ノಠ益ಠ)ノ彡'; } else if (command === 'unflip') { var unflipped; var toUnflip = (ctx.args || '').trim(); if (toUnflip === 'me') unflipped = '@'+ctx.incoming_message.user_name || 'you'; else if (toUnflip === '') unflipped = '┬──┬'; else unflipped = toUnflip; return unflipped + ' ノ( º _ ºノ)'; } else if (command === 'flip') { guy = '(╯°□°)╯︵'; } var toflip = (ctx.args || '').trim(); if (toflip === 'me') toflip = '@'+ctx.incoming_message.user_name || 'you'; if (toflip === '') flipped = '┻━┻'; else flipped = flip(toflip); return guy + ' ' + flipped; }
function handler(argv) { var input = argv.text.join(' '); if (input === 'table' || input.length < 1) input = '┻━┻'; argv.reply('(ノಠ益ಠ)ノ彡 ' + flip(input)); }