4.0.1 • Published 6 years ago

tinyslacktriviabot v4.0.1

Weekly downloads
23
License
MIT
Repository
github
Last release
6 years ago

tinyslacktriviabot

A tiny, extensible slack trivia bot

version dependencies

Requirements

node v8

Installation

npm i tinyslacktriviabot

Usage

Create a file trivia.js and run it with node trivia.js

Minimum configuration
const { TinySlackTriviaBot } = require('tinyslacktriviabot');
const config = {
  name: 'trivia',
  token: 'SLACK_BOT_TOKEN',
  channels: ['SLACK_CHANNEL_ID']
}
TinySlackTriviaBot.run(config)

Get a <SLACK_BOT_TOKEN> here https://my.slack.com/services/new/bot

Note: configuration can also be stored in a file config.json in the same folder as trivia.js

All databases included configuration
const { TinySlackTriviaBot } = require('tinyslacktriviabot');
const config = {
  name: 'trivia',
  token: 'SLACK_BOT_TOKEN',
  channels: ['SLACK_CHANNEL_ID'],
  repository: [
    { 
      'ignore': false,
      'path': 'DbRepository.js' 
    },
    { 
      'ignore': false,
      'path': 'TriviaDbRepository.js' 
    },
    { 
      'ignore': false,
      'path': 'JsonRepository.js'
    },
    { 
      'ignore': false,
      'path': 'HsRepository.js' 
    },
    { 
      'ignore': false,
      'path': 'JsRepository.js' 
    },
    {
      'ignore': false,
      'path': 'JsonRepository.js',
      'dbPath': 'wow.json'
    },
    {
      'ignore': false,
      'path': 'JsonRepository.js',
      'dbPath': 'jeopardy.json'
    },
    {
      'ignore': false,
      'path': 'JsonRepository.js',
      'dbPath': 'capitals.json',
      'questionPath': ['text'],
      'answerPath': [['answers', 0, 'text', 0]]
    },
    {
      'ignore': false,
      'path': 'JsonRepository.js',
      'dbPath': 'flags.json',
      'questionPath': ['text'],
      'answerPath': [['answers', 0, 'text', 0]]
    }]
}
TinySlackTriviaBot.run(config)

Advanced configuration

Configuration details

RepositorySettings

Base settings

Note: The settings bellow allow you to use the OOTB repositories with alternative databses. Internally the question object needs to have this structure { question, answer, category, ... } and these settings allow you to map a custom databse to the correct fields

JsonRepositorySettings

Assume the question object from JSON has the following format

question = {
              "text":"question text",
              "answers":["first answer", "second answer"],
              "parent": { "group":"category name" }
            }

Note: Property paths are evaluated using object-path. Internally, tinyslacktriviabot uses the coalesce function.

DbRepositorySettings

History

v4.0.0

  • Each repository has it's own settings now
  • Hearthstone respository
  • World of warcraft, Jeopardy, country flags and country capitals json databases
  • Export base models for easier extensibility

v3.0.0

  • configure multiple repositories
  • JsRepository (js questions with evaluator)
  • JsonRepository (questions from json file)

v2.0.0

  • opentdb support

v1.0.0

  • Initial version

License

© 2017 MIT

4.0.1

6 years ago

4.0.0

7 years ago

3.2.1-0

7 years ago

3.2.0-0

7 years ago

3.1.0

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0-0

7 years ago

2.3.2-0

7 years ago

2.3.1-0

7 years ago

2.3.0-0

7 years ago

2.2.2-0

7 years ago

2.2.1-0

7 years ago

2.2.0-0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.1.0-0

7 years ago

2.0.0-0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago