seiyria's notebooks

  • pyra-hook-scale - /seiyria/pyra-hook-scale
    Last edited 3 years ago
    const random = require('lodash.random'); const { run, json } = require('micro'); const me = fn => (req, res) => run(req, res, fn); exports.endpoint = me(async (req, res) => { const body = await json(req); let start = 1; let end = 10; let whereWeAre = 0; let startName = 1; let endName = 10; let whereWeAreName = 0; const allArgs = body.arguments.split('|'); if(allArgs.length === 1) { if(isNaN(+allArgs[0])) { whereWeAre = random(start, end); whereWeAreName = allArgs[0]; } else { whereWeAre = whereWeAreName = +allArgs[0]; } } if(allArgs.length === 2) { if(isNaN(+allArgs[0])) { start = 1; startName = allArgs[0]; } else { start = startName = +allArgs[0]; } if(isNaN(+allArgs[1])) { end = 10; endName = allArgs[1]; } else { end = endName = +allArgs[1]; } } if(allArgs.length === 3) { if(isNaN(+allArgs[0])) { start = 1; startName = allArgs[0]; } else { start = startName = +allArgs[0]; } if(isNaN(+allArgs[1])) { end = 10; endName = allArgs[1]; } else { end = endName = +allArgs[1]; } if(isNaN(+allArgs[2])) { whereWeAre = random(start, end); whereWeAreName = allArgs[2]; } else { whereWeAre = whereWeAreName = +allArgs[2]; } } let arr = new Array(end - 1); arr[whereWeAre - 1] = '|'; const message = `On a scale of "${startName}" to "${endName}", "${whereWeAreName}" is about right here: [${arr.join(' ')}]`; return { message }; });
  • pyra-hook-goodmorning - /seiyria/pyra-hook-goodmorning
    Last edited 5 years ago
    const { run, json } = require('micro'); const me = fn => (req, res) => run(req, res, fn); exports.endpoint = me(async (req, res) => { return { message: 'https://i.redd.it/25f3s59j6gz11.jpg' }; });