Update .gitignore. Add database related models, data.

This commit is contained in:
Ceda EI 2018-11-27 00:34:53 +05:30
parent 32d0a48277
commit dce4394ff6
6 changed files with 48 additions and 1 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/
node_modules
config.js

5
bot.js
View File

@ -0,0 +1,5 @@
const Telegraf = require("telegraf");
const config = require("./config");
const Sequelize = require("sequelize");
const bot = new Telegraf(config.botApiKey);

8
data/index.js Normal file
View File

@ -0,0 +1,8 @@
const Sequelize = require("sequelize");
const config = require("../config");
const { database, username, password, options } = config.sequelize;
const sequelize = new Sequelize(database, username, password, options);
const models = require("../models")(sequelize);
module.exports = sequelize.sync().then(() => models);

3
models/index.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = sequelize => ({
integrations: require("./integrations")(sequelize),
});

12
models/integrations.js Normal file
View File

@ -0,0 +1,12 @@
const Sequelize = require("sequelize");
module.exports = sequelize => {
const integrations = sequelize.define("integrations", {
chatID: { type: Sequelize.INTEGER, allowNull: false, unique: "com"},
repoURL: {type: Sequelize.STRING, allowNull: false, unique: "com"},
chatType: {type: Sequelize.STRING},
issues: {type: Sequelize.BOOLEAN, defaultValue: false},
pullRequests: {type: Sequelize.BOOLEAN, defaultValue: false},
commits: {type: Sequelize.BOOLEAN, defaultValue: true},
});
integrations.sync().then(return integration);
};

18
sample.config.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
// Create a new bot by messaging @BotFather and follow the instructions
// Replace the key by the actual token recieved from BotFather
botApiKey: "key",
// Connection information for database
"sequelize": {
database: "git-alerts-bot",
username: "git-bot",
password: "hopefully_a_secure_password",
options: {
host: "localhost",
dialect: "sqlite",
// SQLite only
storage: "./git-alerts-bot.sqlite"
}
},
};