mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 20:49:15 +00:00
Compare commits
171 Commits
feature/mo
...
next-relea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06acec2bf2 | ||
|
|
c868f73462 | ||
|
|
93a990e229 | ||
|
|
00c587fbf2 | ||
|
|
e6fefb4049 | ||
|
|
2d5ac2664b | ||
|
|
4d4f15ce73 | ||
|
|
a30eaac775 | ||
|
|
5da4b7a4d1 | ||
|
|
4e0fcbd834 | ||
|
|
041bf6280e | ||
|
|
e37fd0da36 | ||
|
|
ca6afbb87f | ||
|
|
66f75f8722 | ||
|
|
31c83f5d68 | ||
|
|
1b83871cca | ||
|
|
337c2e94bc | ||
|
|
01fe9ebc9a | ||
|
|
23b2e8e439 | ||
|
|
f799498dec | ||
| 17466138dd | |||
| 63ca8e8892 | |||
| 60fdbf3d3c | |||
|
|
e8c249897d | ||
| 55d12810d9 | |||
| 639e2defa7 | |||
| b97d8ba8f1 | |||
|
|
f05b76936a | ||
|
|
0a4e1e052a | ||
|
|
28d88c282c | ||
|
|
a2be57f0aa | ||
|
|
670ecf121b | ||
|
|
79e2318256 | ||
|
|
87ba43a553 | ||
|
|
acc1d37e4f | ||
|
|
c578d039c0 | ||
|
|
162067104e | ||
|
|
ea677b6eea | ||
|
|
a82b1cfb57 | ||
| 61d0324261 | |||
|
|
4d692e0a26 | ||
|
|
9de7eada87 | ||
|
|
8f81d995a4 | ||
|
|
024f13691d | ||
|
|
4aa91cb22a | ||
|
|
9ecafe5fc8 | ||
|
|
d039e2aacd | ||
|
|
5173a6c467 | ||
|
|
1d08682393 | ||
|
|
0bb251b4d5 | ||
|
|
04baa7f6fd | ||
|
|
32212fb52d | ||
|
|
aa61a1e1b5 | ||
|
|
5ecf9c6ba7 | ||
|
|
d233cbac22 | ||
|
|
10098f018f | ||
|
|
70de13ef6a | ||
|
|
f912fd328f | ||
|
|
6a86da2851 | ||
|
|
1a2a246bf8 | ||
|
|
248d04b666 | ||
|
|
41e96ad027 | ||
|
|
f2fd254d17 | ||
|
|
7790391b50 | ||
|
|
b827a0ab22 | ||
|
|
4142ca4fd5 | ||
|
|
fee7c2e967 | ||
|
|
091544ac3f | ||
|
|
2ce342a0cb | ||
|
|
781779328f | ||
|
|
dfced8c594 | ||
|
|
aaa4ce8372 | ||
|
|
9ddf144244 | ||
|
|
b465de55a0 | ||
|
|
cf1dc6fac8 | ||
|
|
739c63d025 | ||
|
|
8d897f824e | ||
|
|
aad129ea94 | ||
|
|
e48b29ed29 | ||
|
|
c64560bfc3 | ||
|
|
255ba86506 | ||
|
|
cd2dad9d26 | ||
|
|
c7ff6b4794 | ||
|
|
628d55df37 | ||
|
|
0059a1e7fb | ||
|
|
73ea7c0063 | ||
|
|
cb9f4befa0 | ||
|
|
decccb672a | ||
|
|
51466bf1c7 | ||
|
|
397798790e | ||
|
|
d3b8310180 | ||
|
|
7797c2b461 | ||
|
|
929e74c84b | ||
| 08e2552907 | |||
| 6617107ab8 | |||
|
|
8921959ea0 | ||
|
|
ec46cfdd65 | ||
|
|
bfb69d9a95 | ||
|
|
15f6972257 | ||
|
|
2319db3009 | ||
|
|
9cb98b5e73 | ||
|
|
2999e0e753 | ||
|
|
af716b7537 | ||
|
|
c6999c8493 | ||
|
|
d4b49a9bd7 | ||
|
|
eebc3c9806 | ||
|
|
257f1cc12d | ||
|
|
1036273a28 | ||
|
|
1b8ed93367 | ||
|
|
8c1820c879 | ||
|
|
e5a9db7e12 | ||
|
|
9d5aa7db5d | ||
|
|
40b0d9691e | ||
|
|
2e906bce79 | ||
|
|
f05ff4cf88 | ||
|
|
5735b49e25 | ||
|
|
1988948c30 | ||
|
|
cb33c0df68 | ||
|
|
f4ad7040ab | ||
|
|
b115dc3654 | ||
|
|
8c6023e93b | ||
|
|
5d7c297f2f | ||
|
|
04f99d5ed2 | ||
|
|
bb3f21b056 | ||
|
|
cf6188d860 | ||
|
|
294bfbb35f | ||
|
|
230538bcea | ||
|
|
5e7aa72494 | ||
|
|
3159ea5665 | ||
|
|
4b307efe79 | ||
|
|
0105dab2c4 | ||
|
|
6e8e16c9a4 | ||
|
|
8d73c86946 | ||
|
|
a7b19d9bff | ||
|
|
4b7de0f690 | ||
|
|
520145bf7d | ||
|
|
2253d57fed | ||
|
|
0fb93f66a3 | ||
|
|
501887300d | ||
|
|
14b6247106 | ||
|
|
eda8a67718 | ||
|
|
73caf090ba | ||
|
|
afa6771903 | ||
|
|
8dd3be909b | ||
|
|
88af2469cb | ||
|
|
999d6742b4 | ||
|
|
24ac9fbf48 | ||
|
|
4350dff22a | ||
|
|
30e3d443bb | ||
|
|
f5ea7fe2c4 | ||
|
|
94d139e484 | ||
|
|
8049241f3f | ||
|
|
28d308ed4b | ||
|
|
e0862053d0 | ||
|
|
e0e76d3a56 | ||
|
|
242e44315b | ||
|
|
6b53ed13e2 | ||
|
|
fafccbcecc | ||
|
|
49698bfda9 | ||
|
|
4154cc2230 | ||
|
|
ce8a96b958 | ||
|
|
f373a3abc7 | ||
|
|
371ee0a780 | ||
|
|
5e1a373730 | ||
|
|
aa2417af12 | ||
|
|
f2533f1ed5 | ||
|
|
f9ccfef8e0 | ||
|
|
08dbdcf4ae | ||
|
|
d7ed9ff592 | ||
|
|
a99f424901 | ||
|
|
f29ed6e29b |
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
packages/docs/*
|
||||
@@ -10,5 +10,9 @@ module.exports = {
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {},
|
||||
rules: {
|
||||
'no-unsafe-negation': 'off',
|
||||
'no-prototype-builtins': 'off',
|
||||
'no-useless-escape': 'off',
|
||||
},
|
||||
}
|
||||
|
||||
9
.github/FUNDING.yml
vendored
Normal file
9
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: leifermendez
|
||||
open_collective: bot-whatsapp
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
custom: https://www.buymeacoffee.com/leifermendez
|
||||
66
.github/workflows/ci.yml
vendored
66
.github/workflows/ci.yml
vendored
@@ -1,26 +1,58 @@
|
||||
name: Test / Coverage
|
||||
name: BotWhatsapp Build-Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [feature/monorepo]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
build:
|
||||
############ BUILD PACKAGE ############
|
||||
build-package:
|
||||
name: Build Package
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x]
|
||||
|
||||
needs:
|
||||
- test-unit
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
- run: npm run build --if-present
|
||||
- run: npm run test.unit
|
||||
- run: npm run test.coverage
|
||||
node-version: 16.x
|
||||
cache: 'yarn'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- run: corepack enable
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --immutable --network-timeout 300000
|
||||
|
||||
- name: Build Package
|
||||
run: yarn build
|
||||
|
||||
- name: Build Eslint rules
|
||||
run: yarn lint:fix
|
||||
|
||||
############ UNIT TEST ############
|
||||
test-unit:
|
||||
name: Unit Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: 'yarn'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- run: corepack enable
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --immutable --network-timeout 300000
|
||||
|
||||
- name: Unit Tests
|
||||
run: yarn test
|
||||
|
||||
19
.github/workflows/contributors.yml
vendored
Normal file
19
.github/workflows/contributors.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
name: Add contributors
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
types: [closed]
|
||||
|
||||
jobs:
|
||||
contrib-readme-job:
|
||||
runs-on: ubuntu-latest
|
||||
name: A job to automate contrib in readme
|
||||
steps:
|
||||
- name: Contribute List
|
||||
uses: akhilmhdh/contributors-readme-action@v2.3.6
|
||||
with:
|
||||
image_size: 50
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
56
.github/workflows/releases-dev.yml
vendored
Normal file
56
.github/workflows/releases-dev.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: BotWhatsapp Releases(DEV)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- next-release
|
||||
|
||||
jobs:
|
||||
############ RELEASE ############
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: 'yarn'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- run: corepack enable
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --immutable --network-timeout 300000
|
||||
|
||||
- name: Build Package
|
||||
run: yarn build
|
||||
|
||||
- name: Release @bot-whatsapp/bot
|
||||
run: yarn node ./scripts/release.js --name=bot --version= --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/cli
|
||||
run: yarn node ./scripts/release.js --name=cli --version= --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/create-bot-whatsapp
|
||||
run: yarn node ./scripts/release.js --name=create-bot-whatsapp --version= --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/database
|
||||
run: yarn node ./scripts/release.js --name=database --version= --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/provider
|
||||
run: yarn node ./scripts/release.js --name=provider --version= --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Commit Versioning & Push changes
|
||||
uses: actions-js/push@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: 'ci(version): :zap: automatic - "${date}" updated versions every packages'
|
||||
branch: 'dev'
|
||||
60
.github/workflows/releases.yml
vendored
Normal file
60
.github/workflows/releases.yml
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
name: BotWhatsapp Releases(Prod)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
############ RELEASE ############
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set output
|
||||
id: vars
|
||||
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: 'yarn'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- run: corepack enable
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: yarn install --immutable --network-timeout 300000
|
||||
|
||||
- name: Build Package
|
||||
run: yarn build
|
||||
|
||||
- name: Release @bot-whatsapp/bot
|
||||
run: yarn node ./scripts/release.js --name=bot --version="${{ steps.vars.outputs.tag }}" --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/cli
|
||||
run: yarn node ./scripts/release.js --name=cli --version="${{ steps.vars.outputs.tag }}" --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/create-bot-whatsapp
|
||||
run: yarn node ./scripts/release.js --name=create-bot-whatsapp --version="${{ steps.vars.outputs.tag }}" --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/database
|
||||
run: yarn node ./scripts/release.js --name=database --version="${{ steps.vars.outputs.tag }}" --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Release @bot-whatsapp/provider
|
||||
run: yarn node ./scripts/release.js --name=provider --version="${{ steps.vars.outputs.tag }}" --token="${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
- name: Commit Versioning & Push changes
|
||||
uses: actions-js/push@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: 'ci(version): :zap: automatic - "${date}" updated versions every packages'
|
||||
branch: 'dev'
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -1,7 +1,9 @@
|
||||
/node_modules
|
||||
/packages/*/starters
|
||||
/packages/*/node_modules
|
||||
/packages/*/dist
|
||||
/packages/*/docs/dist
|
||||
/packages/provider/src/venom/tokens
|
||||
session.json
|
||||
chats/*
|
||||
!chats/.gitkeep
|
||||
@@ -18,6 +20,9 @@ config.json
|
||||
coverage/
|
||||
*.lcov
|
||||
log
|
||||
log/*
|
||||
*.log
|
||||
*.tgz
|
||||
lib
|
||||
tmp/
|
||||
.yarn/*
|
||||
@@ -25,6 +30,9 @@ tmp/
|
||||
!.yarn/plugins/@yarnpkg/plugin-postinstall.cjs
|
||||
.fleet/
|
||||
example-app*/
|
||||
base-*/
|
||||
!starters/apps/base-*/
|
||||
qr.svg
|
||||
package-lock.json
|
||||
yarn-error.log
|
||||
yarn-error.log
|
||||
.npmrc
|
||||
@@ -1,5 +1,5 @@
|
||||
packages/**/lib
|
||||
packages/docs
|
||||
packages/docs/*.json
|
||||
**/.git
|
||||
**/.svn
|
||||
**/.hg
|
||||
|
||||
11
.vscode/settings.json
vendored
11
.vscode/settings.json
vendored
@@ -1,3 +1,12 @@
|
||||
{
|
||||
"conventionalCommits.scopes": ["hook", "contributing", "cli"]
|
||||
"conventionalCommits.scopes": [
|
||||
"hook",
|
||||
"contributing",
|
||||
"cli",
|
||||
"bot",
|
||||
"provider",
|
||||
"adapter",
|
||||
"ci",
|
||||
"starters"
|
||||
]
|
||||
}
|
||||
|
||||
2
.yarn/releases/yarn-3.3.0.cjs
vendored
2
.yarn/releases/yarn-3.3.0.cjs
vendored
@@ -804,4 +804,4 @@ ${a.map(l=>`
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
*/
|
||||
*/
|
||||
225
CHANGELOG.md
225
CHANGELOG.md
@@ -2,6 +2,231 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.1.2](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.1...v0.1.2) (2022-12-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cli:** :art: starters ([79e2318](https://github.com/leifermendez/bot-whatsapp/commit/79e231825613f33bfec2ae8e93139f885c199c7a))
|
||||
* **cli:** :art: starters ([87ba43a](https://github.com/leifermendez/bot-whatsapp/commit/87ba43a5535be0893a7701a3b6a085ee5d29e7c5))
|
||||
* fix dependencias ([61d0324](https://github.com/leifermendez/bot-whatsapp/commit/61d032426119341187a470035d49b8b252ca46cd))
|
||||
|
||||
### [0.1.1](https://github.com/leifermendez/bot-whatsapp/compare/v0.3.0...v0.1.1) (2022-12-12)
|
||||
|
||||
## 0.3.0 (2022-12-12)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* 🧨 NO
|
||||
|
||||
### Features
|
||||
|
||||
* (🎸) add onClick prop to component ([4ae3898](https://github.com/leifermendez/bot-whatsapp/commit/4ae389846d38c133f6bb2129ae373eed39d9d08d))
|
||||
* **adapter:** added adapter mysql ([717a7dc](https://github.com/leifermendez/bot-whatsapp/commit/717a7dc95fbc107ec6f55387aff606c47144baa4))
|
||||
* **adapter:** implementation of json file adapter ([5e1a373](https://github.com/leifermendez/bot-whatsapp/commit/5e1a3737303c843095984f6357564ea18458362f))
|
||||
* **adapter:** mysql adapter ([8d73c86](https://github.com/leifermendez/bot-whatsapp/commit/8d73c86946d07aa80e5b375b62b84a88b2892e03))
|
||||
* **adapter:** sql is added to create the table ([4b7de0f](https://github.com/leifermendez/bot-whatsapp/commit/4b7de0f6901524fa2c09271c3a99c364e6b3c260))
|
||||
* **bot:** :fire: improvement provider handler ([4154cc2](https://github.com/leifermendez/bot-whatsapp/commit/4154cc223091a46d3203d3a378cd42f61749a5fa))
|
||||
* **bot:** :zap: add send image function ([ce8a96b](https://github.com/leifermendez/bot-whatsapp/commit/ce8a96b958ff814c65d8fb4dbd5eaed5cc83a1ed))
|
||||
* **ci:** :art: add releases ([b115dc3](https://github.com/leifermendez/bot-whatsapp/commit/b115dc3654996f049837bfb6b5d039a2313df0ad))
|
||||
* **ci:** :art: relases script ([2e906bc](https://github.com/leifermendez/bot-whatsapp/commit/2e906bce79f7d854d437334e1d0c2cd270b0bbc6))
|
||||
* **ci:** update ci ([e5a9db7](https://github.com/leifermendez/bot-whatsapp/commit/e5a9db7e12340c4f5baa66e8b20585b63daa3bcf))
|
||||
* **cli:** create-starter ([3977987](https://github.com/leifermendez/bot-whatsapp/commit/397798790ef5857ca758b0df8384c6a4bfacc181))
|
||||
* **provider:** :fire: add twilii (weoking) ([4350dff](https://github.com/leifermendez/bot-whatsapp/commit/4350dff22a7de69ba6d35ecbdd67e59b810bd46f))
|
||||
* **provider:** added twilio provider ([8dd3be9](https://github.com/leifermendez/bot-whatsapp/commit/8dd3be909b36717f6b54e141a5f48d2722d4855c))
|
||||
* **release:** added ([1988948](https://github.com/leifermendez/bot-whatsapp/commit/1988948c30d922beb7b83faab96d1d59cf7f5f90))
|
||||
* **release:** added ([f4ad704](https://github.com/leifermendez/bot-whatsapp/commit/f4ad7040abf619635480c30babd6f1159c7af85a))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **adapter:** conflict resolution ([4b307ef](https://github.com/leifermendez/bot-whatsapp/commit/4b307efe79c738a5c4e04ff1c07ca247d827593c))
|
||||
* **adapter:** corrections are made to the adapter ([afa6771](https://github.com/leifermendez/bot-whatsapp/commit/afa677190392d48715930ebe2b1e15c7619d730f))
|
||||
* **bot:** :zap: added delay promises ([73caf09](https://github.com/leifermendez/bot-whatsapp/commit/73caf090ba9013132e5dcb7761a10939dc9ac300))
|
||||
* **bot:** :zap: fix sensitive case ([24ac9fb](https://github.com/leifermendez/bot-whatsapp/commit/24ac9fbf48f80eeb521a36bc938af3a70dd82303))
|
||||
* **bot:** :zap: flow improvement + add utils ([a7b19d9](https://github.com/leifermendez/bot-whatsapp/commit/a7b19d9bff5ea66ff888555c3df37ae0e20b612a))
|
||||
* **bot:** update ([49698bf](https://github.com/leifermendez/bot-whatsapp/commit/49698bfda9d2a53f7b1a7e1724a796698601fbaa))
|
||||
* **ci:** :zap: balance version ([ec46cfd](https://github.com/leifermendez/bot-whatsapp/commit/ec46cfdd657c08c8e90261613f00cfc080f1e1d6))
|
||||
* **ci:** :zap: github action ([b827a0a](https://github.com/leifermendez/bot-whatsapp/commit/b827a0ab225b89bb8117c82628db0679c09b4102))
|
||||
* **ci:** :zap: github action ([4142ca4](https://github.com/leifermendez/bot-whatsapp/commit/4142ca4fd552e7005f3b1397a76b90a2e574d19d))
|
||||
* **ci:** :zap: github action ([091544a](https://github.com/leifermendez/bot-whatsapp/commit/091544ac3fac0c16925e856e1aec64bcad0ecf6d))
|
||||
* **ci:** :zap: github action ([2ce342a](https://github.com/leifermendez/bot-whatsapp/commit/2ce342a0cb15019d5084ca06dc30e342b030ea10))
|
||||
* **ci:** :zap: github action ([7817793](https://github.com/leifermendez/bot-whatsapp/commit/781779328f93ef8b0e6e0f85c6cd05ae782112fb))
|
||||
* **ci:** :zap: github action ([dfced8c](https://github.com/leifermendez/bot-whatsapp/commit/dfced8c594e9175c81e837af359631ba055b7e1a))
|
||||
* **ci:** :zap: github action ([aaa4ce8](https://github.com/leifermendez/bot-whatsapp/commit/aaa4ce837229fd51e274de3d91e1d9d615ac69fd))
|
||||
* **ci:** :zap: github action ([9ddf144](https://github.com/leifermendez/bot-whatsapp/commit/9ddf144244cd6877e7d26f576387814459f2befb))
|
||||
* **ci:** :zap: github action ([b465de5](https://github.com/leifermendez/bot-whatsapp/commit/b465de55a0e511213d1a7760a74efa102172c85e))
|
||||
* **ci:** :zap: github action ([cf1dc6f](https://github.com/leifermendez/bot-whatsapp/commit/cf1dc6fac810545e5a2b63f31f71322f37329e38))
|
||||
* **ci:** :zap: github action ([8d897f8](https://github.com/leifermendez/bot-whatsapp/commit/8d897f824e27a55ca011163092a813a7e8f426af))
|
||||
* **ci:** ci ([f55cfae](https://github.com/leifermendez/bot-whatsapp/commit/f55cfae6e4ccc1df949212999406680020d27f9c))
|
||||
* **ci:** ci ([671c5b3](https://github.com/leifermendez/bot-whatsapp/commit/671c5b37f33360e8cb754625b8dd6e83bce9014d))
|
||||
* **cli:** :bug: path ([32212fb](https://github.com/leifermendez/bot-whatsapp/commit/32212fb52d206bf6f8d753a86d9ce40aa0db2a5d))
|
||||
* **cli:** :fire: create script - templates ([2319db3](https://github.com/leifermendez/bot-whatsapp/commit/2319db3009501fe57ae21e60ad286eb68c46f4fd))
|
||||
* **cli:** :fire: create script - templates ([9cb98b5](https://github.com/leifermendez/bot-whatsapp/commit/9cb98b5e73fca3c3f5e70a8497badc31e494b943))
|
||||
* **cli:** :fire: create script - templates ([2999e0e](https://github.com/leifermendez/bot-whatsapp/commit/2999e0e753f31a8b9e6d7c117e78cdb5656e203a))
|
||||
* **cli:** :fire: create script - templates ([af716b7](https://github.com/leifermendez/bot-whatsapp/commit/af716b75372899877a81b528b58278376166d0ad))
|
||||
* **cli:** :fire: create script - templates ([c6999c8](https://github.com/leifermendez/bot-whatsapp/commit/c6999c84931083a87b5717db58003be68244707e))
|
||||
* **cli:** :fire: create script - templates ([d4b49a9](https://github.com/leifermendez/bot-whatsapp/commit/d4b49a9bd7085070f0c5964d2903f10b71bde0b3))
|
||||
* **cli:** :fire: create script - templates ([eebc3c9](https://github.com/leifermendez/bot-whatsapp/commit/eebc3c980638d88f11a0d93b8344f3ff345c7ee5))
|
||||
* **cli:** :zap: clean eslinter ([bfb69d9](https://github.com/leifermendez/bot-whatsapp/commit/bfb69d9a9574a757ae02748b6c5f5afa3eac68e6))
|
||||
* **cli:** :zap: clean eslinter ([15f6972](https://github.com/leifermendez/bot-whatsapp/commit/15f697225775a0f0e0a440cd980f7fb8f51a1056))
|
||||
* **cli:** :zap: create-starter ([d3b8310](https://github.com/leifermendez/bot-whatsapp/commit/d3b8310180d2ad813733b1d18f2c32d7d947740a))
|
||||
* **cli:** :zap: update cli copy ([7797c2b](https://github.com/leifermendez/bot-whatsapp/commit/7797c2b46133697e2a591adab2b67e66b34a1cfe))
|
||||
* **fix:** fix ([6483545](https://github.com/leifermendez/bot-whatsapp/commit/648354500b123f20044f5ac2e8a26b15f16d1b8d))
|
||||
* **fix:** fix ([28c0480](https://github.com/leifermendez/bot-whatsapp/commit/28c0480b8bfa6b24394095f57c36ef89c9aeb566))
|
||||
* **linter:** update linter and commitlint ([70a94ab](https://github.com/leifermendez/bot-whatsapp/commit/70a94ab2c6f8e4122780c77bc3a621944883e621))
|
||||
* pre-copy fix ([08e2552](https://github.com/leifermendez/bot-whatsapp/commit/08e2552907c48cfeaac843457a18bf2032e6f8aa))
|
||||
* pre-copy fix ([6617107](https://github.com/leifermendez/bot-whatsapp/commit/6617107ab824215c449e26eae6c2bb327ecfc092))
|
||||
* **starter:** pre-copy fix ([929e74c](https://github.com/leifermendez/bot-whatsapp/commit/929e74c84b667ec13cb5490b3b951cb8df15ebd1))
|
||||
|
||||
|
||||
* (💍) Is justa test! ([37d04e9](https://github.com/leifermendez/bot-whatsapp/commit/37d04e9e89d3f01fdc367654ba60fb11ab2614c4))
|
||||
|
||||
### [0.2.1](https://github.com/leifermendez/bot-whatsapp/compare/v0.2.0...v0.2.1) (2022-12-12)
|
||||
|
||||
## 0.2.0 (2022-12-12)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* 🧨 NO
|
||||
|
||||
### Features
|
||||
|
||||
* (🎸) add onClick prop to component ([4ae3898](https://github.com/leifermendez/bot-whatsapp/commit/4ae389846d38c133f6bb2129ae373eed39d9d08d))
|
||||
* **adapter:** added adapter mysql ([717a7dc](https://github.com/leifermendez/bot-whatsapp/commit/717a7dc95fbc107ec6f55387aff606c47144baa4))
|
||||
* **adapter:** implementation of json file adapter ([5e1a373](https://github.com/leifermendez/bot-whatsapp/commit/5e1a3737303c843095984f6357564ea18458362f))
|
||||
* **adapter:** mysql adapter ([8d73c86](https://github.com/leifermendez/bot-whatsapp/commit/8d73c86946d07aa80e5b375b62b84a88b2892e03))
|
||||
* **adapter:** sql is added to create the table ([4b7de0f](https://github.com/leifermendez/bot-whatsapp/commit/4b7de0f6901524fa2c09271c3a99c364e6b3c260))
|
||||
* **bot:** :fire: improvement provider handler ([4154cc2](https://github.com/leifermendez/bot-whatsapp/commit/4154cc223091a46d3203d3a378cd42f61749a5fa))
|
||||
* **bot:** :zap: add send image function ([ce8a96b](https://github.com/leifermendez/bot-whatsapp/commit/ce8a96b958ff814c65d8fb4dbd5eaed5cc83a1ed))
|
||||
* **ci:** :art: add releases ([b115dc3](https://github.com/leifermendez/bot-whatsapp/commit/b115dc3654996f049837bfb6b5d039a2313df0ad))
|
||||
* **ci:** :art: relases script ([2e906bc](https://github.com/leifermendez/bot-whatsapp/commit/2e906bce79f7d854d437334e1d0c2cd270b0bbc6))
|
||||
* **ci:** update ci ([e5a9db7](https://github.com/leifermendez/bot-whatsapp/commit/e5a9db7e12340c4f5baa66e8b20585b63daa3bcf))
|
||||
* **cli:** create-starter ([3977987](https://github.com/leifermendez/bot-whatsapp/commit/397798790ef5857ca758b0df8384c6a4bfacc181))
|
||||
* **provider:** :fire: add twilii (weoking) ([4350dff](https://github.com/leifermendez/bot-whatsapp/commit/4350dff22a7de69ba6d35ecbdd67e59b810bd46f))
|
||||
* **provider:** added twilio provider ([8dd3be9](https://github.com/leifermendez/bot-whatsapp/commit/8dd3be909b36717f6b54e141a5f48d2722d4855c))
|
||||
* **release:** added ([1988948](https://github.com/leifermendez/bot-whatsapp/commit/1988948c30d922beb7b83faab96d1d59cf7f5f90))
|
||||
* **release:** added ([f4ad704](https://github.com/leifermendez/bot-whatsapp/commit/f4ad7040abf619635480c30babd6f1159c7af85a))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **adapter:** conflict resolution ([4b307ef](https://github.com/leifermendez/bot-whatsapp/commit/4b307efe79c738a5c4e04ff1c07ca247d827593c))
|
||||
* **adapter:** corrections are made to the adapter ([afa6771](https://github.com/leifermendez/bot-whatsapp/commit/afa677190392d48715930ebe2b1e15c7619d730f))
|
||||
* **bot:** :zap: added delay promises ([73caf09](https://github.com/leifermendez/bot-whatsapp/commit/73caf090ba9013132e5dcb7761a10939dc9ac300))
|
||||
* **bot:** :zap: fix sensitive case ([24ac9fb](https://github.com/leifermendez/bot-whatsapp/commit/24ac9fbf48f80eeb521a36bc938af3a70dd82303))
|
||||
* **bot:** :zap: flow improvement + add utils ([a7b19d9](https://github.com/leifermendez/bot-whatsapp/commit/a7b19d9bff5ea66ff888555c3df37ae0e20b612a))
|
||||
* **bot:** update ([49698bf](https://github.com/leifermendez/bot-whatsapp/commit/49698bfda9d2a53f7b1a7e1724a796698601fbaa))
|
||||
* **ci:** :zap: balance version ([ec46cfd](https://github.com/leifermendez/bot-whatsapp/commit/ec46cfdd657c08c8e90261613f00cfc080f1e1d6))
|
||||
* **ci:** :zap: github action ([b827a0a](https://github.com/leifermendez/bot-whatsapp/commit/b827a0ab225b89bb8117c82628db0679c09b4102))
|
||||
* **ci:** :zap: github action ([4142ca4](https://github.com/leifermendez/bot-whatsapp/commit/4142ca4fd552e7005f3b1397a76b90a2e574d19d))
|
||||
* **ci:** :zap: github action ([091544a](https://github.com/leifermendez/bot-whatsapp/commit/091544ac3fac0c16925e856e1aec64bcad0ecf6d))
|
||||
* **ci:** :zap: github action ([2ce342a](https://github.com/leifermendez/bot-whatsapp/commit/2ce342a0cb15019d5084ca06dc30e342b030ea10))
|
||||
* **ci:** :zap: github action ([7817793](https://github.com/leifermendez/bot-whatsapp/commit/781779328f93ef8b0e6e0f85c6cd05ae782112fb))
|
||||
* **ci:** :zap: github action ([dfced8c](https://github.com/leifermendez/bot-whatsapp/commit/dfced8c594e9175c81e837af359631ba055b7e1a))
|
||||
* **ci:** :zap: github action ([aaa4ce8](https://github.com/leifermendez/bot-whatsapp/commit/aaa4ce837229fd51e274de3d91e1d9d615ac69fd))
|
||||
* **ci:** :zap: github action ([9ddf144](https://github.com/leifermendez/bot-whatsapp/commit/9ddf144244cd6877e7d26f576387814459f2befb))
|
||||
* **ci:** :zap: github action ([b465de5](https://github.com/leifermendez/bot-whatsapp/commit/b465de55a0e511213d1a7760a74efa102172c85e))
|
||||
* **ci:** :zap: github action ([cf1dc6f](https://github.com/leifermendez/bot-whatsapp/commit/cf1dc6fac810545e5a2b63f31f71322f37329e38))
|
||||
* **ci:** :zap: github action ([8d897f8](https://github.com/leifermendez/bot-whatsapp/commit/8d897f824e27a55ca011163092a813a7e8f426af))
|
||||
* **ci:** ci ([f55cfae](https://github.com/leifermendez/bot-whatsapp/commit/f55cfae6e4ccc1df949212999406680020d27f9c))
|
||||
* **ci:** ci ([671c5b3](https://github.com/leifermendez/bot-whatsapp/commit/671c5b37f33360e8cb754625b8dd6e83bce9014d))
|
||||
* **cli:** :bug: path ([32212fb](https://github.com/leifermendez/bot-whatsapp/commit/32212fb52d206bf6f8d753a86d9ce40aa0db2a5d))
|
||||
* **cli:** :fire: create script - templates ([2319db3](https://github.com/leifermendez/bot-whatsapp/commit/2319db3009501fe57ae21e60ad286eb68c46f4fd))
|
||||
* **cli:** :fire: create script - templates ([9cb98b5](https://github.com/leifermendez/bot-whatsapp/commit/9cb98b5e73fca3c3f5e70a8497badc31e494b943))
|
||||
* **cli:** :fire: create script - templates ([2999e0e](https://github.com/leifermendez/bot-whatsapp/commit/2999e0e753f31a8b9e6d7c117e78cdb5656e203a))
|
||||
* **cli:** :fire: create script - templates ([af716b7](https://github.com/leifermendez/bot-whatsapp/commit/af716b75372899877a81b528b58278376166d0ad))
|
||||
* **cli:** :fire: create script - templates ([c6999c8](https://github.com/leifermendez/bot-whatsapp/commit/c6999c84931083a87b5717db58003be68244707e))
|
||||
* **cli:** :fire: create script - templates ([d4b49a9](https://github.com/leifermendez/bot-whatsapp/commit/d4b49a9bd7085070f0c5964d2903f10b71bde0b3))
|
||||
* **cli:** :fire: create script - templates ([eebc3c9](https://github.com/leifermendez/bot-whatsapp/commit/eebc3c980638d88f11a0d93b8344f3ff345c7ee5))
|
||||
* **cli:** :zap: clean eslinter ([bfb69d9](https://github.com/leifermendez/bot-whatsapp/commit/bfb69d9a9574a757ae02748b6c5f5afa3eac68e6))
|
||||
* **cli:** :zap: clean eslinter ([15f6972](https://github.com/leifermendez/bot-whatsapp/commit/15f697225775a0f0e0a440cd980f7fb8f51a1056))
|
||||
* **cli:** :zap: create-starter ([d3b8310](https://github.com/leifermendez/bot-whatsapp/commit/d3b8310180d2ad813733b1d18f2c32d7d947740a))
|
||||
* **cli:** :zap: update cli copy ([7797c2b](https://github.com/leifermendez/bot-whatsapp/commit/7797c2b46133697e2a591adab2b67e66b34a1cfe))
|
||||
* **fix:** fix ([6483545](https://github.com/leifermendez/bot-whatsapp/commit/648354500b123f20044f5ac2e8a26b15f16d1b8d))
|
||||
* **fix:** fix ([28c0480](https://github.com/leifermendez/bot-whatsapp/commit/28c0480b8bfa6b24394095f57c36ef89c9aeb566))
|
||||
* **linter:** update linter and commitlint ([70a94ab](https://github.com/leifermendez/bot-whatsapp/commit/70a94ab2c6f8e4122780c77bc3a621944883e621))
|
||||
* pre-copy fix ([08e2552](https://github.com/leifermendez/bot-whatsapp/commit/08e2552907c48cfeaac843457a18bf2032e6f8aa))
|
||||
* pre-copy fix ([6617107](https://github.com/leifermendez/bot-whatsapp/commit/6617107ab824215c449e26eae6c2bb327ecfc092))
|
||||
* **starter:** pre-copy fix ([929e74c](https://github.com/leifermendez/bot-whatsapp/commit/929e74c84b667ec13cb5490b3b951cb8df15ebd1))
|
||||
|
||||
|
||||
* (💍) Is justa test! ([37d04e9](https://github.com/leifermendez/bot-whatsapp/commit/37d04e9e89d3f01fdc367654ba60fb11ab2614c4))
|
||||
|
||||
### [0.0.3](https://github.com/leifermendez/bot-whatsapp/compare/v0.2.0...v0.0.3) (2022-12-12)
|
||||
|
||||
## 0.2.0 (2022-12-12)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* 🧨 NO
|
||||
|
||||
### Features
|
||||
|
||||
* (🎸) add onClick prop to component ([4ae3898](https://github.com/leifermendez/bot-whatsapp/commit/4ae389846d38c133f6bb2129ae373eed39d9d08d))
|
||||
* **adapter:** added adapter mysql ([717a7dc](https://github.com/leifermendez/bot-whatsapp/commit/717a7dc95fbc107ec6f55387aff606c47144baa4))
|
||||
* **adapter:** implementation of json file adapter ([5e1a373](https://github.com/leifermendez/bot-whatsapp/commit/5e1a3737303c843095984f6357564ea18458362f))
|
||||
* **adapter:** mysql adapter ([8d73c86](https://github.com/leifermendez/bot-whatsapp/commit/8d73c86946d07aa80e5b375b62b84a88b2892e03))
|
||||
* **adapter:** sql is added to create the table ([4b7de0f](https://github.com/leifermendez/bot-whatsapp/commit/4b7de0f6901524fa2c09271c3a99c364e6b3c260))
|
||||
* **bot:** :fire: improvement provider handler ([4154cc2](https://github.com/leifermendez/bot-whatsapp/commit/4154cc223091a46d3203d3a378cd42f61749a5fa))
|
||||
* **bot:** :zap: add send image function ([ce8a96b](https://github.com/leifermendez/bot-whatsapp/commit/ce8a96b958ff814c65d8fb4dbd5eaed5cc83a1ed))
|
||||
* **ci:** :art: add releases ([b115dc3](https://github.com/leifermendez/bot-whatsapp/commit/b115dc3654996f049837bfb6b5d039a2313df0ad))
|
||||
* **ci:** :art: relases script ([2e906bc](https://github.com/leifermendez/bot-whatsapp/commit/2e906bce79f7d854d437334e1d0c2cd270b0bbc6))
|
||||
* **ci:** update ci ([e5a9db7](https://github.com/leifermendez/bot-whatsapp/commit/e5a9db7e12340c4f5baa66e8b20585b63daa3bcf))
|
||||
* **cli:** create-starter ([3977987](https://github.com/leifermendez/bot-whatsapp/commit/397798790ef5857ca758b0df8384c6a4bfacc181))
|
||||
* **provider:** :fire: add twilii (weoking) ([4350dff](https://github.com/leifermendez/bot-whatsapp/commit/4350dff22a7de69ba6d35ecbdd67e59b810bd46f))
|
||||
* **provider:** added twilio provider ([8dd3be9](https://github.com/leifermendez/bot-whatsapp/commit/8dd3be909b36717f6b54e141a5f48d2722d4855c))
|
||||
* **release:** added ([1988948](https://github.com/leifermendez/bot-whatsapp/commit/1988948c30d922beb7b83faab96d1d59cf7f5f90))
|
||||
* **release:** added ([f4ad704](https://github.com/leifermendez/bot-whatsapp/commit/f4ad7040abf619635480c30babd6f1159c7af85a))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **adapter:** conflict resolution ([4b307ef](https://github.com/leifermendez/bot-whatsapp/commit/4b307efe79c738a5c4e04ff1c07ca247d827593c))
|
||||
* **adapter:** corrections are made to the adapter ([afa6771](https://github.com/leifermendez/bot-whatsapp/commit/afa677190392d48715930ebe2b1e15c7619d730f))
|
||||
* **bot:** :zap: added delay promises ([73caf09](https://github.com/leifermendez/bot-whatsapp/commit/73caf090ba9013132e5dcb7761a10939dc9ac300))
|
||||
* **bot:** :zap: fix sensitive case ([24ac9fb](https://github.com/leifermendez/bot-whatsapp/commit/24ac9fbf48f80eeb521a36bc938af3a70dd82303))
|
||||
* **bot:** :zap: flow improvement + add utils ([a7b19d9](https://github.com/leifermendez/bot-whatsapp/commit/a7b19d9bff5ea66ff888555c3df37ae0e20b612a))
|
||||
* **bot:** update ([49698bf](https://github.com/leifermendez/bot-whatsapp/commit/49698bfda9d2a53f7b1a7e1724a796698601fbaa))
|
||||
* **ci:** :zap: balance version ([ec46cfd](https://github.com/leifermendez/bot-whatsapp/commit/ec46cfdd657c08c8e90261613f00cfc080f1e1d6))
|
||||
* **ci:** :zap: github action ([b827a0a](https://github.com/leifermendez/bot-whatsapp/commit/b827a0ab225b89bb8117c82628db0679c09b4102))
|
||||
* **ci:** :zap: github action ([4142ca4](https://github.com/leifermendez/bot-whatsapp/commit/4142ca4fd552e7005f3b1397a76b90a2e574d19d))
|
||||
* **ci:** :zap: github action ([091544a](https://github.com/leifermendez/bot-whatsapp/commit/091544ac3fac0c16925e856e1aec64bcad0ecf6d))
|
||||
* **ci:** :zap: github action ([2ce342a](https://github.com/leifermendez/bot-whatsapp/commit/2ce342a0cb15019d5084ca06dc30e342b030ea10))
|
||||
* **ci:** :zap: github action ([7817793](https://github.com/leifermendez/bot-whatsapp/commit/781779328f93ef8b0e6e0f85c6cd05ae782112fb))
|
||||
* **ci:** :zap: github action ([dfced8c](https://github.com/leifermendez/bot-whatsapp/commit/dfced8c594e9175c81e837af359631ba055b7e1a))
|
||||
* **ci:** :zap: github action ([aaa4ce8](https://github.com/leifermendez/bot-whatsapp/commit/aaa4ce837229fd51e274de3d91e1d9d615ac69fd))
|
||||
* **ci:** :zap: github action ([9ddf144](https://github.com/leifermendez/bot-whatsapp/commit/9ddf144244cd6877e7d26f576387814459f2befb))
|
||||
* **ci:** :zap: github action ([b465de5](https://github.com/leifermendez/bot-whatsapp/commit/b465de55a0e511213d1a7760a74efa102172c85e))
|
||||
* **ci:** :zap: github action ([cf1dc6f](https://github.com/leifermendez/bot-whatsapp/commit/cf1dc6fac810545e5a2b63f31f71322f37329e38))
|
||||
* **ci:** :zap: github action ([8d897f8](https://github.com/leifermendez/bot-whatsapp/commit/8d897f824e27a55ca011163092a813a7e8f426af))
|
||||
* **ci:** ci ([f55cfae](https://github.com/leifermendez/bot-whatsapp/commit/f55cfae6e4ccc1df949212999406680020d27f9c))
|
||||
* **ci:** ci ([671c5b3](https://github.com/leifermendez/bot-whatsapp/commit/671c5b37f33360e8cb754625b8dd6e83bce9014d))
|
||||
* **cli:** :bug: path ([32212fb](https://github.com/leifermendez/bot-whatsapp/commit/32212fb52d206bf6f8d753a86d9ce40aa0db2a5d))
|
||||
* **cli:** :fire: create script - templates ([2319db3](https://github.com/leifermendez/bot-whatsapp/commit/2319db3009501fe57ae21e60ad286eb68c46f4fd))
|
||||
* **cli:** :fire: create script - templates ([9cb98b5](https://github.com/leifermendez/bot-whatsapp/commit/9cb98b5e73fca3c3f5e70a8497badc31e494b943))
|
||||
* **cli:** :fire: create script - templates ([2999e0e](https://github.com/leifermendez/bot-whatsapp/commit/2999e0e753f31a8b9e6d7c117e78cdb5656e203a))
|
||||
* **cli:** :fire: create script - templates ([af716b7](https://github.com/leifermendez/bot-whatsapp/commit/af716b75372899877a81b528b58278376166d0ad))
|
||||
* **cli:** :fire: create script - templates ([c6999c8](https://github.com/leifermendez/bot-whatsapp/commit/c6999c84931083a87b5717db58003be68244707e))
|
||||
* **cli:** :fire: create script - templates ([d4b49a9](https://github.com/leifermendez/bot-whatsapp/commit/d4b49a9bd7085070f0c5964d2903f10b71bde0b3))
|
||||
* **cli:** :fire: create script - templates ([eebc3c9](https://github.com/leifermendez/bot-whatsapp/commit/eebc3c980638d88f11a0d93b8344f3ff345c7ee5))
|
||||
* **cli:** :zap: clean eslinter ([bfb69d9](https://github.com/leifermendez/bot-whatsapp/commit/bfb69d9a9574a757ae02748b6c5f5afa3eac68e6))
|
||||
* **cli:** :zap: clean eslinter ([15f6972](https://github.com/leifermendez/bot-whatsapp/commit/15f697225775a0f0e0a440cd980f7fb8f51a1056))
|
||||
* **cli:** :zap: create-starter ([d3b8310](https://github.com/leifermendez/bot-whatsapp/commit/d3b8310180d2ad813733b1d18f2c32d7d947740a))
|
||||
* **cli:** :zap: update cli copy ([7797c2b](https://github.com/leifermendez/bot-whatsapp/commit/7797c2b46133697e2a591adab2b67e66b34a1cfe))
|
||||
* **fix:** fix ([6483545](https://github.com/leifermendez/bot-whatsapp/commit/648354500b123f20044f5ac2e8a26b15f16d1b8d))
|
||||
* **fix:** fix ([28c0480](https://github.com/leifermendez/bot-whatsapp/commit/28c0480b8bfa6b24394095f57c36ef89c9aeb566))
|
||||
* **linter:** update linter and commitlint ([70a94ab](https://github.com/leifermendez/bot-whatsapp/commit/70a94ab2c6f8e4122780c77bc3a621944883e621))
|
||||
* pre-copy fix ([08e2552](https://github.com/leifermendez/bot-whatsapp/commit/08e2552907c48cfeaac843457a18bf2032e6f8aa))
|
||||
* pre-copy fix ([6617107](https://github.com/leifermendez/bot-whatsapp/commit/6617107ab824215c449e26eae6c2bb327ecfc092))
|
||||
* **starter:** pre-copy fix ([929e74c](https://github.com/leifermendez/bot-whatsapp/commit/929e74c84b667ec13cb5490b3b951cb8df15ebd1))
|
||||
|
||||
|
||||
* (💍) Is justa test! ([37d04e9](https://github.com/leifermendez/bot-whatsapp/commit/37d04e9e89d3f01fdc367654ba60fb11ab2614c4))
|
||||
|
||||
## 0.2.0-alpha.0 (2022-12-01)
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
|
||||
__Requerimientos:__
|
||||
- Node v16 o superior __[descargar node](https://nodejs.org/es/download/)__
|
||||
- __[Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable)__ como gestor de paquetes. En el link conseguiras las intrucciones para instalar yarn.
|
||||
- __[VSCode](https://code.visualstudio.com/download)__ (recomendado): Editor de codigo con plugins
|
||||
- __[Conventional Commits](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits&ssr=false#overview)__ (plugin-vscode) este plugin te ayudara a crear commit semantico.
|
||||
- Se usara la rama __dev__ *(https://github.com/leifermendez/bot-whatsapp/tree/dev)* como rama principal hasta que se haga oficialmente el lanzamiento de la V2
|
||||
- __[Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable)__ como gestor de paquetes. En el link conseguirás las intrucciones para instalar yarn.
|
||||
- __[VSCode](https://code.visualstudio.com/download)__ (recomendado): Editor de código con plugins.
|
||||
- __[Conventional Commits](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits&ssr=false#overview)__ (plugin-vscode) este plugin te ayudará a crear commit semántico.
|
||||
- Se usará la rama __dev__ *(https://github.com/leifermendez/bot-whatsapp/tree/dev)* como rama principal hasta que se haga oficialmente el lanzamiento de la V2.
|
||||
|
||||
### 🚀 Iniciando
|
||||
|
||||
@@ -22,14 +22,14 @@ yarn install
|
||||
```
|
||||
|
||||
__Compilar (build)__
|
||||
Para compilar la aplicación es necesario ejecutar, eso te genera dentro de packages del monorepo un directorio `lib`
|
||||
Para compilar la aplicación es necesario ejecutar este comando, el cual genera un directorio `lib` dentro de los paquetes del monorepo.
|
||||
|
||||
```
|
||||
yarn build
|
||||
```
|
||||
|
||||
__Example-app__
|
||||
Se ejecuta el CLI (Command Line Interface) para ayudarte a crear un app-bot de ejemplo
|
||||
Se ejecuta el CLI (Command Line Interface) para ayudarte a crear un app-bot de ejemplo.
|
||||
```
|
||||
yarn run cli
|
||||
```
|
||||
@@ -42,15 +42,16 @@ npm run pre-copy
|
||||
npm start
|
||||
```
|
||||
|
||||
__Commit y Push__
|
||||
El proyecto tiene implementado __[husky](https://typicode.github.io/husky/#/)__ es una herramienta que dispara unas acciones al momento de hacer commit y hacer push
|
||||
### __Commit y Push__
|
||||
|
||||
__commit:__ Los commit son semanticos esto quiere decir que deben cumplir un standar al momento de escribirlos ejemplo ` feat(adapter): new adapter myqsl ` puede ver más info sobre esto __[aquí](https://github.com/conventional-changelog/commitlint/#what-is-commitlint)__
|
||||
El proyecto tiene implementado __[husky](https://typicode.github.io/husky/#/)__, es una herramienta que dispara unas acciones al momento de hacer commit y hacer push.
|
||||
|
||||
__push:__ Cada push ejecutar `yarn run test` el cual ejecuta los test internos que tienen que cumplir con __95% de cobertura__.
|
||||
__commit:__ Los commit son semánticos, esto quiere decir que deben cumplir un standar al momento de escribirlos ejemplo: ` feat(adapter): new adapter myqsl ` puede ver más info sobre esto __[aquí](https://github.com/conventional-changelog/commitlint/#what-is-commitlint)__
|
||||
|
||||
__push:__ Cada push ejecutar `yarn run test` el cual realiza los test internos que tienen que cumplir con __95% de cobertura__.
|
||||
|
||||
|
||||
> Documento en constaten actualización....
|
||||
> Documento en constante actualización....
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
|
||||
2
GLOSSARY.md
Normal file
2
GLOSSARY.md
Normal file
@@ -0,0 +1,2 @@
|
||||
CTX: Es el objeto que representa un mensaje, con opciones, id, ref
|
||||
messageInComming: Objeto entrante del provider {body, from,...}
|
||||
85
README.md
85
README.md
@@ -3,18 +3,91 @@
|
||||
--------
|
||||
🦊 Documentación: [https://bot-whatsapp.pages.dev/](https://bot-whatsapp.pages.dev/)
|
||||
Video como hacer PR: https://youtu.be/Lxt8Acob6aU
|
||||
|
||||
- [ ] Evitar dependencias
|
||||
|
||||
🚀 __Roadmap:__ [https://github.com/users/leifermendez/projects/4/views/1](https://github.com/users/leifermendez/projects/4/views/1)
|
||||
|
||||
|
||||
**Comunidad**
|
||||
<!-- readme: collaborators,contributors -start -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/leifermendez">
|
||||
<img src="https://avatars.githubusercontent.com/u/15802366?v=4" width="50;" alt="leifermendez"/>
|
||||
<br />
|
||||
<sub><b>Leifer Mendez</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/aurik3">
|
||||
<img src="https://avatars.githubusercontent.com/u/37228512?v=4" width="50;" alt="aurik3"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/vicente1992">
|
||||
<img src="https://avatars.githubusercontent.com/u/57806030?v=4" width="50;" alt="vicente1992"/>
|
||||
<br />
|
||||
<sub><b>Manuel Vicente Ortiz</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/leifermendezfroged">
|
||||
<img src="https://avatars.githubusercontent.com/u/97020486?v=4" width="50;" alt="leifermendezfroged"/>
|
||||
<br />
|
||||
<sub><b>Leifer Mendez</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Gonzalito87">
|
||||
<img src="https://avatars.githubusercontent.com/u/100331586?v=4" width="50;" alt="Gonzalito87"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/jzvi12">
|
||||
<img src="https://avatars.githubusercontent.com/u/10729787?v=4" width="50;" alt="jzvi12"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/tonyvazgar">
|
||||
<img src="https://avatars.githubusercontent.com/u/21047090?v=4" width="50;" alt="tonyvazgar"/>
|
||||
<br />
|
||||
<sub><b>Luis Antonio Vázquez García</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/ulisesvina">
|
||||
<img src="https://avatars.githubusercontent.com/u/20508563?v=4" width="50;" alt="ulisesvina"/>
|
||||
<br />
|
||||
<sub><b>Ulises Viña</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rrruuuyyy">
|
||||
<img src="https://avatars.githubusercontent.com/u/33061671?v=4" width="50;" alt="rrruuuyyy"/>
|
||||
<br />
|
||||
<sub><b>Rodrigo Mendoza Cabrera</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/yond1994">
|
||||
<img src="https://avatars.githubusercontent.com/u/47557263?v=4" width="50;" alt="yond1994"/>
|
||||
<br />
|
||||
<sub><b>Yonathan Suarez</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
</table>
|
||||
<!-- readme: collaborators,contributors -end -->
|
||||
|
||||
> Forma parte de este proyecto.
|
||||
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
- [Twitter](https://twitter.com/leifermendez)
|
||||
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
|
||||
|
||||
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
33
TODO.md
33
TODO.md
@@ -2,31 +2,50 @@
|
||||
- [X] __(doc)__ Video de como colaborar PR
|
||||
- [ ] __(doc)__ Video implementación de test y cobertura
|
||||
- [ ] __(doc)__ Video explicacion de github action
|
||||
- [ ] Crear packages list externas
|
||||
|
||||
### @bot-whatsapp/bot
|
||||
- [ ] agregar export package
|
||||
- [X] agregar export package
|
||||
- [X] Posibilidad de en el capture meter todo un nuevo CTX de FLOW .addAnswer('Marca la opcion',{capture:true, join:CTX})
|
||||
- [X] .addKeyword('1') no funciona con 1 caracter
|
||||
- [X] sensitivy viene activado por defecto
|
||||
- [ ] fallback respuesta en hijo: Se puede colocar en option el ref de la answer fallback
|
||||
- [X] fallback respuesta en hijo: Se puede colocar en option el ref de la answer fallback
|
||||
- [X] Cuando Envian Sticket devuelve mensaje raro
|
||||
- [x] addAnswer agregar delay
|
||||
- [ ] colocar mensaje esperando conectando whatsapp (provider)
|
||||
- [ ] Cuando Envian Sticket devuelve mensaje raro
|
||||
- [ ] createDatabase validar implementacion de funciones
|
||||
- [ ] limitar caracteres de mensajes 4000
|
||||
- [X] cuando envias numeros (5 o 1) se dispara el flujo
|
||||
|
||||
### @bot-whatsapp/database
|
||||
- [X] agregar export package
|
||||
- [X] __(doc):__ Video para explicar como implementar nuevos database
|
||||
- [X] Mongo adapter
|
||||
- [ ] MySQL adapter
|
||||
- [X] MySQL adapter
|
||||
- [ ] JsonFile adapter
|
||||
|
||||
### @bot-whatsapp/provider
|
||||
- [X] agregar export package
|
||||
- [ ] __(doc):__ Video para explicar como implementar nuevos providers
|
||||
- [ ] WhatsappWeb provider enviar imagenes
|
||||
- [ ] WhatsappWeb provider enviar audio
|
||||
- [X] WhatsappWeb provider enviar imagenes
|
||||
- [X] WhatsappWeb provider enviar audio
|
||||
- [X] WhatsappWeb botones (Tiene truco) github:leifermendez/whatsapp-web.js
|
||||
- [ ] Twilio adapter
|
||||
- [ ] Meta adapter
|
||||
|
||||
### @bot-whatsapp/cli
|
||||
- [ ] Hacer comando para crear `example-app`
|
||||
- [X] Hacer comando para crear `example-app`
|
||||
|
||||
|
||||
### @bot-whatsapp/create-bot
|
||||
- [ ]
|
||||
|
||||
### Starters
|
||||
- [X] Base
|
||||
- [X] Basico
|
||||
- [ ] Enviando Imagen
|
||||
- [ ] Enviando Botones
|
||||
- [ ] Mezclando flujos hijos
|
||||
|
||||
### Extra
|
||||
- [X] Crear CI mantener fork update https://stackoverflow.com/questions/23793062/can-forks-be-synced-automatically-in-github
|
||||
|
||||
12
package.json
12
package.json
@@ -1,35 +1,38 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/root",
|
||||
"version": "0.2.0-alpha.0",
|
||||
"version": "0.1.2",
|
||||
"description": "Bot de wahtsapp open source para MVP o pequeños negocios",
|
||||
"main": "app.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"commit": "git-cz",
|
||||
"cli:rollup": "rollup --config ./packages/cli/rollup-cli.config.js ",
|
||||
"create-bot:rollup": "rollup --config ./packages/create-bot-whatsapp/rollup-create.config.js ",
|
||||
"bot:rollup": "rollup --config ./packages/bot/rollup-bot.config.js",
|
||||
"provider:rollup": "rollup --config ./packages/provider/rollup-provider.config.js ",
|
||||
"database:rollup": "rollup --config ./packages/database/rollup-database.config.js",
|
||||
"create-bot-whatsapp:rollup": "rollup --config ./packages/create-bot-whatsapp/rollup-create.config.js",
|
||||
"format:check": "prettier --check ./packages",
|
||||
"format:write": "prettier --write ./packages",
|
||||
"fmt.staged": "pretty-quick --staged",
|
||||
"lint:check": "eslint ./packages",
|
||||
"lint:fix": "eslint --fix ./packages",
|
||||
"build": "yarn run cli:rollup && yarn run bot:rollup && yarn run provider:rollup && yarn run database:rollup",
|
||||
"link.dist": "cd packages/bot && npm link && cd ../provider && npm link && cd ../cli && npm link && cd ../database && npm link && cd ../provider && npm link",
|
||||
"build": "yarn run cli:rollup && yarn run bot:rollup && yarn run provider:rollup && yarn run database:rollup && yarn run create-bot-whatsapp:rollup",
|
||||
"copy.lib": "node ./scripts/move.js",
|
||||
"test.unit": "node ./node_modules/uvu/bin.js packages test",
|
||||
"test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit",
|
||||
"test": "npm run test.coverage",
|
||||
"cli": "node ./packages/cli/bin/cli.js",
|
||||
"create": "node ./packages/create-bot-whatsapp/bin/create.js",
|
||||
"dev:debug": "node --inspect ./example-app/app.js",
|
||||
"dev": "node ./example-app/app.js",
|
||||
"prepare": "npx husky install",
|
||||
"preinstall": "npx only-allow yarn",
|
||||
"postinstall": "npx prettier --write .",
|
||||
"release": "standard-version"
|
||||
"release": "standard-version -- --prerelease"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/create-bot-whatsapp",
|
||||
"packages/bot",
|
||||
"packages/cli",
|
||||
"packages/database",
|
||||
@@ -78,6 +81,7 @@
|
||||
"rollup": "^3.2.3",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-copy": "^3.4.0",
|
||||
"semver": "^7.3.8",
|
||||
"standard-version": "^9.5.0",
|
||||
"uvu": "^0.5.6"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
const { toCtx } = require('../io/methods')
|
||||
const { printer } = require('../utils/interactive')
|
||||
const { delay } = require('../utils/delay')
|
||||
const Queue = require('../utils/queue')
|
||||
const { Console } = require('console')
|
||||
const { createWriteStream } = require('fs')
|
||||
|
||||
const logger = new Console({
|
||||
stdout: createWriteStream(`${process.cwd()}/core.class.log`),
|
||||
})
|
||||
/**
|
||||
* [ ] Escuchar eventos del provider asegurarte que los provider emitan eventos
|
||||
* [ ] Guardar historial en db
|
||||
@@ -21,15 +28,22 @@ class CoreClass {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manejador de eventos
|
||||
*/
|
||||
listenerBusEvents = () => [
|
||||
{
|
||||
event: 'preinit',
|
||||
func: () => printer('Iniciando proveedor, espere...'),
|
||||
},
|
||||
{
|
||||
event: 'require_action',
|
||||
func: ({ instructions, title = '⚡⚡ ACCION REQUERIDA ⚡⚡' }) =>
|
||||
func: ({ instructions, title = '⚡⚡ ACCIÓN REQUERIDA ⚡⚡' }) =>
|
||||
printer(instructions, title),
|
||||
},
|
||||
{
|
||||
event: 'ready',
|
||||
func: () => printer('Provider conectado y listo'),
|
||||
func: () => printer('Proveedor conectado y listo'),
|
||||
},
|
||||
{
|
||||
event: 'auth_failure',
|
||||
@@ -44,16 +58,19 @@ class CoreClass {
|
||||
]
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {*} ctxMessage
|
||||
*
|
||||
* @param {*} messageInComming
|
||||
* @returns
|
||||
*/
|
||||
handleMsg = async (messageInComming) => {
|
||||
logger.log(`[handleMsg]: `, messageInComming)
|
||||
const { body, from } = messageInComming
|
||||
let msgToSend = []
|
||||
let fallBackFlag = false
|
||||
|
||||
if (!body.length) return
|
||||
|
||||
//Consultamos mensaje previo en DB
|
||||
const prevMsg = await this.databaseClass.getPrevByNumber(from)
|
||||
//Consultamos for refSerializada en el flow actual
|
||||
const refToContinue = this.flowClass.findBySerialize(
|
||||
prevMsg?.refSerialize
|
||||
)
|
||||
@@ -67,14 +84,24 @@ class CoreClass {
|
||||
this.databaseClass.save(ctxByNumber)
|
||||
}
|
||||
|
||||
//Si se tiene un callback se ejecuta
|
||||
if (refToContinue && prevMsg?.options?.callback) {
|
||||
const indexFlow = this.flowClass.findIndexByRef(refToContinue?.ref)
|
||||
this.flowClass.allCallbacks[indexFlow].callback(messageInComming)
|
||||
// 📄 [options: fallback]: esta funcion se encarga de repetir el ultimo mensaje
|
||||
const fallBack = () => {
|
||||
fallBackFlag = true
|
||||
msgToSend = this.flowClass.find(refToContinue?.keyword, true) || []
|
||||
this.sendFlow(msgToSend, from)
|
||||
return refToContinue
|
||||
}
|
||||
|
||||
//Si se tiene anidaciones de flows, si tienes anidados obligatoriamente capture:true
|
||||
if (prevMsg?.options?.nested?.length) {
|
||||
// 📄 [options: callback]: Si se tiene un callback se ejecuta
|
||||
if (!fallBackFlag && refToContinue && prevMsg?.options?.callback) {
|
||||
const indexFlow = this.flowClass.findIndexByRef(refToContinue?.ref)
|
||||
this.flowClass.allCallbacks[indexFlow].callback(messageInComming, {
|
||||
fallBack,
|
||||
})
|
||||
}
|
||||
|
||||
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
|
||||
if (!fallBackFlag && prevMsg?.options?.nested?.length) {
|
||||
const nestedRef = prevMsg.options.nested
|
||||
const flowStandalone = nestedRef.map((f) => ({
|
||||
...nestedRef.find((r) => r.refSerialize === f.refSerialize),
|
||||
@@ -85,28 +112,44 @@ class CoreClass {
|
||||
return
|
||||
}
|
||||
|
||||
//Consultamos si se espera respuesta por parte de cliente "Ejemplo: Dime tu nombre"
|
||||
if (!prevMsg?.options?.nested?.length && prevMsg?.options?.capture) {
|
||||
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
|
||||
} else {
|
||||
msgToSend = this.flowClass.find(body) || []
|
||||
// 📄🤘(tiene return) [options: capture (boolean)]: Si se tiene option boolean
|
||||
if (!fallBackFlag && !prevMsg?.options?.nested?.length) {
|
||||
const typeCapture = typeof prevMsg?.options?.capture
|
||||
const valueCapture = prevMsg?.options?.capture
|
||||
|
||||
if (['string', 'boolean'].includes(typeCapture) && valueCapture) {
|
||||
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
|
||||
this.sendFlow(msgToSend, from)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
msgToSend = this.flowClass.find(body) || []
|
||||
this.sendFlow(msgToSend, from)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar mensaje con contexto atraves del proveedor de whatsapp
|
||||
* @param {*} numberOrId
|
||||
* @param {*} ctxMessage ver más en GLOSSARY.md
|
||||
* @returns
|
||||
*/
|
||||
sendProviderAndSave = (numberOrId, ctxMessage) => {
|
||||
const { answer } = ctxMessage
|
||||
return Promise.all([
|
||||
this.providerClass.sendMessage(numberOrId, answer),
|
||||
this.providerClass.sendMessage(numberOrId, answer, ctxMessage),
|
||||
this.databaseClass.save({ ...ctxMessage, from: numberOrId }),
|
||||
])
|
||||
}
|
||||
|
||||
sendFlow = (messageToSend, numberOrId) => {
|
||||
sendFlow = async (messageToSend, numberOrId) => {
|
||||
const queue = []
|
||||
for (const ctxMessage of messageToSend) {
|
||||
queue.push(this.sendProviderAndSave(numberOrId, ctxMessage))
|
||||
const delayMs = ctxMessage?.options?.delay || 0
|
||||
if (delayMs) await delay(delayMs)
|
||||
Queue.enqueue(() =>
|
||||
this.sendProviderAndSave(numberOrId, ctxMessage)
|
||||
)
|
||||
}
|
||||
return Promise.all(queue)
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ const createFlow = (args) => {
|
||||
|
||||
/**
|
||||
* Crear instancia de clase Provider
|
||||
* Depdendiendo del Provider puedes pasar argumentos
|
||||
* Ver Documentacion
|
||||
* @param {*} args
|
||||
* @returns
|
||||
*/
|
||||
const createProvider = (providerClass = class {}) => {
|
||||
const providerInstance = new providerClass()
|
||||
const createProvider = (providerClass = class {}, args = null) => {
|
||||
const providerInstance = new providerClass(args)
|
||||
if (!providerClass.prototype instanceof ProviderClass)
|
||||
throw new Error('El provider no implementa ProviderClass')
|
||||
return providerInstance
|
||||
|
||||
@@ -21,29 +21,25 @@ class FlowClass {
|
||||
}
|
||||
|
||||
find = (keyOrWord, symbol = false, overFlow = null) => {
|
||||
keyOrWord = `${keyOrWord}`
|
||||
let capture = false
|
||||
let messages = []
|
||||
let refSymbol = null
|
||||
overFlow = overFlow ?? this.flowSerialize
|
||||
|
||||
const mapSensitiveString = (str, flag = false) => {
|
||||
if (!flag && Array.isArray(str)) {
|
||||
return str.map((c) => c.toLowerCase())
|
||||
/** Retornar expresion regular para buscar coincidencia */
|
||||
const mapSensitive = (str, flag = false) => {
|
||||
const regexSensitive = flag ? 'g' : 'i'
|
||||
if (Array.isArray(str)) {
|
||||
return new RegExp(str.join('|'), regexSensitive)
|
||||
}
|
||||
|
||||
if (!flag && typeof str === 'string') {
|
||||
return str.toLowerCase()
|
||||
}
|
||||
|
||||
return str
|
||||
return new RegExp(str, regexSensitive)
|
||||
}
|
||||
|
||||
const findIn = (keyOrWord, symbol = false, flow = overFlow) => {
|
||||
const sensitive = refSymbol?.options?.sensitive || false
|
||||
capture = refSymbol?.options?.capture || false
|
||||
|
||||
keyOrWord = mapSensitiveString(keyOrWord, sensitive)
|
||||
|
||||
if (capture) return messages
|
||||
|
||||
if (symbol) {
|
||||
@@ -51,9 +47,9 @@ class FlowClass {
|
||||
if (refSymbol?.answer) messages.push(refSymbol)
|
||||
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
||||
} else {
|
||||
refSymbol = flow.find((c) =>
|
||||
mapSensitiveString(c.keyword, sensitive).includes(keyOrWord)
|
||||
)
|
||||
refSymbol = flow.find((c) => {
|
||||
return mapSensitive(c.keyword, sensitive).test(keyOrWord)
|
||||
})
|
||||
if (refSymbol?.ref) findIn(refSymbol.ref, true)
|
||||
return messages
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
const { generateRef } = require('../../utils/hash')
|
||||
const { toJson } = require('./toJson')
|
||||
const { toSerialize } = require('./toSerialize')
|
||||
/**
|
||||
*
|
||||
* @param answer string
|
||||
* @param options {media:string, buttons:[], capture:true default false}
|
||||
* @param options {media:string, buttons:[{"body":"😎 Cursos"}], delay:ms, capture:true default false}
|
||||
* @returns
|
||||
*/
|
||||
const addAnswer =
|
||||
@@ -25,6 +24,7 @@ const addAnswer =
|
||||
: false,
|
||||
child:
|
||||
typeof options?.child === 'string' ? `${options?.child}` : null,
|
||||
delay: typeof options?.delay === 'number' ? options?.delay : 0,
|
||||
})
|
||||
|
||||
const getNested = () => ({
|
||||
@@ -79,6 +79,7 @@ const addAnswer =
|
||||
}
|
||||
}
|
||||
|
||||
/// Retornar contexto no colocar nada más abajo de esto
|
||||
const ctx = ctxAnswer()
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/bot",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.21-alpha.0",
|
||||
"description": "",
|
||||
"main": "./lib/bundle.bot.cjs",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"bot:rollup": "node ../../node_modules/.bin/rollup index.js --config ./rollup-cli.config.js",
|
||||
"format:check": "prettier --check .",
|
||||
|
||||
4
packages/bot/utils/delay.js
Normal file
4
packages/bot/utils/delay.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const delay = (miliseconds) =>
|
||||
new Promise((res) => setTimeout(res, miliseconds))
|
||||
|
||||
module.exports = { delay }
|
||||
46
packages/bot/utils/queue.js
Normal file
46
packages/bot/utils/queue.js
Normal file
@@ -0,0 +1,46 @@
|
||||
class Queue {
|
||||
static queue = []
|
||||
static pendingPromise = false
|
||||
|
||||
static enqueue(promise) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.queue.push({
|
||||
promise,
|
||||
resolve,
|
||||
reject,
|
||||
})
|
||||
this.dequeue()
|
||||
})
|
||||
}
|
||||
|
||||
static dequeue() {
|
||||
if (this.workingOnPromise) {
|
||||
return false
|
||||
}
|
||||
const item = this.queue.shift()
|
||||
if (!item) {
|
||||
return false
|
||||
}
|
||||
try {
|
||||
this.workingOnPromise = true
|
||||
item.promise()
|
||||
.then((value) => {
|
||||
this.workingOnPromise = false
|
||||
item.resolve(value)
|
||||
this.dequeue()
|
||||
})
|
||||
.catch((err) => {
|
||||
this.workingOnPromise = false
|
||||
item.reject(err)
|
||||
this.dequeue()
|
||||
})
|
||||
} catch (err) {
|
||||
this.workingOnPromise = false
|
||||
item.reject(err)
|
||||
this.dequeue()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Queue
|
||||
@@ -12,20 +12,20 @@ const checkNodeVersion = () => {
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(green(`Node.js combatible ${version}`))
|
||||
console.log(green(`Node.js compatible ${version}`))
|
||||
console.log(``)
|
||||
}
|
||||
|
||||
const checkOs = () => {
|
||||
console.log(bgCyan('🙂 Revisando tu Sistema Operativo'))
|
||||
console.log(bgCyan('🙂 Revisando tu sistema operativo'))
|
||||
const os = process.platform
|
||||
if (!os.includes('win32')) {
|
||||
const messages = [
|
||||
`El sistema operativo actual (${os}) posiblemente requiera`,
|
||||
`una confiuración adicional referente al puppeter`,
|
||||
`una configuración adicional referente al puppeteer`,
|
||||
``,
|
||||
`Recuerda pasar por el WIKI`,
|
||||
`🔗 https://github.com/leifermendez/bot-whatsapp/wiki/Instalaci%C3%B3n`,
|
||||
`🔗 https://github.com/leifermendez/bot-whatsapp/wiki/Instalación`,
|
||||
``,
|
||||
]
|
||||
|
||||
|
||||
@@ -12,9 +12,13 @@ const copyFiles = async (from, to) => {
|
||||
}
|
||||
}
|
||||
|
||||
const copyBaseApp = async () => {
|
||||
const BASEP_APP_PATH_FROM = `${process.cwd()}/starters/apps/base`
|
||||
const BASEP_APP_PATH_TO = `${process.cwd()}/example-app-base`
|
||||
/**
|
||||
* Copiar directorio con archivos
|
||||
* @param {*} templateName
|
||||
*/
|
||||
const copyBaseApp = async (fromDir = process.cwd(), toDir = process.cwd()) => {
|
||||
const BASEP_APP_PATH_FROM = `${fromDir}`
|
||||
const BASEP_APP_PATH_TO = `${toDir}`
|
||||
await copyFiles(BASEP_APP_PATH_FROM, BASEP_APP_PATH_TO)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const getPkgManage = async () => {
|
||||
}
|
||||
|
||||
const installDeps = (pkgManager, packageList) => {
|
||||
const errorMessage = `Ocurrio un error instalando ${packageList}`
|
||||
const errorMessage = `Ocurrió un error instalando ${packageList}`
|
||||
let childProcess = []
|
||||
|
||||
const installSingle = (pkgInstall) => () => {
|
||||
|
||||
@@ -1,54 +1,59 @@
|
||||
const prompts = require('prompts')
|
||||
const { yellow, red } = require('kleur')
|
||||
const { installAll } = require('../install')
|
||||
const { cleanSession } = require('../clean')
|
||||
const { yellow, red, cyan, bgMagenta } = require('kleur')
|
||||
const { copyBaseApp } = require('../create-app')
|
||||
const { join } = require('path')
|
||||
const { existsSync } = require('fs')
|
||||
const { checkNodeVersion, checkOs } = require('../check')
|
||||
const { jsonConfig } = require('../configuration')
|
||||
|
||||
const bannerDone = () => {
|
||||
console.log(``)
|
||||
console.log(
|
||||
cyan(
|
||||
[
|
||||
`[Agradecimientos]: Este es un proyecto OpenSource, si tienes intenciones de colaborar puedes hacerlo:`,
|
||||
`[😉] Comprando un cafe https://www.buymeacoffee.com/leifermendez`,
|
||||
`[⭐] Dar estrella https://github.com/leifermendez/bot-whatsapp`,
|
||||
`[🚀] Realizando mejoras en el codigo`,
|
||||
].join('\n')
|
||||
)
|
||||
)
|
||||
console.log(``)
|
||||
}
|
||||
|
||||
const startInteractive = async () => {
|
||||
const questions = [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'exampeOpt',
|
||||
message:
|
||||
'Quieres crear una app de ejemplo "example-app-example"? (Y/n)',
|
||||
},
|
||||
// {
|
||||
// type: 'text',
|
||||
// name: 'dependencies',
|
||||
// message:
|
||||
// 'Quieres actualizar las librerias "whatsapp-web.js"? (Y/n)',
|
||||
// },
|
||||
{
|
||||
type: 'text',
|
||||
name: 'cleanTmp',
|
||||
message: 'Quieres limpiar la session del bot? (Y/n)',
|
||||
name: 'outDir',
|
||||
message: 'Quieres crear un bot? (Y/n)',
|
||||
},
|
||||
{
|
||||
type: 'multiselect',
|
||||
name: 'providerWs',
|
||||
message: 'Proveedor de Whatsapp',
|
||||
message: '¿Cuál proveedor de whatsapp quieres utilizar?',
|
||||
choices: [
|
||||
{ title: 'whatsapp-web.js', value: 'whatsapp-web.js' },
|
||||
{ title: 'whatsapp-web.js (gratis)', value: 'wweb' },
|
||||
{ title: 'Twilio', value: 'twilio' },
|
||||
{ title: 'Venom (gratis)', value: 'venom' },
|
||||
{ title: 'Baileys (gratis)', value: 'bailey' },
|
||||
{ title: 'API Oficial (Meta)', value: 'meta', disabled: true },
|
||||
{ title: 'Twilio', value: 'twilio', disabled: true },
|
||||
],
|
||||
max: 1,
|
||||
hint: 'Espacio para selecionar',
|
||||
hint: 'Espacio para seleccionar',
|
||||
instructions: '↑/↓',
|
||||
},
|
||||
{
|
||||
type: 'multiselect',
|
||||
name: 'providerDb',
|
||||
message: 'Cual base de datos quieres usar',
|
||||
message: '¿Cuál base de datos quieres utilizar?',
|
||||
choices: [
|
||||
{ title: 'JSONFile', value: 'json' },
|
||||
{ title: 'MySQL', value: 'mysql', disabled: true },
|
||||
{ title: 'Mongo', value: 'mongo', disabled: true },
|
||||
{ title: 'Memory', value: 'memory' },
|
||||
{ title: 'Mongo', value: 'mongo' },
|
||||
{ title: 'MySQL', value: 'mysql' },
|
||||
{ title: 'Json', value: 'json', disabled: true },
|
||||
],
|
||||
max: 1,
|
||||
hint: 'Espacio para selecionar',
|
||||
hint: 'Espacio para seleccionar',
|
||||
instructions: '↑/↓',
|
||||
},
|
||||
]
|
||||
@@ -57,90 +62,78 @@ const startInteractive = async () => {
|
||||
checkNodeVersion()
|
||||
checkOs()
|
||||
const onCancel = () => {
|
||||
console.log('Proceso cancelado!')
|
||||
console.log('¡Proceso cancelado!')
|
||||
return true
|
||||
}
|
||||
const response = await prompts(questions, { onCancel })
|
||||
const {
|
||||
dependencies = '',
|
||||
cleanTmp = '',
|
||||
exampeOpt = '',
|
||||
providerDb = [],
|
||||
providerWs = [],
|
||||
} = response
|
||||
/**
|
||||
* Question
|
||||
* @returns
|
||||
*/
|
||||
const installOrUdpateDep = async () => {
|
||||
const answer = dependencies.toLowerCase() || 'n'
|
||||
const { outDir = '', providerDb = [], providerWs = [] } = response
|
||||
|
||||
const createApp = async (templateName = null) => {
|
||||
if (!templateName)
|
||||
throw new Error('TEMPLATE_NAME_INVALID: ', templateName)
|
||||
|
||||
const possiblesPath = [
|
||||
join(__dirname, '..', '..', 'starters', 'apps', templateName),
|
||||
join(__dirname, '..', 'starters', 'apps', templateName),
|
||||
join(__dirname, 'starters', 'apps', templateName),
|
||||
]
|
||||
|
||||
const answer = outDir.toLowerCase() || 'n'
|
||||
if (answer.includes('n')) return true
|
||||
|
||||
if (answer.includes('y')) {
|
||||
await installAll()
|
||||
return true
|
||||
const indexOfPath = possiblesPath.find((a) => existsSync(a))
|
||||
await copyBaseApp(indexOfPath, join(process.cwd(), templateName))
|
||||
console.log(``)
|
||||
console.log(bgMagenta(`⚡⚡⚡INSTRUCCIONES⚡⚡⚡`))
|
||||
console.log(yellow(`cd ${templateName}`))
|
||||
console.log(yellow(`npm install`))
|
||||
console.log(yellow(`npm start`))
|
||||
console.log(``)
|
||||
|
||||
return outDir
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Question
|
||||
* Selccionar Provider (meta, twilio, etc...)
|
||||
* @returns
|
||||
*/
|
||||
const cleanAllSession = async () => {
|
||||
const answer = cleanTmp.toLowerCase() || 'n'
|
||||
if (answer.includes('n')) return true
|
||||
|
||||
if (answer.includes('y')) {
|
||||
await cleanSession()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const createApp = async () => {
|
||||
const answer = exampeOpt.toLowerCase() || 'n'
|
||||
if (answer.includes('n')) return true
|
||||
|
||||
if (answer.includes('y')) {
|
||||
await copyBaseApp()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const vendorProvider = async () => {
|
||||
const [answer] = providerWs
|
||||
if (!providerWs.length) {
|
||||
console.log(
|
||||
red(
|
||||
`Debes de seleccionar una WS Provider. Tecla [Space] para seleccionar`
|
||||
`Debes seleccionar un proveedor de whatsapp. Tecla [Space] para seleccionar`
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(yellow(`'Deberia crer una carpeta en root/provider'`))
|
||||
return true
|
||||
return answer
|
||||
}
|
||||
|
||||
/**
|
||||
* Selecionar adaptador de base de datos
|
||||
* @returns
|
||||
*/
|
||||
const dbProvider = async () => {
|
||||
const answer = providerDb
|
||||
const [answer] = providerDb
|
||||
if (!providerDb.length) {
|
||||
console.log(
|
||||
red(
|
||||
`Debes de seleccionar una DB Provider. Tecla [Space] para seleccionar`
|
||||
`Debes seleccionar un proveedor de base de datos. Tecla [Space] para seleccionar`
|
||||
)
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
if (answer === 'json') {
|
||||
console.log('Deberia crer una carpeta en root/data')
|
||||
return 1
|
||||
}
|
||||
return answer
|
||||
}
|
||||
|
||||
await createApp()
|
||||
await installOrUdpateDep()
|
||||
await cleanAllSession()
|
||||
await vendorProvider()
|
||||
await dbProvider()
|
||||
await jsonConfig()
|
||||
const providerAdapter = await vendorProvider()
|
||||
const dbAdapter = await dbProvider()
|
||||
const NAME_DIR = ['base', providerAdapter, dbAdapter].join('-')
|
||||
await createApp(NAME_DIR)
|
||||
bannerDone()
|
||||
}
|
||||
|
||||
module.exports = { startInteractive }
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/cli",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-spawn": "^7.0.3",
|
||||
@@ -11,6 +10,7 @@
|
||||
"kleur": "^4.1.5"
|
||||
},
|
||||
"files": [
|
||||
"./starters/",
|
||||
"./lib/cli/bundle.cli.cjs"
|
||||
],
|
||||
"bin": {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const banner = require('../../config/banner.rollup.json')
|
||||
const commonjs = require('@rollup/plugin-commonjs')
|
||||
const copy = require('rollup-plugin-copy')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const { join } = require('path')
|
||||
|
||||
@@ -12,5 +13,11 @@ module.exports = {
|
||||
file: PATH,
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs(), nodeResolve()],
|
||||
plugins: [
|
||||
copy({
|
||||
targets: [{ src: 'starters/*', dest: join(__dirname, 'starters') }],
|
||||
}),
|
||||
commonjs(),
|
||||
nodeResolve(),
|
||||
],
|
||||
}
|
||||
|
||||
3
packages/create-bot-whatsapp/bin/create.js
Executable file
3
packages/create-bot-whatsapp/bin/create.js
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
const main = require('../lib/bundle.create-bot-whatsapp.cjs')
|
||||
main()
|
||||
10
packages/create-bot-whatsapp/index.js
Normal file
10
packages/create-bot-whatsapp/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const { startInteractive } = require('../cli')
|
||||
/**
|
||||
* Voy a llamar directo a CLI
|
||||
* Temporalmente luego mejoro esta
|
||||
* parte
|
||||
* @returns
|
||||
*/
|
||||
const main = () => startInteractive()
|
||||
|
||||
module.exports = main
|
||||
15
packages/create-bot-whatsapp/package.json
Normal file
15
packages/create-bot-whatsapp/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "create-bot-whatsapp",
|
||||
"version": "0.0.39-alpha.0",
|
||||
"description": "",
|
||||
"main": "./lib/bundle.create-bot-whatsapp.cjs",
|
||||
"files": [
|
||||
"./starters/",
|
||||
"./bin/create.js",
|
||||
"./lib/bundle.create-bot-whatsapp.cjs"
|
||||
],
|
||||
"bin": "./bin/create.js",
|
||||
"dependencies": {
|
||||
"@bot-whatsapp/cli": "*"
|
||||
}
|
||||
}
|
||||
23
packages/create-bot-whatsapp/rollup-create.config.js
Normal file
23
packages/create-bot-whatsapp/rollup-create.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const banner = require('../../config/banner.rollup.json')
|
||||
const commonjs = require('@rollup/plugin-commonjs')
|
||||
const copy = require('rollup-plugin-copy')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const { join } = require('path')
|
||||
|
||||
const PATH = join(__dirname, 'lib', 'bundle.create-bot-whatsapp.cjs')
|
||||
|
||||
module.exports = {
|
||||
input: join(__dirname, 'index.js'),
|
||||
output: {
|
||||
banner: banner['banner.output'].join(''),
|
||||
file: PATH,
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [
|
||||
copy({
|
||||
targets: [{ src: 'starters/*', dest: join(__dirname, 'starters') }],
|
||||
}),
|
||||
commonjs(),
|
||||
nodeResolve(),
|
||||
],
|
||||
}
|
||||
@@ -1,20 +1,24 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/database",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.20-alpha.0",
|
||||
"description": "Esto es el conector a mysql, pg, mongo",
|
||||
"main": "./lib/mock/index.cjs",
|
||||
"private": true,
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"files": [
|
||||
"./lib/"
|
||||
],
|
||||
"dependencies": {
|
||||
"dotenv": "^16.0.3",
|
||||
"mongodb": "^4.11.0",
|
||||
"mysql2": "^2.3.3"
|
||||
"mysql2": "^2.3.3",
|
||||
"stormdb": "^0.6.0"
|
||||
},
|
||||
"exports": {
|
||||
"./mock": "./lib/mock/index.cjs",
|
||||
"./mongo": "./lib/mongo/index.cjs",
|
||||
"./json-file": "./lib/json-file/index.cjs",
|
||||
"./mysql": "./lib/mysql/index.cjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,12 @@ module.exports = [
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
},
|
||||
{
|
||||
input: join(__dirname, 'src', 'json-file', 'index.js'),
|
||||
output: {
|
||||
banner: banner['banner.output'].join(''),
|
||||
file: join(__dirname, 'lib', 'json-file', 'index.cjs'),
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
},
|
||||
]
|
||||
|
||||
48
packages/database/src/json-file/index.js
Normal file
48
packages/database/src/json-file/index.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const path = require('path')
|
||||
const StormDB = require('stormdb')
|
||||
const engine = new StormDB.localFileEngine(
|
||||
path.join(process.cwd(), './db.stormdb')
|
||||
)
|
||||
|
||||
class JsonFileAdapter {
|
||||
db
|
||||
listHistory = []
|
||||
|
||||
constructor() {
|
||||
this.init().then()
|
||||
}
|
||||
|
||||
init() {
|
||||
return new Promise((resolve) => {
|
||||
this.db = new StormDB(engine)
|
||||
this.db.default({ history: [] })
|
||||
resolve(this.db)
|
||||
})
|
||||
}
|
||||
|
||||
getPrevByNumber = async (from) => {
|
||||
const response = await this.db.get('history')
|
||||
const { history } = response.state
|
||||
|
||||
if (!history.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
const result = history.filter((res) => res.from === from).pop()
|
||||
|
||||
return {
|
||||
...result,
|
||||
}
|
||||
}
|
||||
|
||||
save = async (ctx) => {
|
||||
await this.db
|
||||
.get('history')
|
||||
.push({ ...ctx })
|
||||
.save()
|
||||
console.log('Guardado en DB...', ctx)
|
||||
this.listHistory.push(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JsonFileAdapter
|
||||
@@ -1,28 +1,22 @@
|
||||
require('dotenv').config()
|
||||
const mysql = require('mysql2')
|
||||
|
||||
const DB_NAME = process.env.DB_NAME || 'db_bot'
|
||||
const DB_HOST = process.env.DB_HOST || 'localhost'
|
||||
const DB_USER = process.env.DB_USER || 'root'
|
||||
|
||||
class MyslAdapter {
|
||||
db
|
||||
listHistory = []
|
||||
credentials = { host: null, user: null, database: null }
|
||||
|
||||
constructor() {
|
||||
constructor(_credentials) {
|
||||
this.credentials = _credentials
|
||||
this.init().then()
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.db = mysql.createConnection({
|
||||
host: DB_HOST,
|
||||
user: DB_USER,
|
||||
database: DB_NAME,
|
||||
})
|
||||
this.db = mysql.createConnection(this.credentials)
|
||||
|
||||
await this.db.connect((error) => {
|
||||
await this.db.connect(async (error) => {
|
||||
if (!error) {
|
||||
console.log(`Solicitud de conexión a base de datos exitosa`)
|
||||
await this.checkTableExists()
|
||||
}
|
||||
|
||||
if (error) {
|
||||
@@ -71,6 +65,42 @@ class MyslAdapter {
|
||||
})
|
||||
this.listHistory.push(ctx)
|
||||
}
|
||||
|
||||
createTable = () =>
|
||||
new Promise((resolve) => {
|
||||
const tableName = 'history'
|
||||
|
||||
const sql = `CREATE TABLE ${tableName}
|
||||
(id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
ref varchar(255) NOT NULL,
|
||||
keyword varchar(255) NOT NULL,
|
||||
answer longtext NOT NULL,
|
||||
refSerialize varchar(255) NOT NULL,
|
||||
phone varchar(255) NOT NULL,
|
||||
options longtext NOT NULL
|
||||
)`
|
||||
|
||||
this.db.query(sql, (err) => {
|
||||
if (err) throw err
|
||||
console.log(`Tabla ${tableName} creada correctamente `)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
|
||||
checkTableExists = () =>
|
||||
new Promise((resolve) => {
|
||||
const sql = "SHOW TABLES LIKE 'history'"
|
||||
|
||||
this.db.query(sql, (err, rows) => {
|
||||
if (err) throw err
|
||||
|
||||
if (!rows.length) {
|
||||
this.createTable()
|
||||
}
|
||||
|
||||
resolve(!!rows.length)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = MyslAdapter
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adaptors/cloudflare-pages/vite';
|
||||
import { extendConfig } from '@builder.io/qwik-city/vite';
|
||||
import baseConfig from '../../vite.config';
|
||||
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adaptors/cloudflare-pages/vite'
|
||||
import { extendConfig } from '@builder.io/qwik-city/vite'
|
||||
import baseConfig from '../../vite.config'
|
||||
|
||||
export default extendConfig(baseConfig, () => {
|
||||
return {
|
||||
build: {
|
||||
ssr: true,
|
||||
rollupOptions: {
|
||||
input: ['src/entry.cloudflare-pages.tsx', '@qwik-city-plan'],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
cloudflarePagesAdaptor({
|
||||
staticGenerate: true,
|
||||
}),
|
||||
],
|
||||
};
|
||||
});
|
||||
return {
|
||||
build: {
|
||||
ssr: true,
|
||||
rollupOptions: {
|
||||
input: ['src/entry.cloudflare-pages.tsx', '@qwik-city-plan'],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
cloudflarePagesAdaptor({
|
||||
staticGenerate: true,
|
||||
}),
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
// Cloudflare Pages Functions
|
||||
// https://developers.cloudflare.com/pages/platform/functions/
|
||||
export { onRequest } from '../server/entry.cloudflare-pages';
|
||||
export { onRequest } from '../server/entry.cloudflare-pages'
|
||||
|
||||
@@ -1,41 +1,44 @@
|
||||
{
|
||||
"name": "bot-whatsapp-docs",
|
||||
"version": "0.0.1",
|
||||
"description": "Basic start point to build a docs site with Qwik",
|
||||
"engines": {
|
||||
"node": ">=15.0.0"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "qwik build",
|
||||
"build.client": "vite build",
|
||||
"build.preview": "vite build --ssr src/entry.preview.tsx",
|
||||
"build.server": "vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
||||
"build.types": "tsc --incremental --noEmit",
|
||||
"deploy": "wrangler pages dev ./dist",
|
||||
"dev": "vite --mode ssr",
|
||||
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
|
||||
"fmt": "prettier --write .",
|
||||
"fmt.check": "prettier --check .",
|
||||
"lint": "eslint \"src/**/*.ts*\"",
|
||||
"preview": "qwik build preview && vite preview --open",
|
||||
"start": "vite --open --mode ssr",
|
||||
"qwik": "qwik"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@builder.io/qwik": "0.14.1",
|
||||
"@builder.io/qwik-city": "0.0.127",
|
||||
"@types/eslint": "8.4.10",
|
||||
"@types/node": "latest",
|
||||
"@typescript-eslint/eslint-plugin": "5.43.0",
|
||||
"@typescript-eslint/parser": "5.43.0",
|
||||
"eslint": "8.28.0",
|
||||
"eslint-plugin-qwik": "0.14.1",
|
||||
"node-fetch": "3.3.0",
|
||||
"prettier": "2.7.1",
|
||||
"typescript": "4.9.3",
|
||||
"vite": "3.2.4",
|
||||
"vite-tsconfig-paths": "3.5.0",
|
||||
"wrangler": "latest"
|
||||
}
|
||||
"name": "bot-whatsapp-docs",
|
||||
"version": "0.0.1",
|
||||
"description": "Basic start point to build a docs site with Qwik",
|
||||
"engines": {
|
||||
"node": ">=15.0.0"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "qwik build",
|
||||
"build.client": "vite build",
|
||||
"build.preview": "vite build --ssr src/entry.preview.tsx",
|
||||
"build.server": "vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
||||
"build.types": "tsc --incremental --noEmit",
|
||||
"deploy": "wrangler pages dev ./dist",
|
||||
"dev": "vite --mode ssr",
|
||||
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
|
||||
"fmt": "prettier --write .",
|
||||
"fmt.check": "prettier --check .",
|
||||
"lint": "eslint \"src/**/*.ts*\"",
|
||||
"preview": "qwik build preview && vite preview --open",
|
||||
"start": "vite --open --mode ssr",
|
||||
"qwik": "qwik"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@builder.io/qwik": "0.14.1",
|
||||
"@builder.io/qwik-city": "0.0.127",
|
||||
"@types/eslint": "8.4.10",
|
||||
"@types/node": "latest",
|
||||
"@typescript-eslint/eslint-plugin": "5.43.0",
|
||||
"@typescript-eslint/parser": "5.43.0",
|
||||
"autoprefixer": "10.4.11",
|
||||
"eslint": "8.28.0",
|
||||
"eslint-plugin-qwik": "0.14.1",
|
||||
"node-fetch": "3.3.0",
|
||||
"postcss": "^8.4.16",
|
||||
"prettier": "2.7.1",
|
||||
"tailwindcss": "^3.1.8",
|
||||
"typescript": "4.9.3",
|
||||
"vite": "3.2.4",
|
||||
"vite-tsconfig-paths": "3.5.0",
|
||||
"wrangler": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
6
packages/docs/postcss.config.js
Normal file
6
packages/docs/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
|
||||
"name": "qwik-project-name",
|
||||
"short_name": "Welcome to Qwik",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#fff",
|
||||
"description": "A Qwik project app."
|
||||
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
|
||||
"name": "qwik-project-name",
|
||||
"short_name": "Welcome to Qwik",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#fff",
|
||||
"description": "A Qwik project app."
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
nav.breadcrumbs {
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
nav.breadcrumbs > span {
|
||||
display: inline-block;
|
||||
padding: 5px 0;
|
||||
font-size: 12px;
|
||||
display: inline-block;
|
||||
padding: 5px 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
nav.breadcrumbs > span a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
nav.breadcrumbs > span::after {
|
||||
content: '>';
|
||||
padding: 0 5px;
|
||||
opacity: 0.4;
|
||||
content: '>';
|
||||
padding: 0 5px;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
nav.breadcrumbs > span:last-child::after {
|
||||
display: none;
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -1,74 +1,77 @@
|
||||
import { component$, useStyles$ } from '@builder.io/qwik';
|
||||
import { useContent, useLocation, ContentMenu } from '@builder.io/qwik-city';
|
||||
import styles from './breadcrumbs.css?inline';
|
||||
import { component$, useStyles$ } from '@builder.io/qwik'
|
||||
import { useContent, useLocation, ContentMenu } from '@builder.io/qwik-city'
|
||||
import styles from './breadcrumbs.css?inline'
|
||||
|
||||
export const Breadcrumbs = component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
const { menu } = useContent();
|
||||
const loc = useLocation();
|
||||
const { menu } = useContent()
|
||||
const loc = useLocation()
|
||||
|
||||
const breadcrumbs = createBreadcrumbs(menu, loc.pathname);
|
||||
if (breadcrumbs.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<nav class="breadcrumbs">
|
||||
{breadcrumbs.map((b) => (
|
||||
<span>{b.href ? <a href={b.href}>{b.text}</a> : b.text}</span>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
});
|
||||
|
||||
export function createBreadcrumbs(menu: ContentMenu | undefined, pathname: string) {
|
||||
if (menu?.items) {
|
||||
for (const indexA of menu.items) {
|
||||
const breadcrumbA: ContentBreadcrumb = {
|
||||
text: indexA.text,
|
||||
};
|
||||
if (typeof indexA.href === 'string') {
|
||||
breadcrumbA.href = indexA.href;
|
||||
}
|
||||
if (indexA.href === pathname) {
|
||||
return [breadcrumbA];
|
||||
}
|
||||
|
||||
if (indexA.items) {
|
||||
for (const indexB of indexA.items) {
|
||||
const breadcrumbB: ContentBreadcrumb = {
|
||||
text: indexB.text,
|
||||
};
|
||||
if (typeof indexB.href === 'string') {
|
||||
breadcrumbB.href = indexB.href;
|
||||
}
|
||||
if (indexB.href === pathname) {
|
||||
return [breadcrumbA, breadcrumbB];
|
||||
}
|
||||
|
||||
if (indexB.items) {
|
||||
for (const indexC of indexB.items) {
|
||||
const breadcrumbC: ContentBreadcrumb = {
|
||||
text: indexC.text,
|
||||
};
|
||||
if (typeof indexC.href === 'string') {
|
||||
breadcrumbC.href = indexC.href;
|
||||
}
|
||||
if (indexC.href === pathname) {
|
||||
return [breadcrumbA, breadcrumbB, breadcrumbC];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const breadcrumbs = createBreadcrumbs(menu, loc.pathname)
|
||||
if (breadcrumbs.length === 0) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
return (
|
||||
<nav class="breadcrumbs">
|
||||
{breadcrumbs.map((b) => (
|
||||
<span>{b.href ? <a href={b.href}>{b.text}</a> : b.text}</span>
|
||||
))}
|
||||
</nav>
|
||||
)
|
||||
})
|
||||
|
||||
export function createBreadcrumbs(
|
||||
menu: ContentMenu | undefined,
|
||||
pathname: string
|
||||
) {
|
||||
if (menu?.items) {
|
||||
for (const indexA of menu.items) {
|
||||
const breadcrumbA: ContentBreadcrumb = {
|
||||
text: indexA.text,
|
||||
}
|
||||
if (typeof indexA.href === 'string') {
|
||||
breadcrumbA.href = indexA.href
|
||||
}
|
||||
if (indexA.href === pathname) {
|
||||
return [breadcrumbA]
|
||||
}
|
||||
|
||||
if (indexA.items) {
|
||||
for (const indexB of indexA.items) {
|
||||
const breadcrumbB: ContentBreadcrumb = {
|
||||
text: indexB.text,
|
||||
}
|
||||
if (typeof indexB.href === 'string') {
|
||||
breadcrumbB.href = indexB.href
|
||||
}
|
||||
if (indexB.href === pathname) {
|
||||
return [breadcrumbA, breadcrumbB]
|
||||
}
|
||||
|
||||
if (indexB.items) {
|
||||
for (const indexC of indexB.items) {
|
||||
const breadcrumbC: ContentBreadcrumb = {
|
||||
text: indexC.text,
|
||||
}
|
||||
if (typeof indexC.href === 'string') {
|
||||
breadcrumbC.href = indexC.href
|
||||
}
|
||||
if (indexC.href === pathname) {
|
||||
return [breadcrumbA, breadcrumbB, breadcrumbC]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
interface ContentBreadcrumb {
|
||||
text: string;
|
||||
href?: string;
|
||||
text: string
|
||||
href?: string
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
footer {
|
||||
border-top: 0.5px solid #ddd;
|
||||
margin-top: 40px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-top: 0.5px solid #ddd;
|
||||
margin-top: 40px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
footer a {
|
||||
color: #9e9e9e;
|
||||
font-size: 12px;
|
||||
color: #9e9e9e;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
footer ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
footer li {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
import { component$, useStyles$ } from '@builder.io/qwik';
|
||||
import styles from './footer.css?inline';
|
||||
import { component$, useStyles$ } from '@builder.io/qwik'
|
||||
import styles from './footer.css?inline'
|
||||
|
||||
export default component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
return (
|
||||
<footer>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/docs">Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/about-us">About Us</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/">Qwik</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/QwikDev">Twitter</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/BuilderIO/qwik">GitHub</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/chat">Chat</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<a href="https://www.builder.io/" target="_blank" class="builder">
|
||||
Made with ♡ by Builder.io
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<footer>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/docs">Docs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/about-us">About Us</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/">Qwik</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/QwikDev">Twitter</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/BuilderIO/qwik">GitHub</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/chat">Chat</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<a
|
||||
href="https://www.builder.io/"
|
||||
target="_blank"
|
||||
class="builder"
|
||||
>
|
||||
Made with ♡ by Builder.io
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 11;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(130px, auto) 1fr;
|
||||
gap: 30px;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 11;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(130px, auto) 1fr;
|
||||
gap: 30px;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
background-color: white;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
header a.logo {
|
||||
display: block;
|
||||
display: block;
|
||||
}
|
||||
|
||||
header a {
|
||||
text-decoration: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
header nav {
|
||||
text-align: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
header nav a {
|
||||
display: inline-block;
|
||||
padding: 5px 15px;
|
||||
display: inline-block;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
|
||||
header nav a:hover {
|
||||
text-decoration: underline;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
import { component$, useStyles$ } from '@builder.io/qwik';
|
||||
import { useLocation } from '@builder.io/qwik-city';
|
||||
import { QwikLogo } from '../icons/qwik';
|
||||
import styles from './header.css?inline';
|
||||
import { component$, useStyles$ } from '@builder.io/qwik'
|
||||
import { useLocation } from '@builder.io/qwik-city'
|
||||
import { QwikLogo } from '../icons/qwik'
|
||||
import styles from './header.css?inline'
|
||||
|
||||
export default component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
const { pathname } = useLocation();
|
||||
const { pathname } = useLocation()
|
||||
|
||||
return (
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
<QwikLogo />
|
||||
</a>
|
||||
<nav>
|
||||
<a href="/docs" class={{ active: pathname.startsWith('/docs') }}>
|
||||
Docs
|
||||
</a>
|
||||
<a href="/about-us" class={{ active: pathname.startsWith('/about-us') }}>
|
||||
About Us
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<header>
|
||||
<a class="logo" href="/">
|
||||
<QwikLogo />
|
||||
</a>
|
||||
<nav>
|
||||
<a
|
||||
href="/docs"
|
||||
class={{ active: pathname.startsWith('/docs') }}
|
||||
>
|
||||
Docs
|
||||
</a>
|
||||
<a
|
||||
href="/about-us"
|
||||
class={{ active: pathname.startsWith('/about-us') }}
|
||||
>
|
||||
About Us
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
export const QwikLogo = () => (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 167 53">
|
||||
<path
|
||||
fill="#000"
|
||||
d="M81.95 46.59h-6.4V35.4a12.25 12.25 0 0 1-7.06 2.17c-3.47 0-6.06-.94-7.67-2.92-1.6-1.96-2.42-5.45-2.42-10.43 0-5.1.95-8.62 2.87-10.67 1.96-2.08 5.1-3.09 9.43-3.09 4.1 0 7.82.57 11.25 1.67V46.6Zm-6.4-30.31a16.6 16.6 0 0 0-4.85-.66c-2.17 0-3.73.56-4.6 1.7-.85 1.17-1.32 3.38-1.32 6.65 0 3.08.41 5.14 1.26 6.26.86 1.1 2.33 1.67 4.5 1.67 2.84 0 5.01-1.17 5.01-2.62v-13Zm15.58-5.14c2.27 6.3 4.2 12.6 5.86 18.95 2.22-6.5 4.1-12.8 5.55-18.95h5.61a187.5 187.5 0 0 1 5.3 18.95c2.52-6.9 4.5-13.21 5.95-18.95h6.31a285.68 285.68 0 0 1-8.92 25.76h-7.53c-.86-4.6-2.22-10.14-4.04-16.75a151.51 151.51 0 0 1-4.89 16.75H92.8a287.88 287.88 0 0 0-8.17-25.76h6.5Zm41.7-3.58c-2.83 0-3.63-.7-3.63-3.59 0-2.57.82-3.18 3.63-3.18 2.83 0 3.63.6 3.63 3.18 0 2.89-.8 3.59-3.63 3.59Zm-3.18 3.58h6.4V36.9h-6.4V11.14Zm36.65 0c-4.54 6.46-7.72 10.39-9.49 11.8 1.46.95 5.36 5.95 10.2 13.98h-7.38c-6.02-9.13-8.89-13.07-10.3-13.67v13.67h-6.4V0h6.4v23.23c1.45-1.06 4.63-5.1 9.54-12.09h7.43Z"
|
||||
/>
|
||||
<path
|
||||
fill="#18B6F6"
|
||||
d="M40.97 52.54 32.1 43.7l-.14.02v-.1l-18.9-18.66 4.66-4.5-2.74-15.7L2 20.87a7.14 7.14 0 0 0-1.03 8.52l8.11 13.45a6.81 6.81 0 0 0 5.92 3.3l4.02-.05 21.96 6.46Z"
|
||||
/>
|
||||
<path
|
||||
fill="#AC7EF4"
|
||||
d="m45.82 20.54-1.78-3.3-.93-1.68-.37-.66-.04.04-4.9-8.47a6.85 6.85 0 0 0-5.99-3.43l-4.28.12-12.8.04a6.85 6.85 0 0 0-5.85 3.37L1.1 21.99 15 4.73l18.24 20.04L30 28.04l1.94 15.68.02-.04v.04h-.04l.04.04 1.51 1.47 7.36 7.19c.3.29.81-.06.6-.43l-4.54-8.93 7.91-14.63.26-.3a6.73 6.73 0 0 0 .76-7.6Z"
|
||||
/>
|
||||
<path
|
||||
fill="#fff"
|
||||
d="M33.3 24.69 15.02 4.75l2.6 15.62-4.66 4.51L31.91 43.7l-1.7-15.62 3.1-3.4Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 167 53">
|
||||
<path
|
||||
fill="#000"
|
||||
d="M81.95 46.59h-6.4V35.4a12.25 12.25 0 0 1-7.06 2.17c-3.47 0-6.06-.94-7.67-2.92-1.6-1.96-2.42-5.45-2.42-10.43 0-5.1.95-8.62 2.87-10.67 1.96-2.08 5.1-3.09 9.43-3.09 4.1 0 7.82.57 11.25 1.67V46.6Zm-6.4-30.31a16.6 16.6 0 0 0-4.85-.66c-2.17 0-3.73.56-4.6 1.7-.85 1.17-1.32 3.38-1.32 6.65 0 3.08.41 5.14 1.26 6.26.86 1.1 2.33 1.67 4.5 1.67 2.84 0 5.01-1.17 5.01-2.62v-13Zm15.58-5.14c2.27 6.3 4.2 12.6 5.86 18.95 2.22-6.5 4.1-12.8 5.55-18.95h5.61a187.5 187.5 0 0 1 5.3 18.95c2.52-6.9 4.5-13.21 5.95-18.95h6.31a285.68 285.68 0 0 1-8.92 25.76h-7.53c-.86-4.6-2.22-10.14-4.04-16.75a151.51 151.51 0 0 1-4.89 16.75H92.8a287.88 287.88 0 0 0-8.17-25.76h6.5Zm41.7-3.58c-2.83 0-3.63-.7-3.63-3.59 0-2.57.82-3.18 3.63-3.18 2.83 0 3.63.6 3.63 3.18 0 2.89-.8 3.59-3.63 3.59Zm-3.18 3.58h6.4V36.9h-6.4V11.14Zm36.65 0c-4.54 6.46-7.72 10.39-9.49 11.8 1.46.95 5.36 5.95 10.2 13.98h-7.38c-6.02-9.13-8.89-13.07-10.3-13.67v13.67h-6.4V0h6.4v23.23c1.45-1.06 4.63-5.1 9.54-12.09h7.43Z"
|
||||
/>
|
||||
<path
|
||||
fill="#18B6F6"
|
||||
d="M40.97 52.54 32.1 43.7l-.14.02v-.1l-18.9-18.66 4.66-4.5-2.74-15.7L2 20.87a7.14 7.14 0 0 0-1.03 8.52l8.11 13.45a6.81 6.81 0 0 0 5.92 3.3l4.02-.05 21.96 6.46Z"
|
||||
/>
|
||||
<path
|
||||
fill="#AC7EF4"
|
||||
d="m45.82 20.54-1.78-3.3-.93-1.68-.37-.66-.04.04-4.9-8.47a6.85 6.85 0 0 0-5.99-3.43l-4.28.12-12.8.04a6.85 6.85 0 0 0-5.85 3.37L1.1 21.99 15 4.73l18.24 20.04L30 28.04l1.94 15.68.02-.04v.04h-.04l.04.04 1.51 1.47 7.36 7.19c.3.29.81-.06.6-.43l-4.54-8.93 7.91-14.63.26-.3a6.73 6.73 0 0 0 .76-7.6Z"
|
||||
/>
|
||||
<path
|
||||
fill="#fff"
|
||||
d="M33.3 24.69 15.02 4.75l2.6 15.62-4.66 4.51L31.91 43.7l-1.7-15.62 3.1-3.4Z"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
.menu {
|
||||
background: #eee;
|
||||
padding: 20px 10px;
|
||||
background: #eee;
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.menu h5 {
|
||||
margin: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu ul {
|
||||
padding-left: 20px;
|
||||
margin: 5px 0 25px 0;
|
||||
padding-left: 20px;
|
||||
margin: 5px 0 25px 0;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,37 @@
|
||||
import { component$, useStyles$ } from '@builder.io/qwik';
|
||||
import { useContent, Link, useLocation } from '@builder.io/qwik-city';
|
||||
import styles from './menu.css?inline';
|
||||
import { component$, useStyles$ } from '@builder.io/qwik'
|
||||
import { useContent, Link, useLocation } from '@builder.io/qwik-city'
|
||||
import styles from './menu.css?inline'
|
||||
|
||||
export default component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
const { menu } = useContent();
|
||||
const loc = useLocation();
|
||||
const { menu } = useContent()
|
||||
const loc = useLocation()
|
||||
|
||||
return (
|
||||
<aside class="menu">
|
||||
{menu
|
||||
? menu.items?.map((item) => (
|
||||
<>
|
||||
<h5>{item.text}</h5>
|
||||
<ul>
|
||||
{item.items?.map((item) => (
|
||||
<li>
|
||||
<Link
|
||||
href={item.href}
|
||||
class={{
|
||||
'is-active': loc.pathname === item.href,
|
||||
}}
|
||||
>
|
||||
{item.text}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
))
|
||||
: null}
|
||||
</aside>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<aside class="menu">
|
||||
{menu
|
||||
? menu.items?.map((item) => (
|
||||
<>
|
||||
<h5>{item.text}</h5>
|
||||
<ul>
|
||||
{item.items?.map((item) => (
|
||||
<li>
|
||||
<Link
|
||||
href={item.href}
|
||||
class={{
|
||||
'is-active':
|
||||
loc.pathname === item.href,
|
||||
}}
|
||||
>
|
||||
{item.text}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
))
|
||||
: null}
|
||||
</aside>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
.on-this-page {
|
||||
padding-bottom: 20px;
|
||||
font-size: 0.9em;
|
||||
padding-bottom: 20px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.on-this-page h6 {
|
||||
margin: 10px 0;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
margin: 10px 0;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.on-this-page ul {
|
||||
margin: 0;
|
||||
padding: 0 0 20px 0;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0 0 20px 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.on-this-page a {
|
||||
position: relative;
|
||||
display: block;
|
||||
border: 0 solid #ddd;
|
||||
border-left-width: 2px;
|
||||
padding: 4px 2px 4px 8px;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
display: block;
|
||||
border: 0 solid #ddd;
|
||||
border-left-width: 2px;
|
||||
padding: 4px 2px 4px 8px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.on-this-page a.indent {
|
||||
padding-left: 30px;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.on-this-page a:hover {
|
||||
border-color: var(--theme-accent);
|
||||
border-color: var(--theme-accent);
|
||||
}
|
||||
|
||||
@@ -1,62 +1,63 @@
|
||||
import { useContent, useLocation } from '@builder.io/qwik-city';
|
||||
import { component$, useStyles$ } from '@builder.io/qwik';
|
||||
import styles from './on-this-page.css?inline';
|
||||
import { useContent, useLocation } from '@builder.io/qwik-city'
|
||||
import { component$, useStyles$ } from '@builder.io/qwik'
|
||||
import styles from './on-this-page.css?inline'
|
||||
|
||||
export default component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
const { headings } = useContent();
|
||||
const contentHeadings = headings?.filter((h) => h.level === 2 || h.level === 3) || [];
|
||||
const { headings } = useContent()
|
||||
const contentHeadings =
|
||||
headings?.filter((h) => h.level === 2 || h.level === 3) || []
|
||||
|
||||
const { pathname } = useLocation();
|
||||
const editUrl = `#update-your-edit-url-for-${pathname}`;
|
||||
const { pathname } = useLocation()
|
||||
const editUrl = `#update-your-edit-url-for-${pathname}`
|
||||
|
||||
return (
|
||||
<aside class="on-this-page">
|
||||
{contentHeadings.length > 0 ? (
|
||||
<>
|
||||
<h6>On This Page</h6>
|
||||
<ul>
|
||||
{contentHeadings.map((h) => (
|
||||
<li>
|
||||
<a
|
||||
href={`#${h.id}`}
|
||||
class={{
|
||||
block: true,
|
||||
indent: h.level > 2,
|
||||
}}
|
||||
>
|
||||
{h.text}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
return (
|
||||
<aside class="on-this-page">
|
||||
{contentHeadings.length > 0 ? (
|
||||
<>
|
||||
<h6>On This Page</h6>
|
||||
<ul>
|
||||
{contentHeadings.map((h) => (
|
||||
<li>
|
||||
<a
|
||||
href={`#${h.id}`}
|
||||
class={{
|
||||
block: true,
|
||||
indent: h.level > 2,
|
||||
}}
|
||||
>
|
||||
{h.text}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<h6>More</h6>
|
||||
<ul>
|
||||
<li>
|
||||
<a href={editUrl} target="_blank">
|
||||
Edit this page
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/chat" target="_blank">
|
||||
Join our community
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/BuilderIO/qwik" target="_blank">
|
||||
GitHub
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/QwikDev" target="_blank">
|
||||
@QwikDev
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
);
|
||||
});
|
||||
<h6>More</h6>
|
||||
<ul>
|
||||
<li>
|
||||
<a href={editUrl} target="_blank">
|
||||
Edit this page
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://qwik.builder.io/chat" target="_blank">
|
||||
Join our community
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/BuilderIO/qwik" target="_blank">
|
||||
GitHub
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://twitter.com/QwikDev" target="_blank">
|
||||
@QwikDev
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
import { component$ } from '@builder.io/qwik';
|
||||
import { useDocumentHead, useLocation } from '@builder.io/qwik-city';
|
||||
import { component$ } from '@builder.io/qwik'
|
||||
import { useDocumentHead, useLocation } from '@builder.io/qwik-city'
|
||||
|
||||
/**
|
||||
* The RouterHead component is placed inside of the document `<head>` element.
|
||||
*/
|
||||
export const RouterHead = component$(() => {
|
||||
const head = useDocumentHead();
|
||||
const loc = useLocation();
|
||||
const head = useDocumentHead()
|
||||
const loc = useLocation()
|
||||
|
||||
return (
|
||||
<>
|
||||
<title>{head.title}</title>
|
||||
return (
|
||||
<>
|
||||
<title>{head.title}</title>
|
||||
|
||||
<link rel="canonical" href={loc.href} />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="canonical" href={loc.href} />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0"
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
|
||||
{head.meta.map((m) => (
|
||||
<meta {...m} />
|
||||
))}
|
||||
{head.meta.map((m) => (
|
||||
<meta {...m} />
|
||||
))}
|
||||
|
||||
{head.links.map((l) => (
|
||||
<link {...l} />
|
||||
))}
|
||||
{head.links.map((l) => (
|
||||
<link {...l} />
|
||||
))}
|
||||
|
||||
{head.styles.map((s) => (
|
||||
<style {...s.props} dangerouslySetInnerHTML={s.style} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
});
|
||||
{head.styles.map((s) => (
|
||||
<style {...s.props} dangerouslySetInnerHTML={s.style} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
* - https://qwik.builder.io/qwikcity/adaptors/cloudflare-pages/
|
||||
*
|
||||
*/
|
||||
import { createQwikCity } from '@builder.io/qwik-city/middleware/cloudflare-pages';
|
||||
import qwikCityPlan from '@qwik-city-plan';
|
||||
import render from './entry.ssr';
|
||||
import { createQwikCity } from '@builder.io/qwik-city/middleware/cloudflare-pages'
|
||||
import qwikCityPlan from '@qwik-city-plan'
|
||||
import render from './entry.ssr'
|
||||
|
||||
const onRequest = createQwikCity({ render, qwikCityPlan });
|
||||
const onRequest = createQwikCity({ render, qwikCityPlan })
|
||||
|
||||
export { onRequest };
|
||||
export { onRequest }
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
* - More code is transferred to the browser than in SSR mode.
|
||||
* - Optimizer/Serialization/Deserialization code is not exercised!
|
||||
*/
|
||||
import { render, RenderOptions } from '@builder.io/qwik';
|
||||
import Root from './root';
|
||||
import { render, RenderOptions } from '@builder.io/qwik'
|
||||
import Root from './root'
|
||||
|
||||
export default function (opts: RenderOptions) {
|
||||
return render(document, <Root />, opts);
|
||||
return render(document, <Root />, opts)
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
* - https://vitejs.dev/config/preview-options.html#preview-options
|
||||
*
|
||||
*/
|
||||
import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
|
||||
import render from './entry.ssr';
|
||||
import qwikCityPlan from '@qwik-city-plan';
|
||||
import { createQwikCity } from '@builder.io/qwik-city/middleware/node'
|
||||
import render from './entry.ssr'
|
||||
import qwikCityPlan from '@qwik-city-plan'
|
||||
|
||||
/**
|
||||
* The default export is the QwikCity adaptor used by Vite preview.
|
||||
*/
|
||||
export default createQwikCity({ render, qwikCityPlan });
|
||||
export default createQwikCity({ render, qwikCityPlan })
|
||||
|
||||
@@ -10,18 +10,18 @@
|
||||
* - npm run build
|
||||
*
|
||||
*/
|
||||
import { renderToStream, RenderToStreamOptions } from '@builder.io/qwik/server';
|
||||
import { manifest } from '@qwik-client-manifest';
|
||||
import Root from './root';
|
||||
import { renderToStream, RenderToStreamOptions } from '@builder.io/qwik/server'
|
||||
import { manifest } from '@qwik-client-manifest'
|
||||
import Root from './root'
|
||||
|
||||
export default function (opts: RenderToStreamOptions) {
|
||||
return renderToStream(<Root />, {
|
||||
manifest,
|
||||
...opts,
|
||||
// Use container attributes to set attributes on the html tag.
|
||||
containerAttributes: {
|
||||
lang: 'en-us',
|
||||
...opts.containerAttributes,
|
||||
},
|
||||
});
|
||||
return renderToStream(<Root />, {
|
||||
manifest,
|
||||
...opts,
|
||||
// Use container attributes to set attributes on the html tag.
|
||||
containerAttributes: {
|
||||
lang: 'en-us',
|
||||
...opts.containerAttributes,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,66 +1,67 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--user-font-scale: 1rem - 16px;
|
||||
--max-width: calc(100% - 1rem);
|
||||
--user-font-scale: 1rem - 16px;
|
||||
--max-width: calc(100% - 1rem);
|
||||
|
||||
--font-body: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif,
|
||||
Apple Color Emoji, Segoe UI Emoji;
|
||||
--font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console',
|
||||
'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono',
|
||||
'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace;
|
||||
--font-body: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI,
|
||||
Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;
|
||||
--font-mono: 'IBM Plex Mono', Consolas, 'Andale Mono WT', 'Andale Mono',
|
||||
'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono',
|
||||
'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco,
|
||||
'Courier New', Courier, monospace;
|
||||
|
||||
color-scheme: light;
|
||||
--theme-accent: #006ce9;
|
||||
--theme-text: #181818;
|
||||
color-scheme: light;
|
||||
--theme-accent: #006ce9;
|
||||
--theme-text: #181818;
|
||||
}
|
||||
|
||||
@media (min-width: 50em) {
|
||||
:root {
|
||||
--max-width: 46em;
|
||||
}
|
||||
:root {
|
||||
--max-width: 46em;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
font-family: var(--font-body);
|
||||
font-size: 1rem;
|
||||
font-size: clamp(0.9rem, 0.75rem + 0.375vw + var(--user-font-scale), 1rem);
|
||||
line-height: 1.5;
|
||||
max-width: 100vw;
|
||||
background: var(--theme-bg);
|
||||
color: var(--theme-text);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
font-family: var(--font-body);
|
||||
font-size: 1rem;
|
||||
font-size: clamp(0.9rem, 0.75rem + 0.375vw + var(--user-font-scale), 1rem);
|
||||
line-height: 1.5;
|
||||
max-width: 100vw;
|
||||
background: var(--theme-bg);
|
||||
color: var(--theme-text);
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 10px 20px;
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
padding: 10px 20px;
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--theme-accent);
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp,
|
||||
pre {
|
||||
font-family: var(--font-mono);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: rgb(224, 224, 224);
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
border-bottom: 2px solid #bfbfbf;
|
||||
background-color: rgb(224, 224, 224);
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
border-bottom: 2px solid #bfbfbf;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
import { component$ } from '@builder.io/qwik';
|
||||
import { QwikCityProvider, RouterOutlet, ServiceWorkerRegister } from '@builder.io/qwik-city';
|
||||
import { RouterHead } from './components/router-head/router-head';
|
||||
import { component$ } from '@builder.io/qwik'
|
||||
import {
|
||||
QwikCityProvider,
|
||||
RouterOutlet,
|
||||
ServiceWorkerRegister,
|
||||
} from '@builder.io/qwik-city'
|
||||
import { RouterHead } from './components/router-head/router-head'
|
||||
|
||||
import './global.css';
|
||||
import './global.css'
|
||||
|
||||
export default component$(() => {
|
||||
/*
|
||||
* The root of a QwikCity site always start with the <QwikCityProvider> component,
|
||||
* immediately followed by the document's <head> and <body>.
|
||||
*
|
||||
* Dont remove the `<head>` and `<body>` elements.
|
||||
*/
|
||||
return (
|
||||
<QwikCityProvider>
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<RouterHead />
|
||||
</head>
|
||||
<body lang="en">
|
||||
<RouterOutlet />
|
||||
<ServiceWorkerRegister />
|
||||
</body>
|
||||
</QwikCityProvider>
|
||||
);
|
||||
});
|
||||
/*
|
||||
* The root of a QwikCity site always start with the <QwikCityProvider> component,
|
||||
* immediately followed by the document's <head> and <body>.
|
||||
*
|
||||
* Dont remove the `<head>` and `<body>` elements.
|
||||
*/
|
||||
return (
|
||||
<QwikCityProvider>
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<RouterHead />
|
||||
</head>
|
||||
<body lang="en">
|
||||
<RouterOutlet />
|
||||
<ServiceWorkerRegister />
|
||||
</body>
|
||||
</QwikCityProvider>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
.docs {
|
||||
display: grid;
|
||||
grid-template-columns: 210px auto 190px;
|
||||
grid-template-areas: 'menu article on-this-page';
|
||||
gap: 40px;
|
||||
display: grid;
|
||||
grid-template-columns: 210px auto 190px;
|
||||
grid-template-areas: 'menu article on-this-page';
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.docs h1 {
|
||||
margin-top: 0;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.docs .menu {
|
||||
grid-area: menu;
|
||||
grid-area: menu;
|
||||
}
|
||||
|
||||
.docs article {
|
||||
grid-area: article;
|
||||
grid-area: article;
|
||||
}
|
||||
|
||||
.docs .on-this-page {
|
||||
grid-area: on-this-page;
|
||||
grid-area: on-this-page;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { component$, Slot, useStyles$ } from '@builder.io/qwik';
|
||||
import type { DocumentHead } from '@builder.io/qwik-city';
|
||||
import Menu from '~/components/menu/menu';
|
||||
import OnThisPage from '~/components/on-this-page/on-this-page';
|
||||
import styles from './docs.css?inline';
|
||||
import { component$, Slot, useStyles$ } from '@builder.io/qwik'
|
||||
import type { DocumentHead } from '@builder.io/qwik-city'
|
||||
import Menu from '~/components/menu/menu'
|
||||
import OnThisPage from '~/components/on-this-page/on-this-page'
|
||||
import styles from './docs.css?inline'
|
||||
|
||||
export default component$(() => {
|
||||
useStyles$(styles);
|
||||
useStyles$(styles)
|
||||
|
||||
return (
|
||||
<div class="docs">
|
||||
<Menu />
|
||||
<article>
|
||||
<Slot />
|
||||
</article>
|
||||
<OnThisPage />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div class="docs">
|
||||
<Menu />
|
||||
<article>
|
||||
<Slot />
|
||||
</article>
|
||||
<OnThisPage />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
export const head: DocumentHead = ({ head }) => {
|
||||
return {
|
||||
title: `${head.title} - Documentation`,
|
||||
};
|
||||
};
|
||||
return {
|
||||
title: `${head.title} - Documentation`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,143 +4,228 @@ import type { DocumentHead } from '@builder.io/qwik-city'
|
||||
export default component$(() => {
|
||||
return (
|
||||
<>
|
||||
<h1>Welcome to BotWhatsapp Docs Starter</h1>
|
||||
<h1>Bienvenido</h1>
|
||||
|
||||
<p>
|
||||
Un robot (bot) de Whatsapp es un programa que reconoce palabras
|
||||
clave en los mensajes que entran, y contesta con respuestas
|
||||
pre-programadas, facilitando así el dar información a posibles
|
||||
clientes desde tu cuenta de Whatsapp automáticamente.
|
||||
</p>
|
||||
<p>
|
||||
Este bot esta programado en Javascript y usa NodeJS y es{' '}
|
||||
<a href="https://www.redhat.com/es/topics/open-source/what-is-open-source">
|
||||
Open Source
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
<p>
|
||||
Está programado de tal forma que se pueden usar varias librerías
|
||||
(hasta ahora whatsapp-web.js, twilio y Venom) y se puden agregar
|
||||
más.
|
||||
</p>
|
||||
<p>
|
||||
Si se quere cambiar la librería que se está usando, esto se
|
||||
puede hacer con solo cambiar unas lineas en el código.
|
||||
</p>
|
||||
|
||||
<table border>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Características</th>
|
||||
<th>Estatus</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Menus y Submenus</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dialogflow</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MySQL</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>JSON File</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QR Scan (route)</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Easy deploy heroku</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Buttons</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="information_source"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2139.png"
|
||||
>
|
||||
ℹ️
|
||||
</g-emoji>{' '}
|
||||
(No funciona en multi-device)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send Voice Note</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Add support ubuntu/linux</td>
|
||||
<td>
|
||||
<g-emoji
|
||||
class="g-emoji"
|
||||
alias="white_check_mark"
|
||||
fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2705.png"
|
||||
>
|
||||
✅
|
||||
</g-emoji>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>Requisitos</h2>
|
||||
<ul>
|
||||
<li>This homepage uses a layout without a menu.</li>
|
||||
<li>Node v14 o superior</li>
|
||||
<li>
|
||||
<span>The </span>
|
||||
<a href="/docs">Documentation</a>
|
||||
<span>
|
||||
{' '}
|
||||
pages use multiple nested layouts, one of them providing
|
||||
a left menu.
|
||||
</span>
|
||||
VSCode (Editor de codigo){' '}
|
||||
<a
|
||||
href="https://code.visualstudio.com/download"
|
||||
rel="nofollow"
|
||||
>
|
||||
Descargar
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
Check out the <code>src/routes</code> directory to get
|
||||
started.
|
||||
MySql (opcional) solo aplica si vas a usar el modo 'mysql'{' '}
|
||||
<a href="https://github.com/leifermendez/bot-whatsapp/blob/main/sql-bot.sql">
|
||||
sql-bot.sql migración
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
Add integrations with <code>npm run qwik add</code>.
|
||||
</li>
|
||||
<li>
|
||||
More info about development in <code>README.md</code>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/docs">Qwik City</a>
|
||||
<span> is the meta-framework for Qwik</span>
|
||||
Dialogflow (opcional) solo aplica si vas a usar el modo
|
||||
'dialogflow'
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>Commands</h2>
|
||||
|
||||
<table class="commands">
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run dev</code>
|
||||
</td>
|
||||
<td>Start the dev server and watch for changes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run preview</code>
|
||||
</td>
|
||||
<td>Production build and start preview server.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run build</code>
|
||||
</td>
|
||||
<td>Production build.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run qwik add</code>
|
||||
</td>
|
||||
<td>Select an integration to add.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Add Integrations</h2>
|
||||
|
||||
<table class="commands">
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run qwik add cloudflare-pages</code>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
href="https://developers.cloudflare.com/pages"
|
||||
target="_blank"
|
||||
>
|
||||
Cloudflare Pages Server
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run qwik add express</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://expressjs.com/" target="_blank">
|
||||
Nodejs Express Server
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run qwik add netlify-edge</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="https://docs.netlify.com/" target="_blank">
|
||||
Netlify Edge Functions
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>npm run qwik add static</code>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
href="https://qwik.builder.io/qwikcity/static-site-generation/overview/"
|
||||
target="_blank"
|
||||
>
|
||||
Static Site Generation (SSG)
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Community</h2>
|
||||
|
||||
<h2>Instalación</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<span>Questions or just want to say hi? </span>
|
||||
<a href="https://qwik.builder.io/chat" target="_blank">
|
||||
Chat on discord!
|
||||
</a>
|
||||
Abre VSCode y muevete al directorio en donde queres insralar
|
||||
el bot.
|
||||
</li>
|
||||
<li>Ejecuta este comando: npm create bot-whatsapp@latest</li>
|
||||
<li>Contesta que SI queres crear un bot nuevo (Y)</li>
|
||||
<li>
|
||||
Selecciona con las flechas (arriba y abajo) la librería que
|
||||
quieres usar para el bot, cuando estes sobre la opción que
|
||||
quieres, oprime la barra de espacio y luego la tecla "Enter"
|
||||
</li>
|
||||
<li>
|
||||
<span>Follow </span>
|
||||
<a href="https://twitter.com/QwikDev" target="_blank">
|
||||
@QwikDev
|
||||
</a>
|
||||
<span> on Twitter</span>
|
||||
De igual forma selecciona la base de daros que quieres usar.
|
||||
</li>
|
||||
<li>
|
||||
<span>Open issues and contribute on </span>
|
||||
<a href="https://github.com/BuilderIO/qwik" target="_blank">
|
||||
GitHub
|
||||
</a>
|
||||
Cambiate al directorio que se creo dependiendo de la base de
|
||||
datos que hayas seleccionado, si seleccionaste "Memory"
|
||||
sería "cd base-wweb-memory"
|
||||
</li>
|
||||
<li>
|
||||
<span>Watch </span>
|
||||
<a href="https://qwik.builder.io/media/" target="_blank">
|
||||
Presentations, Podcasts, Videos, etc.
|
||||
</a>
|
||||
Ya estando en el nuevo subdirectorio, ejecuta el comando
|
||||
"npm install" y espera a que se instalen las dependencias.
|
||||
</li>
|
||||
<li>
|
||||
Una vez que termine la instalación ejecuta el comando "npm
|
||||
start"y espera a que te mande el mensaje de que necesitas
|
||||
escanear el código QR, para esto ve al directorio en el que
|
||||
se instaló y busca el archivo "qr.svg" y abrelo, te debe de
|
||||
mostrsr un código QR que tienes que escanear en el Whatsapp
|
||||
que quieres ligar con el bot, para esto ve a tu Whatsapp,
|
||||
haz clic en los tres botones de arriba a la derecha y entra
|
||||
en "Linked devices", y luego en el botón que dice "LINK
|
||||
DEVICE", esto va a abrir la camara para que escanes el
|
||||
código.
|
||||
</li>
|
||||
<li>
|
||||
Una vez ligado el Whatsapp vas a ver el mensaje de
|
||||
"Proveedor conectado y listo".
|
||||
</li>
|
||||
<li>
|
||||
Desde OTRO celular mandas un mensaje al numero del Whatsapp
|
||||
que acabas de ligar al bot con la palabra "Hola" y LISTO.
|
||||
</li>
|
||||
<li>Debes de recibir una respuesta automática del bot.</li>
|
||||
</ul>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { component$, Slot } from '@builder.io/qwik';
|
||||
import Footer from '~/components/footer/footer';
|
||||
import Header from '~/components/header/header';
|
||||
import { component$, Slot } from '@builder.io/qwik'
|
||||
import Footer from '~/components/footer/footer'
|
||||
import Header from '~/components/header/header'
|
||||
|
||||
export default component$(() => {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<main>
|
||||
<Slot />
|
||||
</main>
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<main>
|
||||
<Slot />
|
||||
</main>
|
||||
<Footer />
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
* Qwik uses a service worker to speed up your site and reduce latency, ie, not used in the traditional way of offline.
|
||||
* You can also use this file to add more functionality that runs in the service worker.
|
||||
*/
|
||||
import { setupServiceWorker } from '@builder.io/qwik-city/service-worker';
|
||||
import { setupServiceWorker } from '@builder.io/qwik-city/service-worker'
|
||||
|
||||
setupServiceWorker();
|
||||
setupServiceWorker()
|
||||
|
||||
addEventListener('install', () => self.skipWaiting());
|
||||
addEventListener('install', () => self.skipWaiting())
|
||||
|
||||
addEventListener('activate', () => self.clients.claim());
|
||||
addEventListener('activate', () => self.clients.claim())
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope;
|
||||
declare const self: ServiceWorkerGlobalScope
|
||||
|
||||
21
packages/docs/tailwind.config.js
Normal file
21
packages/docs/tailwind.config.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
|
||||
const defaultTheme = require('tailwindcss/defaultTheme')
|
||||
const colors = require('tailwindcss/colors')
|
||||
|
||||
module.exports = {
|
||||
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
primary: colors.purple,
|
||||
secondary: colors.sky,
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ["'Inter'", ...defaultTheme.fontFamily.sans],
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
darkMode: 'class',
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { qwikVite } from '@builder.io/qwik/optimizer';
|
||||
import { qwikCity } from '@builder.io/qwik-city/vite';
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import { defineConfig } from 'vite'
|
||||
import { qwikVite } from '@builder.io/qwik/optimizer'
|
||||
import { qwikCity } from '@builder.io/qwik-city/vite'
|
||||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||||
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
|
||||
preview: {
|
||||
headers: {
|
||||
'Cache-Control': 'public, max-age=600',
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
return {
|
||||
plugins: [qwikCity(), qwikVite(), tsconfigPaths()],
|
||||
preview: {
|
||||
headers: {
|
||||
'Cache-Control': 'public, max-age=600',
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# @bot-whatsapp/provider
|
||||
|
||||
```js
|
||||
// bootstrap.js Como iniciar el provider
|
||||
const { inout, provider, database } = require('@bot-whatsapp')
|
||||
|
||||
provider.start()
|
||||
provider.close()
|
||||
```
|
||||
|
||||
- [ ] whatsapp-web.js _verificar update_
|
||||
- [ ] Meta _verificar tokens_
|
||||
- [ ] Twilio _verificar tokens_
|
||||
@@ -1,12 +1,14 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/provider",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.26-alpha.0",
|
||||
"description": "Esto es el conector a Twilio, Meta, etc...",
|
||||
"main": "./lib/mock/index.cjs",
|
||||
"private": true,
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"files": [
|
||||
"./lib/"
|
||||
],
|
||||
"dependencies": {
|
||||
"@bot-whatsapp/bot": "*",
|
||||
"qr-image": "^3.2.0"
|
||||
@@ -14,6 +16,8 @@
|
||||
"exports": {
|
||||
"./mock": "./lib/mock/index.cjs",
|
||||
"./twilio": "./lib/twilio/index.cjs",
|
||||
"./web-whatsapp": "./lib/web-whatsapp/index.cjs"
|
||||
"./web-whatsapp": "./lib/web-whatsapp/index.cjs",
|
||||
"./venom": "./lib/venom/index.cjs",
|
||||
"./baileys": "./lib/baileys/index.cjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,22 @@ module.exports = [
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
},
|
||||
{
|
||||
input: join(__dirname, 'src', 'venom', 'index.js'),
|
||||
output: {
|
||||
banner: banner['banner.output'].join(''),
|
||||
file: join(__dirname, 'lib', 'venom', 'index.cjs'),
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
},
|
||||
{
|
||||
input: join(__dirname, 'src', 'baileys', 'index.js'),
|
||||
output: {
|
||||
banner: banner['banner.output'].join(''),
|
||||
file: join(__dirname, 'lib', 'baileys', 'index.cjs'),
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
},
|
||||
]
|
||||
|
||||
171
packages/provider/src/baileys/index.js
Normal file
171
packages/provider/src/baileys/index.js
Normal file
@@ -0,0 +1,171 @@
|
||||
const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
const pino = require('pino')
|
||||
const {
|
||||
default: makeWASocket,
|
||||
useMultiFileAuthState,
|
||||
} = require('@adiwajshing/baileys')
|
||||
const {
|
||||
baileyGenerateImage,
|
||||
baileyCleanNumber,
|
||||
baileyIsValidNumber,
|
||||
} = require('./utils')
|
||||
|
||||
/**
|
||||
* ⚙️ BaileysProvider: Es una clase tipo adaptor
|
||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||
* https://github.com/adiwajshing/Baileys
|
||||
*/
|
||||
class BaileysProvider extends ProviderClass {
|
||||
vendor
|
||||
constructor() {
|
||||
super()
|
||||
this.initBailey().then(() => this.initBusEvents())
|
||||
}
|
||||
|
||||
/**
|
||||
* Iniciar todo Bailey
|
||||
*/
|
||||
async initBailey() {
|
||||
const { state, saveCreds } = await useMultiFileAuthState('sessions')
|
||||
|
||||
try {
|
||||
this.vendor = makeWASocket({
|
||||
printQRInTerminal: false,
|
||||
auth: state,
|
||||
logger: pino({ level: 'error' }),
|
||||
})
|
||||
|
||||
this.vendor.ev.on(
|
||||
'connection.update',
|
||||
async ({ qr, connection, lastDisconnect }) => {
|
||||
if (qr) baileyGenerateImage(qr)
|
||||
if (connection === 'open') this.emit('ready', true)
|
||||
if (lastDisconnect?.error) {
|
||||
saveCreds()
|
||||
this.initBailey()
|
||||
}
|
||||
}
|
||||
)
|
||||
} catch (e) {
|
||||
this.emit('error', e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapeamos los eventos nativos a los que la clase Provider espera
|
||||
* para tener un standar de eventos
|
||||
* @returns
|
||||
*/
|
||||
busEvents = () => [
|
||||
{
|
||||
event: 'connection.update',
|
||||
func: async ({ qr, connection, lastDisconnect }) => {
|
||||
if (qr) {
|
||||
this.emit('require_action', {
|
||||
instructions: [
|
||||
`Debes escanear el QR Code para iniciar session reivsa qr.png`,
|
||||
`Recuerda que el QR se actualiza cada minuto `,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
})
|
||||
baileyGenerateImage(qr)
|
||||
}
|
||||
|
||||
if (lastDisconnect?.error) {
|
||||
this.emit('require_action', {
|
||||
instructions: [
|
||||
`Algo sucedio reinicia el bot o revisa tu whatsapp`,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
if (connection === 'open') this.emit('ready', true)
|
||||
},
|
||||
},
|
||||
{
|
||||
event: 'messages.upsert',
|
||||
func: ({ messages }) => {
|
||||
const [messageCtx] = messages
|
||||
let payload = {
|
||||
...messageCtx,
|
||||
body: messageCtx?.message?.conversation,
|
||||
from: messageCtx?.key?.remoteJid,
|
||||
}
|
||||
if (payload.from === 'status@broadcast') {
|
||||
return
|
||||
}
|
||||
|
||||
if (!baileyIsValidNumber(payload.from)) {
|
||||
return
|
||||
}
|
||||
payload.from = baileyCleanNumber(payload.from, true)
|
||||
this.emit('message', payload)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
initBusEvents = () => {
|
||||
const listEvents = this.busEvents()
|
||||
|
||||
for (const { event, func } of listEvents) {
|
||||
this.vendor.ev.on(event, func)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'https://dominio.com/imagen.jpg' | 'img/imagen.jpg')
|
||||
*/
|
||||
|
||||
sendMedia = async (number, imageUrl) => {
|
||||
await this.vendor.sendMessage(number, {
|
||||
image: { url: imageUrl },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @alpha
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @param {boolean} voiceNote optional
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
|
||||
*/
|
||||
|
||||
sendAudio = async (number, audioUrl, voiceNote = false) => {
|
||||
const numberClean = number.replace('+', '')
|
||||
await this.vendor.sendMessage(`${numberClean}@c.us`, {
|
||||
audio: { url: audioUrl },
|
||||
ptt: voiceNote,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @returns
|
||||
*/
|
||||
sendText = async (number, message) => {
|
||||
return this.vendor.sendMessage(number, { text: message })
|
||||
}
|
||||
/**
|
||||
* TODO: Necesita terminar de implementar el sendMedia y sendButton guiarse:
|
||||
* https://github.com/leifermendez/bot-whatsapp/blob/4e0fcbd8347f8a430adb43351b5415098a5d10df/packages/provider/src/web-whatsapp/index.js#L165
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'Hello World')
|
||||
*/
|
||||
sendMessage = async (numberIn, message, { options }) => {
|
||||
const number = baileyCleanNumber(numberIn)
|
||||
|
||||
// if (options?.buttons?.length)
|
||||
// return this.sendButtons(number, message, options.buttons)
|
||||
if (options?.media) return this.sendMedia(number, options.media)
|
||||
return this.sendText(number, message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BaileysProvider
|
||||
21
packages/provider/src/baileys/utils.js
Normal file
21
packages/provider/src/baileys/utils.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { createWriteStream } = require('fs')
|
||||
const qr = require('qr-image')
|
||||
|
||||
const baileyCleanNumber = (number, full = false) => {
|
||||
number = number.replace('@s.whatsapp.net', '')
|
||||
number = !full ? `${number}@s.whatsapp.net` : `${number}`
|
||||
return number
|
||||
}
|
||||
|
||||
const baileyGenerateImage = (base64) => {
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 })
|
||||
qr_svg.pipe(createWriteStream(`${process.cwd()}/qr.png`))
|
||||
}
|
||||
|
||||
const baileyIsValidNumber = (rawNumber) => {
|
||||
const regexGroup = /\@g.us\b/gm
|
||||
const exist = rawNumber.match(regexGroup)
|
||||
return !exist
|
||||
}
|
||||
|
||||
module.exports = { baileyCleanNumber, baileyGenerateImage, baileyIsValidNumber }
|
||||
@@ -1,19 +1,116 @@
|
||||
const twilio = require('twilio')
|
||||
const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioVendor = new twilio(accountSid, authToken)
|
||||
const TwilioWebHookServer = require('./server')
|
||||
const { parseNumber } = require('./utils')
|
||||
|
||||
/**
|
||||
* ⚙️TwilioProvider: Es un provedor que te ofrece enviar
|
||||
* mensaje a Whatsapp via API
|
||||
* info: https://www.twilio.com/es-mx/messaging/whatsapp
|
||||
* video: https://youtu.be/KoOmsHylxUw
|
||||
*
|
||||
* Necesitas las siguientes tokens y valores
|
||||
* { accountSid, authToken, vendorNumber }
|
||||
*/
|
||||
class TwilioProvider extends ProviderClass {
|
||||
constructor() {
|
||||
super(TwilioVendor)
|
||||
twilioHook
|
||||
vendor
|
||||
vendorNumber
|
||||
constructor({ accountSid, authToken, vendorNumber }, _port = 3000) {
|
||||
super()
|
||||
this.vendor = new twilio(accountSid, authToken)
|
||||
this.twilioHook = new TwilioWebHookServer(_port)
|
||||
this.vendorNumber = parseNumber(vendorNumber)
|
||||
|
||||
this.twilioHook.start()
|
||||
const listEvents = this.busEvents()
|
||||
|
||||
for (const { event, func } of listEvents) {
|
||||
this.twilioHook.on(event, func)
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage = (message) =>
|
||||
this.vendor.messages.create({
|
||||
/**
|
||||
* Mapeamos los eventos nativos de whatsapp-web.js a los que la clase Provider espera
|
||||
* para tener un standar de eventos
|
||||
* @returns
|
||||
*/
|
||||
busEvents = () => [
|
||||
{
|
||||
event: 'auth_failure',
|
||||
func: (payload) => this.emit('error', payload),
|
||||
},
|
||||
{
|
||||
event: 'ready',
|
||||
func: () => this.emit('ready', true),
|
||||
},
|
||||
{
|
||||
event: 'message',
|
||||
func: (payload) => {
|
||||
this.emit('message', payload)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* Enviar un archivo multimedia
|
||||
* https://www.twilio.com/es-mx/docs/whatsapp/tutorial/send-and-receive-media-messages-whatsapp-nodejs
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @returns
|
||||
*/
|
||||
sendMedia = async (number, message, mediaInput = null) => {
|
||||
if (!mediaInput) throw new Error(`MEDIA_INPUT_NULL_: ${mediaInput}`)
|
||||
number = parseNumber(number)
|
||||
return this.vendor.messages.create({
|
||||
mediaUrl: [`${mediaInput}`],
|
||||
body: message,
|
||||
to: '+12345678901', // Text this number
|
||||
from: '+12345678901', // From a valid Twilio number
|
||||
from: `whatsapp:+${this.vendorNumber}`,
|
||||
to: `whatsapp:+${number}`,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar botones
|
||||
* https://www.twilio.com/es-mx/docs/whatsapp/buttons
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} message
|
||||
* @param {*} buttons []
|
||||
* @returns
|
||||
*/
|
||||
sendButtons = async () => {
|
||||
console.log(``)
|
||||
console.log(
|
||||
`[NOTA]: Actualmente enviar botons con Twilio esta en desarrollo`
|
||||
)
|
||||
console.log(
|
||||
`[NOTA]: https://www.twilio.com/es-mx/docs/whatsapp/buttons`
|
||||
)
|
||||
console.log(``)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} userId
|
||||
* @param {*} message
|
||||
* @param {*} param2
|
||||
* @returns
|
||||
*/
|
||||
sendMessage = async (number, message, { options }) => {
|
||||
number = parseNumber(number)
|
||||
if (options?.buttons?.length)
|
||||
this.sendButtons(number, message, options.buttons)
|
||||
if (options?.media)
|
||||
return this.sendMedia(number, message, options.media)
|
||||
return this.vendor.messages.create({
|
||||
body: message,
|
||||
from: `whatsapp:+${this.vendorNumber}`,
|
||||
to: `whatsapp:+${number}`,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TwilioProvider
|
||||
|
||||
64
packages/provider/src/twilio/server.js
Normal file
64
packages/provider/src/twilio/server.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const { EventEmitter } = require('node:events')
|
||||
const polka = require('polka')
|
||||
const { urlencoded } = require('body-parser')
|
||||
const { parseNumber } = require('./utils')
|
||||
|
||||
/**
|
||||
* Encargado de levantar un servidor HTTP con una hook url
|
||||
* [POST] /twilio-hook
|
||||
*/
|
||||
class TwilioWebHookServer extends EventEmitter {
|
||||
twilioServer
|
||||
twilioPort
|
||||
constructor(_twilioPort) {
|
||||
super()
|
||||
this.twilioServer = this.buildHTTPServer()
|
||||
this.twilioPort = _twilioPort
|
||||
}
|
||||
|
||||
/**
|
||||
* Mensaje entrante
|
||||
* emit: 'message'
|
||||
* @param {*} req
|
||||
* @param {*} res
|
||||
*/
|
||||
incomingMsg = (req, res) => {
|
||||
const { body } = req
|
||||
this.emit('message', {
|
||||
from: parseNumber(body.From),
|
||||
to: parseNumber(body.To),
|
||||
body: body.Body,
|
||||
})
|
||||
const json = JSON.stringify({ body })
|
||||
res.end(json)
|
||||
}
|
||||
|
||||
/**
|
||||
* Contruir HTTP Server
|
||||
* @returns
|
||||
*/
|
||||
buildHTTPServer = () => {
|
||||
return polka()
|
||||
.use(urlencoded({ extended: true }))
|
||||
.post('/twilio-hook', this.incomingMsg)
|
||||
}
|
||||
|
||||
/**
|
||||
* Puerto del HTTP
|
||||
* @param {*} port default 3000
|
||||
*/
|
||||
start = () => {
|
||||
this.twilioServer.listen(this.twilioPort, () => {
|
||||
console.log(``)
|
||||
console.log(`[Twilio]: Agregar esta url "WHEN A MESSAGE COMES IN"`)
|
||||
console.log(
|
||||
`[Twilio]: POST http://localhost:${this.twilioPort}/twilio-hook`
|
||||
)
|
||||
console.log(`[Twilio]: Más información en la documentacion`)
|
||||
console.log(``)
|
||||
})
|
||||
this.emit('ready')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TwilioWebHookServer
|
||||
5
packages/provider/src/twilio/utils.js
Normal file
5
packages/provider/src/twilio/utils.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const parseNumber = (number) => {
|
||||
return `${number}`.replace('whatsapp:', '').replace('+', '')
|
||||
}
|
||||
|
||||
module.exports = { parseNumber }
|
||||
116
packages/provider/src/venom/index.js
Normal file
116
packages/provider/src/venom/index.js
Normal file
@@ -0,0 +1,116 @@
|
||||
const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
const venom = require('venom-bot')
|
||||
const {
|
||||
venomCleanNumber,
|
||||
venomGenerateImage,
|
||||
venomisValidNumber,
|
||||
} = require('./utils')
|
||||
|
||||
/**
|
||||
* ⚙️ VenomProvider: Es una clase tipo adaptor
|
||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||
* https://github.com/orkestral/venom
|
||||
*/
|
||||
class VenomProvider extends ProviderClass {
|
||||
vendor
|
||||
constructor() {
|
||||
super()
|
||||
this.init().then(() => this.initBusEvents())
|
||||
}
|
||||
|
||||
/**
|
||||
* Iniciamos el Proveedor Venom
|
||||
*/
|
||||
init = async () => {
|
||||
try {
|
||||
const client = await venom.create(
|
||||
{
|
||||
session: 'session-base',
|
||||
multidevice: true,
|
||||
},
|
||||
(base) => this.generateQr(base),
|
||||
undefined,
|
||||
{ logQR: false }
|
||||
)
|
||||
this.vendor = client
|
||||
} catch (e) {
|
||||
this.emit('auth_failure', {
|
||||
instructions: [
|
||||
`Ocurrio un error con la inicializacion de venom`,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
`(Puedes abrir un ISSUE) https://github.com/leifermendez/bot-whatsapp/issues/new/choose`,
|
||||
``,
|
||||
`${e?.message}`,
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generamos QR Code pra escanear con el Whatsapp
|
||||
*/
|
||||
generateQr = (qr) => {
|
||||
console.clear()
|
||||
this.emit('require_action', {
|
||||
instructions: [
|
||||
`Debes escanear el QR Code para iniciar session reivsa qr.png`,
|
||||
`Recuerda que el QR se actualiza cada minuto `,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
})
|
||||
venomGenerateImage(qr)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapeamos los eventos nativos de https://docs.orkestral.io/venom/#/?id=events
|
||||
* para tener un standar de eventos
|
||||
* @returns
|
||||
*/
|
||||
busEvents = () => [
|
||||
{
|
||||
event: 'onMessage',
|
||||
func: (payload) => {
|
||||
if (payload.from === 'status@broadcast') {
|
||||
return
|
||||
}
|
||||
|
||||
if (!venomisValidNumber(payload.from)) {
|
||||
return
|
||||
}
|
||||
payload.from = venomCleanNumber(payload.from, true)
|
||||
this.emit('message', payload)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* Iniciamos y mapeamos el BusEvent
|
||||
* Ejemplo:
|
||||
* this.vendor.onMessage() 👉 this.vendor["onMessage"]()
|
||||
*/
|
||||
initBusEvents = () => {
|
||||
const listEvents = this.busEvents()
|
||||
|
||||
for (const { event, func } of listEvents) {
|
||||
if (this.vendor[event])
|
||||
this.vendor[event]((payload) => func(payload))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar mensaje al usuario
|
||||
* @param {*} userId
|
||||
* @param {*} message
|
||||
* @param {*} param2
|
||||
* @returns
|
||||
*/
|
||||
sendMessage = async (userId, message, { options }) => {
|
||||
const number = venomCleanNumber(userId)
|
||||
if (options?.buttons?.length)
|
||||
return this.sendButtons(number, message, options.buttons)
|
||||
if (options?.media) return this.sendMedia(number, options.media)
|
||||
return this.vendor.sendText(number, message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VenomProvider
|
||||
36
packages/provider/src/venom/utils.js
Normal file
36
packages/provider/src/venom/utils.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { writeFile } = require('fs')
|
||||
|
||||
const venomCleanNumber = (number, full = false) => {
|
||||
number = number.replace('@c.us', '')
|
||||
number = !full ? `${number}@c.us` : `${number}`
|
||||
return number
|
||||
}
|
||||
|
||||
const venomGenerateImage = (base) => {
|
||||
const matches = base.match(/^data:([A-Za-z-+\/]+);base64,(.+)$/)
|
||||
if (matches.length !== 3) {
|
||||
return new Error('Invalid input string')
|
||||
}
|
||||
|
||||
let response = {}
|
||||
response.type = matches[1]
|
||||
response.data = new Buffer.from(matches[2], 'base64')
|
||||
|
||||
var imageBuffer = response
|
||||
writeFile(
|
||||
`${process.cwd()}/qr.png`,
|
||||
imageBuffer['data'],
|
||||
'binary',
|
||||
(err) => {
|
||||
if (err != null) throw new Error('ERROR_QR_GENERATE')
|
||||
return
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const venomisValidNumber = (rawNumber) => {
|
||||
const regexGroup = /\@g.us\b/gm
|
||||
const exist = rawNumber.match(regexGroup)
|
||||
return !exist
|
||||
}
|
||||
module.exports = { venomCleanNumber, venomGenerateImage, venomisValidNumber }
|
||||
@@ -1,13 +1,23 @@
|
||||
const { Client, LocalAuth } = require('whatsapp-web.js')
|
||||
const { Client, LocalAuth, MessageMedia, Buttons } = require('whatsapp-web.js')
|
||||
const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
const { Console } = require('console')
|
||||
const { createWriteStream } = require('fs')
|
||||
const { cleanNumber, generateImage, isValidNumber } = require('./utils')
|
||||
const {
|
||||
wwebCleanNumber,
|
||||
wwebDownloadMedia,
|
||||
wwebGenerateImage,
|
||||
wwebIsValidNumber,
|
||||
} = require('./utils')
|
||||
|
||||
const logger = new Console({
|
||||
stdout: createWriteStream('./log'),
|
||||
})
|
||||
|
||||
/**
|
||||
* ⚙️ WebWhatsappProvider: Es una clase tipo adaptor
|
||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||
* https://github.com/pedroslopez/whatsapp-web.js
|
||||
*/
|
||||
class WebWhatsappProvider extends ProviderClass {
|
||||
vendor
|
||||
constructor() {
|
||||
@@ -22,12 +32,14 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
this.vendor.on(event, func)
|
||||
}
|
||||
|
||||
this.vendor.emit('preinit')
|
||||
this.vendor.initialize().catch((e) => {
|
||||
logger.log(e)
|
||||
this.emit('require_action', {
|
||||
instructions: [
|
||||
`Debes eliminar la carpeta .wwebjs_auth`,
|
||||
`y reiniciar nuevamente el bot `,
|
||||
`(Opcion 1): Debes eliminar la carpeta .wwebjs_auth y reiniciar nuevamente el bot. `,
|
||||
`(Opcion 2): Intenta actualizar el paquete [npm install whatsapp-web.js] `,
|
||||
`(Opcion 3): Ir FORO de discord https://link.codigoencasa.com/DISCORD `,
|
||||
],
|
||||
})
|
||||
})
|
||||
@@ -48,22 +60,18 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
func: (qr) => {
|
||||
this.emit('require_action', {
|
||||
instructions: [
|
||||
`Debes escanear el QR Code para iniciar session reivsa qr.svg`,
|
||||
`Debes escanear el QR Code para iniciar session reivsa qr.png`,
|
||||
`Recuerda que el QR se actualiza cada minuto `,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
})
|
||||
generateImage(qr)
|
||||
wwebGenerateImage(qr)
|
||||
},
|
||||
},
|
||||
{
|
||||
event: 'ready',
|
||||
func: () => this.emit('ready', true),
|
||||
},
|
||||
{
|
||||
event: 'authenticated',
|
||||
func: () => this.emit('ready', true),
|
||||
},
|
||||
{
|
||||
event: 'message',
|
||||
func: (payload) => {
|
||||
@@ -71,19 +79,96 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
return
|
||||
}
|
||||
|
||||
if (!isValidNumber(payload.from)) {
|
||||
if (!wwebIsValidNumber(payload.from)) {
|
||||
return
|
||||
}
|
||||
payload.from = cleanNumber(payload.from, true)
|
||||
payload.from = wwebCleanNumber(payload.from, true)
|
||||
this.emit('message', payload)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
sendMessage = async (userId, message) => {
|
||||
const number = cleanNumber(userId)
|
||||
/**
|
||||
* Enviar un archivo multimedia
|
||||
* https://docs.wwebjs.dev/MessageMedia.html
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @returns
|
||||
*/
|
||||
sendMedia = async (number, mediaInput = null) => {
|
||||
if (!mediaInput) throw new Error(`NO_SE_ENCONTRO: ${mediaInput}`)
|
||||
const fileDownloaded = await wwebDownloadMedia(mediaInput)
|
||||
const media = MessageMedia.fromFilePath(fileDownloaded)
|
||||
return this.vendor.sendMessage(number, media, {
|
||||
sendAudioAsVoice: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar botones
|
||||
* https://docs.wwebjs.dev/Buttons.html
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} message
|
||||
* @param {*} buttons []
|
||||
* @returns
|
||||
*/
|
||||
sendButtons = async (number, message, buttons = []) => {
|
||||
const buttonMessage = new Buttons(message, buttons, '', '')
|
||||
return this.vendor.sendMessage(number, buttonMessage)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar lista
|
||||
* https://docs.wwebjs.dev/List.html
|
||||
* @private
|
||||
* @alpha No funciona en whatsapp bussines
|
||||
* @param {*} number
|
||||
* @param {*} message
|
||||
* @param {*} buttons []
|
||||
* @returns
|
||||
*/
|
||||
// sendList = async (number, message, listInput = []) => {
|
||||
// let sections = [
|
||||
// {
|
||||
// title: 'sectionTitle',
|
||||
// rows: [
|
||||
// { title: 'ListItem1', description: 'desc' },
|
||||
// { title: 'ListItem2' },
|
||||
// ],
|
||||
// },
|
||||
// ]
|
||||
// let list = new List('List body', 'btnText', sections, 'Title', 'footer')
|
||||
// return this.vendor.sendMessage(number, list)
|
||||
// }
|
||||
|
||||
/**
|
||||
* Enviar un mensaje solo texto
|
||||
* https://docs.wwebjs.dev/Message.html
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
sendText = async (number, message) => {
|
||||
return this.vendor.sendMessage(number, message)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} userId
|
||||
* @param {*} message
|
||||
* @param {*} param2
|
||||
* @returns
|
||||
*/
|
||||
sendMessage = async (userId, message, { options }) => {
|
||||
const number = wwebCleanNumber(userId)
|
||||
if (options?.buttons?.length)
|
||||
return this.sendButtons(number, message, options.buttons)
|
||||
if (options?.media) return this.sendMedia(number, options.media)
|
||||
return this.sendText(number, message)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = WebWhatsappProvider
|
||||
|
||||
@@ -1,21 +1,58 @@
|
||||
const { createWriteStream } = require('fs')
|
||||
const qr = require('qr-image')
|
||||
const { tmpdir } = require('os')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
|
||||
const cleanNumber = (number, full = false) => {
|
||||
const wwebCleanNumber = (number, full = false) => {
|
||||
number = number.replace('@c.us', '')
|
||||
number = !full ? `${number}@c.us` : `${number}`
|
||||
return number
|
||||
}
|
||||
|
||||
const generateImage = (base64) => {
|
||||
let qr_svg = qr.image(base64, { type: 'svg', margin: 4 })
|
||||
qr_svg.pipe(createWriteStream(`${process.cwd()}/qr.svg`))
|
||||
const wwebGenerateImage = (base64) => {
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 })
|
||||
qr_svg.pipe(createWriteStream(`${process.cwd()}/qr.png`))
|
||||
}
|
||||
|
||||
const isValidNumber = (rawNumber) => {
|
||||
const wwebIsValidNumber = (rawNumber) => {
|
||||
const regexGroup = /\@g.us\b/gm
|
||||
const exist = rawNumber.match(regexGroup)
|
||||
return !exist
|
||||
}
|
||||
|
||||
module.exports = { cleanNumber, generateImage, isValidNumber }
|
||||
/**
|
||||
* Incompleta
|
||||
* Descargar archivo multimedia para enviar
|
||||
* @param {*} url
|
||||
* @returns
|
||||
*/
|
||||
const wwebDownloadMedia = (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const ext = url.split('.').pop()
|
||||
const checkProtocol = url.includes('https:')
|
||||
const handleHttp = checkProtocol ? https : http
|
||||
const name = `tmp-${Date.now()}.${ext}`
|
||||
const fullPath = `${tmpdir()}/${name}`
|
||||
const file = createWriteStream(fullPath)
|
||||
handleHttp.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on('finish', function () {
|
||||
file.close()
|
||||
resolve(fullPath)
|
||||
})
|
||||
file.on('error', function () {
|
||||
console.log('errro')
|
||||
file.close()
|
||||
reject(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
wwebCleanNumber,
|
||||
wwebGenerateImage,
|
||||
wwebIsValidNumber,
|
||||
wwebDownloadMedia,
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ const copyLibPkg = async (pkgName, to) => {
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
copyLibPkg('create-bot-whatsapp', appDir),
|
||||
copyLibPkg('bot', appDir),
|
||||
copyLibPkg('database', appDir),
|
||||
copyLibPkg('provider', appDir),
|
||||
]).then(() => console.log('Todas las lib copiadas'))
|
||||
]).then(() => console.log('Todas las librerías copiadas'))
|
||||
|
||||
167
scripts/release.js
Normal file
167
scripts/release.js
Normal file
@@ -0,0 +1,167 @@
|
||||
const { writeFile, readFileSync } = require('fs')
|
||||
const { join } = require('path')
|
||||
const { execFile } = require('node:child_process')
|
||||
const process = require('node:process')
|
||||
const util = require('node:util')
|
||||
|
||||
const OS_ENVIROMENT_WIN = process.platform.includes('win32')
|
||||
const semver = require('semver')
|
||||
|
||||
const NPM_COMMAND = OS_ENVIROMENT_WIN ? 'npm.cmd' : 'npm'
|
||||
const [PKG_ARG, PKG_ARG_VERSION, NPM_TOKEN] = process.argv.slice(2) || [null]
|
||||
const PATH_PACKAGES = join(__dirname, '..', `packages`)
|
||||
|
||||
const cmd = util.promisify(execFile)
|
||||
|
||||
/**
|
||||
* Create Token
|
||||
*/
|
||||
const npmToken = (token = null) =>
|
||||
new Promise((resolve, reject) => {
|
||||
writeFile(
|
||||
`${process.cwd()}/.npmrc`,
|
||||
`//registry.npmjs.org/:_authToken=${token}`,
|
||||
(error) => {
|
||||
if (error) reject(error)
|
||||
resolve()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* Leer package json
|
||||
* @param {*} packageName
|
||||
* @returns
|
||||
*/
|
||||
const readPackage = (packageName = null) => {
|
||||
const pkgJson = join(PATH_PACKAGES, packageName, 'package.json')
|
||||
const rawFile = readFileSync(pkgJson, 'utf-8')
|
||||
if (!rawFile) throw new Error(`ERROR_FILE_READ`)
|
||||
|
||||
return JSON.parse(rawFile)
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar package json
|
||||
* @param {*} packageName
|
||||
* @param {*} newPkgJson
|
||||
*/
|
||||
const updatePackage = (packageName = null, newPkgJson) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const pkgJson = join(PATH_PACKAGES, packageName, 'package.json')
|
||||
if (!Object.keys(newPkgJson).length) throw new Error(`ERROR_FILE_READ`)
|
||||
writeFile(pkgJson, newPkgJson, (err) => {
|
||||
if (err) reject(err)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Actualizar version
|
||||
* @param {*} packageName
|
||||
*/
|
||||
const updateVersion = async (packageName = null, number = null) => {
|
||||
if (!packageName) throw new Error(`PATH_ERROR_PACKAGE: ${packageName}`)
|
||||
|
||||
const pkgJsonObject = readPackage(packageName)
|
||||
const { version } = pkgJsonObject
|
||||
const newVersion = !number
|
||||
? semver.inc(version, 'prepatch', 'alpha')
|
||||
: `${number}`
|
||||
|
||||
if (!semver.valid(newVersion))
|
||||
throw new Error(`VERSION_ERROR: ${newVersion}`)
|
||||
|
||||
const newPkgJson = JSON.stringify(
|
||||
{ ...pkgJsonObject, version: newVersion },
|
||||
null,
|
||||
2
|
||||
)
|
||||
await updatePackage(packageName, newPkgJson)
|
||||
return { version: newVersion }
|
||||
}
|
||||
|
||||
/**
|
||||
* Revisar si la version nueva existe o no en npmjs
|
||||
* @param {*} packageName
|
||||
* @param {*} version
|
||||
* @returns
|
||||
*/
|
||||
const checkExistVersion = async (packageName = null, version = null) => {
|
||||
try {
|
||||
const pkgJson = join(PATH_PACKAGES, packageName)
|
||||
const pkgJsonObject = readPackage(packageName)
|
||||
const { stdout } = await cmd(
|
||||
NPM_COMMAND,
|
||||
['view', `${pkgJsonObject.name}@${version}`],
|
||||
{
|
||||
stdio: 'inherit',
|
||||
cwd: pkgJson,
|
||||
}
|
||||
)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empaquetar
|
||||
* @param {*} packageName
|
||||
* @returns
|
||||
*/
|
||||
const packRelease = async (packageName) => {
|
||||
const pkgJson = join(PATH_PACKAGES, packageName)
|
||||
const { stdout } = await cmd(NPM_COMMAND, ['pack'], {
|
||||
stdio: 'inherit',
|
||||
cwd: pkgJson,
|
||||
})
|
||||
return stdout
|
||||
}
|
||||
|
||||
/**
|
||||
* Lanzar release
|
||||
* @param {*} packageName
|
||||
* @param {*} latest
|
||||
* @returns
|
||||
*/
|
||||
const publishRelease = async (packageName, latest = null) => {
|
||||
const args = !latest ? ['--tag', 'dev'] : ['--access', 'public']
|
||||
const pkgJson = join(PATH_PACKAGES, packageName)
|
||||
const { stdout } = await cmd(NPM_COMMAND, ['publish'].concat(args), {
|
||||
stdio: 'inherit',
|
||||
cwd: pkgJson,
|
||||
})
|
||||
console.log(stdout)
|
||||
return stdout
|
||||
}
|
||||
|
||||
/**
|
||||
* Recibe los argumentos entrantes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
const main = async () => {
|
||||
if (PKG_ARG) {
|
||||
let EXIST_VERSION = true
|
||||
const tokenNpm = NPM_TOKEN ? NPM_TOKEN.split('=').at(1) : null
|
||||
const pkgName = PKG_ARG ? PKG_ARG.split('=').at(1) : null
|
||||
const pkgNumber = PKG_ARG_VERSION
|
||||
? PKG_ARG_VERSION.split('=').at(1)
|
||||
: null
|
||||
if (tokenNpm) await npmToken(tokenNpm)
|
||||
|
||||
while (EXIST_VERSION) {
|
||||
const { version } = await updateVersion(pkgName, pkgNumber)
|
||||
EXIST_VERSION = await checkExistVersion(pkgName, version)
|
||||
console.log(`[${pkgName} - Version]: `, version, EXIST_VERSION)
|
||||
}
|
||||
await packRelease(pkgName)
|
||||
await publishRelease(pkgName, pkgNumber)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
82
starters/apps/base-bailey-memory/app.js
Normal file
82
starters/apps/base-bailey-memory/app.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
const adapterProvider = createProvider(BaileysProvider)
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
20
starters/apps/base-bailey-memory/package.json
Normal file
20
starters/apps/base-bailey-memory/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bot-whatsapp-base-bailey-memory",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"pre-copy": "cd .. && yarn run copy.lib base-bailey-memory",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"dependencies": {
|
||||
"@adiwajshing/baileys": "^4.4.0",
|
||||
"@bot-whatsapp/bot": "latest",
|
||||
"@bot-whatsapp/cli": "latest",
|
||||
"@bot-whatsapp/database": "latest",
|
||||
"@bot-whatsapp/provider": "latest"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
### BASIC APP
|
||||
### BASE APP
|
||||
|
||||
Este bot contiene un flujo basico en el cual una persona (cliente) escribe **"hola"** y el bot responde.
|
||||
|
||||
|
||||

|
||||
- Bienvenido a mi tienda
|
||||
- Como puedo ayudarte?
|
||||
- Tengo: Zapatos Bolsos etc..
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
82
starters/apps/base-bailey-mongo/app.js
Normal file
82
starters/apps/base-bailey-mongo/app.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
const adapterProvider = createProvider(BaileysProvider)
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
20
starters/apps/base-bailey-mongo/package.json
Normal file
20
starters/apps/base-bailey-mongo/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bot-whatsapp-base-bailey-mongo",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"pre-copy": "cd .. && yarn run copy.lib base-bailey-mongo",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"dependencies": {
|
||||
"@adiwajshing/baileys": "^4.4.0",
|
||||
"@bot-whatsapp/bot": "latest",
|
||||
"@bot-whatsapp/cli": "latest",
|
||||
"@bot-whatsapp/database": "latest",
|
||||
"@bot-whatsapp/provider": "latest"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
12
starters/apps/base-bailey-mysql/README.md
Normal file
12
starters/apps/base-bailey-mysql/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
### BASE APP
|
||||
|
||||
Este bot contiene un flujo basico en el cual una persona (cliente) escribe **"hola"** y el bot responde.
|
||||
- Bienvenido a mi tienda
|
||||
- Como puedo ayudarte?
|
||||
- Tengo: Zapatos Bolsos etc..
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
- [Twitter](https://twitter.com/leifermendez)
|
||||
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
82
starters/apps/base-bailey-mysql/app.js
Normal file
82
starters/apps/base-bailey-mysql/app.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const BaileysProvider = require('@bot-whatsapp/provider/baileys')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
const adapterProvider = createProvider(BaileysProvider)
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
20
starters/apps/base-bailey-mysql/package.json
Normal file
20
starters/apps/base-bailey-mysql/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bot-whatsapp-base-bailey-mysql",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"pre-copy": "cd .. && yarn run copy.lib base-bailey-mysql",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"dependencies": {
|
||||
"@adiwajshing/baileys": "^4.4.0",
|
||||
"@bot-whatsapp/bot": "latest",
|
||||
"@bot-whatsapp/cli": "latest",
|
||||
"@bot-whatsapp/database": "latest",
|
||||
"@bot-whatsapp/provider": "latest"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
12
starters/apps/base-twilio-memory/README.md
Normal file
12
starters/apps/base-twilio-memory/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
### BASE APP
|
||||
|
||||
Este bot contiene un flujo basico en el cual una persona (cliente) escribe **"hola"** y el bot responde.
|
||||
- Bienvenido a mi tienda
|
||||
- Como puedo ayudarte?
|
||||
- Tengo: Zapatos Bolsos etc..
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
- [Twitter](https://twitter.com/leifermendez)
|
||||
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
88
starters/apps/base-twilio-memory/app.js
Normal file
88
starters/apps/base-twilio-memory/app.js
Normal file
@@ -0,0 +1,88 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
|
||||
const adapterProvider = createProvider(TwilioProvider, {
|
||||
accountSid: 'YOUR_ACCOUNT_SID',
|
||||
authToken: 'YOUR_ACCOUNT_TOKEN',
|
||||
vendorNumber: '+14155238886',
|
||||
})
|
||||
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
22
starters/apps/base-twilio-memory/package.json
Normal file
22
starters/apps/base-twilio-memory/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "bot-whatsapp-base-twilio-memory",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"pre-copy": "cd .. && yarn run copy.lib base-twilio-memory",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"polka": "^0.5.2",
|
||||
"twilio": "^3.83.4",
|
||||
"@bot-whatsapp/bot": "latest",
|
||||
"@bot-whatsapp/cli": "latest",
|
||||
"@bot-whatsapp/database": "latest",
|
||||
"@bot-whatsapp/provider": "latest"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
12
starters/apps/base-twilio-mongo/README.md
Normal file
12
starters/apps/base-twilio-mongo/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
### BASE APP
|
||||
|
||||
Este bot contiene un flujo basico en el cual una persona (cliente) escribe **"hola"** y el bot responde.
|
||||
- Bienvenido a mi tienda
|
||||
- Como puedo ayudarte?
|
||||
- Tengo: Zapatos Bolsos etc..
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
- [Twitter](https://twitter.com/leifermendez)
|
||||
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
87
starters/apps/base-twilio-mongo/app.js
Normal file
87
starters/apps/base-twilio-mongo/app.js
Normal file
@@ -0,0 +1,87 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
const adapterProvider = createProvider(TwilioProvider, {
|
||||
accountSid: 'YOUR_ACCOUNT_SID',
|
||||
authToken: 'YOUR_ACCOUNT_TOKEN',
|
||||
vendorNumber: '+14155238886',
|
||||
})
|
||||
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
22
starters/apps/base-twilio-mongo/package.json
Normal file
22
starters/apps/base-twilio-mongo/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "bot-whatsapp-base-twilio-mongo",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"pre-copy": "cd .. && yarn run copy.lib base-twilio-mongo",
|
||||
"start": "node app.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.1",
|
||||
"polka": "^0.5.2",
|
||||
"twilio": "^3.83.4",
|
||||
"@bot-whatsapp/bot": "latest",
|
||||
"@bot-whatsapp/cli": "latest",
|
||||
"@bot-whatsapp/database": "latest",
|
||||
"@bot-whatsapp/provider": "latest"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
12
starters/apps/base-twilio-mysql/README.md
Normal file
12
starters/apps/base-twilio-mysql/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
### BASE APP
|
||||
|
||||
Este bot contiene un flujo basico en el cual una persona (cliente) escribe **"hola"** y el bot responde.
|
||||
- Bienvenido a mi tienda
|
||||
- Como puedo ayudarte?
|
||||
- Tengo: Zapatos Bolsos etc..
|
||||
|
||||
------
|
||||
- [Discord](https://link.codigoencasa.com/DISCORD)
|
||||
- [Twitter](https://twitter.com/leifermendez)
|
||||
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
|
||||
- [Telegram](https://t.me/leifermendez)
|
||||
86
starters/apps/base-twilio-mysql/app.js
Normal file
86
starters/apps/base-twilio-mysql/app.js
Normal file
@@ -0,0 +1,86 @@
|
||||
const {
|
||||
createBot,
|
||||
createProvider,
|
||||
createFlow,
|
||||
addKeyword,
|
||||
addChild,
|
||||
} = require('@bot-whatsapp/bot')
|
||||
|
||||
const TwilioProvider = require('@bot-whatsapp/provider/twilio')
|
||||
const MockAdapter = require('@bot-whatsapp/database/mock')
|
||||
|
||||
/**
|
||||
* Declarando flujo hijo
|
||||
*/
|
||||
|
||||
const flowBolsos2 = addKeyword(['bolsos2', '2'])
|
||||
.addAnswer('🤯 *MUCHOS* bolsos ...')
|
||||
.addAnswer('y mas bolsos... bla bla')
|
||||
|
||||
const flowZapatos2 = addKeyword(['zapatos2', '2'])
|
||||
.addAnswer('🤯 repito que tengo *MUCHOS* zapatos.')
|
||||
.addAnswer('y algunas otras cosas.')
|
||||
|
||||
const flowZapatos = addKeyword(['zapatos', 'ZAPATOS'])
|
||||
.addAnswer('🤯 Veo que elegiste zapatos')
|
||||
.addAnswer('Tengo muchos zapatos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*zapatos2*', 'para mas información'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowZapatos2)]
|
||||
)
|
||||
|
||||
const flowBolsos = addKeyword(['bolsos', 'BOLSOS'])
|
||||
.addAnswer('🙌 Veo que elegiste bolsos')
|
||||
.addAnswer('Tengo muchos bolsos...bla bla')
|
||||
.addAnswer(
|
||||
['Manda:', '*2*', 'o', '*bolsos2*', 'para mas información.'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
},
|
||||
[...addChild(flowBolsos2)]
|
||||
)
|
||||
|
||||
/**
|
||||
* Declarando flujo principal
|
||||
*/
|
||||
const flowPrincipal = addKeyword(['hola', 'ole', 'alo'])
|
||||
.addAnswer('Hola, bienvenido a mi tienda')
|
||||
.addAnswer('Como puedo ayudarte?')
|
||||
.addAnswer(['Tengo:', 'Zapatos', 'Bolsos', 'etc..'])
|
||||
.addAnswer(
|
||||
['Para continuar escribe:', '*Zapatos*', 'o', '*Bolsos*'],
|
||||
{ capture: true },
|
||||
(ctx) => {
|
||||
console.log('Aqui puedes ver más info del usuario...')
|
||||
console.log('Puedes enviar un mail, hook, etc..')
|
||||
console.log(ctx)
|
||||
console.log(ctx['_data']['notifyName'])
|
||||
},
|
||||
[...addChild(flowBolsos), ...addChild(flowZapatos)]
|
||||
)
|
||||
|
||||
const main = async () => {
|
||||
const adapterDB = new MockAdapter()
|
||||
const adapterFlow = createFlow([flowPrincipal])
|
||||
const adapterProvider = createProvider(TwilioProvider, {
|
||||
accountSid: 'YOUR_ACCOUNT_SID',
|
||||
authToken: 'YOUR_ACCOUNT_TOKEN',
|
||||
vendorNumber: '+14155238886',
|
||||
})
|
||||
createBot({
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user