codebuddies / greetbot

Slackbot for greeting new codebuddies users
MIT License
9 stars 14 forks source link

Build "Starter" JSON Template to Display Resource Strings Pulled from YAML File #45

Closed BethanyG closed 6 years ago

BethanyG commented 6 years ago

This is a sub-task to #4, and is still in the "exploratory"/WIP phase. If we're going to make our YAML work in a reasonable fashion (or a DB for that matter), we need to think through what we are going to template, how we are going to template it, and where we put the templates and the templating logic. And this may or may not be the right strategy. Please see the discussion under #4 for additional considerations - and feel free to chime in!

Current proof of concept is to use template strings, and pull various pieces of info from a YAML file of resources. The resource file would be filtered by Topic/level, and the template(s) would pull in the needed info and make the JSON necessary to send out the message.

Attached is a (not yet working) copy of a template. Suggestions welcome.

let message = {
      token: process.env.SLACK_TOKEN,
      as_user: true,
      link_names: true,
      mrkdwn_in: ['text', 'pretext'],
      attachments: JSON.stringify([
        {
          pretext: '${language-icon}  ${language-desc}\n\n\n'
          title: '\n${level} ${language}\n\n',
          text:  '${video-link}  ${video-desc}\n\n${tutorial-link}  ${tutorial-desc}\n\n${book-link}  ${book-desc}\n\n${class-link}  ${class-desc}\n\n${help_link}\n\n${more-questions}\n\n\n${maintainer}',
          color: '${sidebar-color}',
        }]),
    };
BethanyG commented 6 years ago

Fixed by @stain88 in his /resources pull request.