diff --git a/.gitignore b/.gitignore index fe77621..56160b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules/ -alice/src/auth/session.json +**/session.json diff --git a/alice/index.js b/alice/index.js deleted file mode 100644 index 5dea3ad..0000000 --- a/alice/index.js +++ /dev/null @@ -1,23 +0,0 @@ -const src = require('./src'); -const build = require('./src/build'); - -const path = new build.Path(__dirname); - -const alice = new src.Alice([ - path.create('scripts/bot', 'bot'), - path.create('scripts/coin', 'coin'), - path.create('scripts/commands', 'commands'), - path.create('scripts/cron', 'cron'), - path.create('scripts/dice', 'dice'), - path.create('scripts/doc', 'doc'), - path.create('scripts/doc', 'help'), - path.create('scripts/github', 'github'), - path.create('scripts/links', 'links'), - path.create('scripts/lyric', 'lyric'), - path.create('scripts/report', 'report'), - path.create('scripts/search', 'search'), - path.create('scripts/suggest', 'suggest'), - path.create('scripts/wiki', 'wiki'), -]); - -alice.initialize(); diff --git a/alice/scripts/bot.js b/alice/scripts/bot.js deleted file mode 100644 index 7157644..0000000 --- a/alice/scripts/bot.js +++ /dev/null @@ -1,3 +0,0 @@ -const output = `Olá, eu sou a Alice. Quer saber mais sobre mim? use o comando !doc`; - -module.exports = () => output.trim(); diff --git a/alice/scripts/commands.js b/alice/scripts/commands.js deleted file mode 100644 index 76437e6..0000000 --- a/alice/scripts/commands.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = () => { - const output = ` - Os seguintes comandos estão disponiveis: - - !bot - - !coin - - !commands - - !cron - - !dice - - !doc - - !github - - !links - - !lyric - - !report - - !search - - !suggest - - !wiki`; - return output.trim(); -}; diff --git a/alice/scripts/links.js b/alice/scripts/links.js deleted file mode 100644 index d9fb846..0000000 --- a/alice/scripts/links.js +++ /dev/null @@ -1,26 +0,0 @@ -const info = `Coding in python: - https://chat.whatsapp.com/I4IpHC0YFPQLUcGHJeqYdF - -Coding in C/C++: - https://chat.whatsapp.com/Csn56Bpj8hVIQ3FiZoxBKh - -Coding in Javascript: - https://chat.whatsapp.com/IUXcqbAPdJC2IuNfd7aaF5 - -Coding in PHP: - https://chat.whatsapp.com/C6wcXZhyT869Q29PIL1J20 - -Coding in Java: - https://chat.whatsapp.com/KDjc7IoCAYWAjCAwNEJ5cF - -Coding on Linux: - https://chat.whatsapp.com/D37sPPhUsiT5LZ8PQeqg4t - -Coding in Taberna: - https://chat.whatsapp.com/GOXnIXSXEFH7wHvO9aTuFs - -Speaking in English: - https://chat.whatsapp.com/EOirNapuFe3CVunBqbwj1Z -`; - -module.exports = () => info; diff --git a/alice/scripts/utils/parse.js b/alice/scripts/utils/parse.js deleted file mode 100644 index 2c2cf73..0000000 --- a/alice/scripts/utils/parse.js +++ /dev/null @@ -1,15 +0,0 @@ -function userID(targetNumber) { - if (typeof targetNumber !== 'string') { - throw new Error('you must pass the number as a string'); - } - - const target = targetNumber.replace(/\D/g, ''); - const regexp = /\d+/; - const matches = target.match(regexp); - const pattern = matches[0]; - return `${pattern}@c.us`; -} - -module.exports = { - userID, -}; diff --git a/index.js b/index.js new file mode 100644 index 0000000..5a6bbe3 --- /dev/null +++ b/index.js @@ -0,0 +1,23 @@ +const { Alice } = require('./src/Alice'); +const build = require('./src/build'); + +const path = new build.Path(__dirname); + +const alice = new Alice([ + path.create('src/commands/bot', 'bot'), + path.create('src/commands/coin', 'coin'), + path.create('src/commands/commands', 'commands'), + path.create('src/commands/cron', 'cron'), + path.create('src/commands/dice', 'dice'), + path.create('src/commands/doc', 'doc'), + path.create('src/commands/doc', 'help'), + path.create('src/commands/github', 'github'), + path.create('src/commands/links', 'links'), + path.create('src/commands/lyric', 'lyric'), + path.create('src/commands/report', 'report'), + path.create('src/commands/search', 'search'), + path.create('src/commands/suggest', 'suggest'), + path.create('src/commands/wiki', 'wiki'), +]); + +alice.initialize(); diff --git a/package.json b/package.json index cb33587..20b3993 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "alice", "version": "0.0.8", "description": "A multipurpose system based on Inside Heartz whatsapp bot", - "main": "alice/index.js", + "main": "index.js", "repository": { "type": "git", "url": "https://github.com/Coding-in-community/alice" diff --git a/alice/src/index.js b/src/Alice.js similarity index 94% rename from alice/src/index.js rename to src/Alice.js index 799b5c6..4c4859f 100644 --- a/alice/src/index.js +++ b/src/Alice.js @@ -1,5 +1,5 @@ const auth = require('./auth'); -const { Parse } = require('./parse'); +const { Parse } = require('./utils/Parse'); const build = require('./build'); const session = new auth.Session(); diff --git a/alice/src/auth/index.js b/src/auth/index.js similarity index 100% rename from alice/src/auth/index.js rename to src/auth/index.js diff --git a/alice/src/build/Commands.js b/src/build/Commands.js similarity index 100% rename from alice/src/build/Commands.js rename to src/build/Commands.js diff --git a/alice/src/build/Path.js b/src/build/Path.js similarity index 100% rename from alice/src/build/Path.js rename to src/build/Path.js diff --git a/alice/src/build/index.js b/src/build/index.js similarity index 100% rename from alice/src/build/index.js rename to src/build/index.js diff --git a/src/commands/bot.js b/src/commands/bot.js new file mode 100644 index 0000000..7f2047b --- /dev/null +++ b/src/commands/bot.js @@ -0,0 +1,2 @@ +module.exports = () => + `Olá, eu sou a Alice. Quer saber mais sobre mim? use o comando !doc`; diff --git a/alice/scripts/coin.js b/src/commands/coin.js similarity index 100% rename from alice/scripts/coin.js rename to src/commands/coin.js diff --git a/src/commands/commands.js b/src/commands/commands.js new file mode 100644 index 0000000..9ff9cf1 --- /dev/null +++ b/src/commands/commands.js @@ -0,0 +1,15 @@ +module.exports = () => + `Os seguintes comandos estão disponiveis: +- !bot +- !coin +- !commands +- !cron +- !dice +- !doc +- !github +- !links +- !lyric +- !report +- !search +- !suggest +- !wiki`.trim(); diff --git a/alice/scripts/cron.js b/src/commands/cron.js similarity index 97% rename from alice/scripts/cron.js rename to src/commands/cron.js index 7b9a3c0..8cec8a1 100644 --- a/alice/scripts/cron.js +++ b/src/commands/cron.js @@ -1,6 +1,5 @@ const events = require('events'); -const chattools = require('./utils/chattools'); -const time = require('./utils/time'); +const { chattools, time } = require('../utils'); const emitter = new events.EventEmitter(); let threads = []; diff --git a/alice/scripts/dice.js b/src/commands/dice.js similarity index 99% rename from alice/scripts/dice.js rename to src/commands/dice.js index 0858c3d..a9371b1 100644 --- a/alice/scripts/dice.js +++ b/src/commands/dice.js @@ -4,7 +4,7 @@ Ele deve ser escrito na forma d+ { const { text } = data; diff --git a/alice/scripts/doc.js b/src/commands/doc.js similarity index 100% rename from alice/scripts/doc.js rename to src/commands/doc.js diff --git a/alice/scripts/github.js b/src/commands/github.js similarity index 100% rename from alice/scripts/github.js rename to src/commands/github.js diff --git a/src/commands/links.js b/src/commands/links.js new file mode 100644 index 0000000..da4f919 --- /dev/null +++ b/src/commands/links.js @@ -0,0 +1,25 @@ +module.exports = () => + `Coding in python: +https://chat.whatsapp.com/I4IpHC0YFPQLUcGHJeqYdF + +Coding in C/C++: +https://chat.whatsapp.com/Csn56Bpj8hVIQ3FiZoxBKh + +Coding in Javascript: +https://chat.whatsapp.com/IUXcqbAPdJC2IuNfd7aaF5 + +Coding in PHP: +https://chat.whatsapp.com/C6wcXZhyT869Q29PIL1J20 + +Coding in Java: +https://chat.whatsapp.com/KDjc7IoCAYWAjCAwNEJ5cF + +Coding on Linux: +https://chat.whatsapp.com/D37sPPhUsiT5LZ8PQeqg4t + +Coding in Taberna: +https://chat.whatsapp.com/GOXnIXSXEFH7wHvO9aTuFs + +Speaking in English: +https://chat.whatsapp.com/EOirNapuFe3CVunBqbwj1Z +`.trim(); diff --git a/alice/scripts/lyric.js b/src/commands/lyric.js similarity index 95% rename from alice/scripts/lyric.js rename to src/commands/lyric.js index 3cba260..ee60399 100644 --- a/alice/scripts/lyric.js +++ b/src/commands/lyric.js @@ -1,6 +1,6 @@ const axios = require('axios'); const JSSoup = require('jssoup').default; -const search = require('./utils/search'); +const { search } = require('../utils'); async function makeSoup(url) { const { data } = await axios.get(url); diff --git a/alice/scripts/report.js b/src/commands/report.js similarity index 90% rename from alice/scripts/report.js rename to src/commands/report.js index 14e8ce6..22dc2e7 100644 --- a/alice/scripts/report.js +++ b/src/commands/report.js @@ -1,6 +1,6 @@ -const parse = require('./utils/parse'); +const { chattools } = require('../utils'); -const myID = parse.userID('+55 11 96734-3809'); +const myID = chattools.userID('+55 11 96734-3809'); const strings = { defaultMessage: ` uso: _!report [--flag] [descrição]_ diff --git a/alice/scripts/search.js b/src/commands/search.js similarity index 92% rename from alice/scripts/search.js rename to src/commands/search.js index 9c4e7e8..949704f 100644 --- a/alice/scripts/search.js +++ b/src/commands/search.js @@ -1,4 +1,4 @@ -const search = require('./utils/search'); +const { search } = require('../utils'); function callback(object) { const { title, link, snippet } = object; diff --git a/alice/scripts/suggest.js b/src/commands/suggest.js similarity index 89% rename from alice/scripts/suggest.js rename to src/commands/suggest.js index d841a06..87d6457 100644 --- a/alice/scripts/suggest.js +++ b/src/commands/suggest.js @@ -1,6 +1,6 @@ -const parse = require('./utils/parse'); +const { chattools } = require('../utils'); -const myID = parse.userID('+55 11 96734-3809'); +const myID = chattools.userID('+55 11 96734-3809'); const defaultMessage = ` uso: _!suggest [--flag] [sugestão]_ diff --git a/alice/scripts/wiki.js b/src/commands/wiki.js similarity index 100% rename from alice/scripts/wiki.js rename to src/commands/wiki.js diff --git a/alice/src/parse/index.js b/src/utils/Parse.js similarity index 100% rename from alice/src/parse/index.js rename to src/utils/Parse.js diff --git a/alice/scripts/utils/chattools.js b/src/utils/chattools.js similarity index 82% rename from alice/scripts/utils/chattools.js rename to src/utils/chattools.js index f4aa4d0..ce255f0 100644 --- a/alice/scripts/utils/chattools.js +++ b/src/utils/chattools.js @@ -44,9 +44,22 @@ async function isAdm(message) { return admList.includes(author); } +function userID(targetNumber) { + if (typeof targetNumber !== 'string') { + throw new Error('you must pass the number as a string'); + } + + const target = targetNumber.replace(/\D/g, ''); + const regexp = /\d+/; + const matches = target.match(regexp); + const pattern = matches[0]; + return `${pattern}@c.us`; +} + module.exports = { getAdmsList, getMembersList, getSerialList, isAdm, + userID, }; diff --git a/src/utils/index.js b/src/utils/index.js new file mode 100644 index 0000000..804d5f2 --- /dev/null +++ b/src/utils/index.js @@ -0,0 +1,8 @@ +/* eslint-disable global-require */ + +module.exports = { + Parse: require('./Parse'), + chattools: require('./chattools'), + search: require('./search'), + time: require('./time'), +}; diff --git a/alice/scripts/utils/search.js b/src/utils/search.js similarity index 100% rename from alice/scripts/utils/search.js rename to src/utils/search.js diff --git a/alice/scripts/utils/time.js b/src/utils/time.js similarity index 100% rename from alice/scripts/utils/time.js rename to src/utils/time.js