diff --git a/.gitignore b/.gitignore index 40b878d..5adb5f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules +config.js diff --git a/bot.js b/bot.js index e69de29..277af3c 100644 --- a/bot.js +++ b/bot.js @@ -0,0 +1,5 @@ +const Telegraf = require("telegraf"); +const config = require("./config"); +const Sequelize = require("sequelize"); + +const bot = new Telegraf(config.botApiKey); diff --git a/data/index.js b/data/index.js new file mode 100644 index 0000000..a7c96ed --- /dev/null +++ b/data/index.js @@ -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); diff --git a/models/index.js b/models/index.js new file mode 100644 index 0000000..3ae1a2c --- /dev/null +++ b/models/index.js @@ -0,0 +1,3 @@ +module.exports = sequelize => ({ + integrations: require("./integrations")(sequelize), +}); diff --git a/models/integrations.js b/models/integrations.js new file mode 100644 index 0000000..7e24656 --- /dev/null +++ b/models/integrations.js @@ -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); +}; diff --git a/sample.config.js b/sample.config.js new file mode 100644 index 0000000..d0766b7 --- /dev/null +++ b/sample.config.js @@ -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" + } + }, +};