-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from wsknorth/dev
dev
- Loading branch information
Showing
24 changed files
with
1,012 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
lib/configs/configs.json | ||
database/midnabot.sqlite |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { start } = require('./start') | ||
const { sandbox } = require('./sandbox') | ||
const { roll } = require('./roll') | ||
const { about } = require('./about') | ||
const { stop } = require('./stop') | ||
|
||
module.exports = { start, sandbox, roll, about, stop } |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const debug = require('debug')('midnabot:start') | ||
|
||
const { Starts } = require('../../models/starts') | ||
|
||
const start = () => (ctx) => { | ||
const name = (ctx.update.message.chat.type === 'private') | ||
? ctx.update.message.from.username | ||
: ctx.update.message.chat.title | ||
|
||
const reply = (ctx.update.message.chat.type === 'private') | ||
? `midnabot is now listening in this chat` | ||
: `midnabot is now listening in this channel` | ||
|
||
Starts.upsert({ name, start: true }) | ||
.then(() => ctx.response(ctx.reply, reply)) | ||
.catch((error) => { | ||
debug(error) | ||
return ctx.response(ctx.reply, `Ooops, something went wrong`) | ||
}) | ||
} | ||
|
||
module.exports = { start } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const debug = require('debug')('midnabot:stop') | ||
|
||
const { Starts } = require('../../models/starts') | ||
|
||
const stop = () => (ctx) => { | ||
const name = (ctx.update.message.chat.type === 'private') | ||
? ctx.update.message.from.username | ||
: ctx.update.message.chat.title | ||
|
||
const reply = (ctx.update.message.chat.type === 'private') | ||
? `midnabot is not listening in this chat` | ||
: `midnabot is not listening in this channel` | ||
|
||
Starts.upsert({ name, start: false }) | ||
.then(() => ctx.response(ctx.reply, reply)) | ||
.catch((error) => { | ||
debug(error) | ||
return ctx.response(ctx.reply, `Ooops, something went wrong`) | ||
}) | ||
} | ||
|
||
module.exports = { stop } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const debug = require('debug')('midnabot:after') | ||
|
||
const { Starts } = require('../../models/starts') | ||
|
||
const after = () => (ctx, next) => { | ||
const name = (ctx.update.message.chat.type === 'private') | ||
? ctx.update.message.from.username | ||
: ctx.update.message.chat.title | ||
Starts.findOne({ where: { name } }) | ||
.then((starts) => (starts.dataValues.start) ? next() : debug('not started')) | ||
} | ||
|
||
module.exports = { after } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { request } = require('./request') | ||
const { response } = require('./response') | ||
const { after } = require('./after') | ||
|
||
module.exports = { request, response, after } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const debug = require('debug')('midnabot:response') | ||
|
||
const response = () => (ctx, next) => { | ||
ctx.response = (callback, message) => { | ||
debug(message) | ||
return callback(message) | ||
} | ||
|
||
next() | ||
} | ||
|
||
module.exports = { response } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const { Starts } = require('./starts') | ||
|
||
module.exports = { Starts } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { Sequelize, sequelize } = require('../../modules/sequelize') | ||
|
||
const Starts = sequelize.define('starts', { | ||
name: { type: Sequelize.STRING, allowNull: false, unique: true }, | ||
start: { type: Sequelize.BOOLEAN, defaultValue: false } | ||
}) | ||
|
||
module.exports = { Starts } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"development": { | ||
"username": "midnadevbot", | ||
"token": "488808043:AAEnrG_7_jtm6k2eJm_zHHhV67Yaqxflje4" | ||
}, | ||
"production": { | ||
"username": "midnabot", | ||
"token": "426124500:AAHyqS64s1TEZjwMQbMFEeE7NxC8bl5CDgk", | ||
"webhook": "https://wsknorth.io/midnabot", | ||
"port": 4000 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const { configs } = require('./configs') | ||
const { sequelize } = require('./sequelize') | ||
|
||
module.exports = { configs, sequelize } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const Sequelize = require('sequelize') | ||
|
||
const sequelize = new Sequelize('midnabot', null, null, { | ||
dialect: 'sqlite', | ||
storage: './database/midnabot.sqlite', | ||
operatorsAliases: false, | ||
logging: false | ||
}) | ||
|
||
module.exports = { Sequelize, sequelize } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.