tinyslacktriviabot
v4.0.1
Published
A very simple, small and extendable trivia bot for slack
Downloads
27
Maintainers
Readme
tinyslacktriviabot
A tiny, extensible slack trivia bot
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 astrivia.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