Skip to content

Commit

Permalink
chore(packages): update and refact commands (#85)
Browse files Browse the repository at this point in the history
* chore(package): update

* chore(commands): refact

* chore(version): bump version 0.6.5
  • Loading branch information
caioagiani authored Jun 18, 2022
1 parent 26fa855 commit f497c42
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: install node v12
uses: actions/setup-node@v3
with:
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "whatsapp-web-bot",
"main": "src/index.ts",
"description": "WhatsApp Bot",
"version": "0.6.1",
"version": "0.6.5",
"license": "MIT",
"keywords": [
"whatsapp",
Expand Down Expand Up @@ -50,25 +50,25 @@
"dev": "tsnd --respawn --transpile-only --ignore-watch node_modules -r dotenv/config src/index.ts"
},
"dependencies": {
"axios": "^0.26.0",
"mobizon-node": "^0.4.3",
"axios": "^0.27.0",
"mobizon-node": "^0.5.0",
"node-base64-image": "^2.0.1",
"qrcode-terminal": "^0.12.0",
"whatsapp-web.js": "^1.16.1"
"whatsapp-web.js": "^1.16.7"
},
"devDependencies": {
"@types/node": "16.11.26",
"@types/node": "16.11.41",
"@types/qrcode": "1.4.2",
"@types/qrcode-terminal": "0.12.0",
"@typescript-eslint/eslint-plugin": "5.12.1",
"@typescript-eslint/parser": "5.12.1",
"dotenv": "16.0.0",
"eslint": "8.10.0",
"eslint-config-prettier": "8.4.0",
"@typescript-eslint/eslint-plugin": "5.28.0",
"@typescript-eslint/parser": "5.28.0",
"dotenv": "16.0.1",
"eslint": "8.18.0",
"eslint-config-prettier": "8.5.0",
"eslint-loader": "4.0.2",
"eslint-plugin-prettier": "4.0.0",
"prettier": "2.5.1",
"prettier": "2.7.1",
"ts-node-dev": "1.1.8",
"typescript": "4.5.5"
"typescript": "4.7.4"
}
}
2 changes: 1 addition & 1 deletion src/app/commands/CepCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import type { Message } from 'whatsapp-web.js';

export default class EconomyCommand {
cep: string;

constructor(cep: string) {
this.cep = cep;
}

async execute(msg: Message): Promise<Message> {
const [_, setCep] = this.cep.split(' ');

const chat = await msg.getChat();

await chat.sendStateTyping();
Expand Down
1 change: 1 addition & 0 deletions src/app/commands/ProfileCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Message } from 'whatsapp-web.js';

export default class ProfileCommand {
mention: string;

constructor(mention: string) {
this.mention = mention;
}
Expand Down
30 changes: 14 additions & 16 deletions src/app/commands/QuoteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,24 @@ export const QuoteCommand = {
return msg.reply('Comando apenas para grupos!');
}

company.forEach(async ({ numero, admin }): Promise<Message> => {
if (numero !== contato) return;
const allowPermissions = company.filter(
({ numero, admin }) => numero === contato && admin,
);

if (!admin) {
return msg.reply(
'Ops, você não tem permissão para executar este comando!',
);
}
if (!allowPermissions.length) {
return msg.reply('Você não tem permissão para usar este comando!');
}

const mentions = [];

let text = '';
const mentions = [];
for (const participant of chat.participants) {
const contact = await client.getContactById(participant.id._serialized);

for (const participant of chat.participants) {
const contact = await client.getContactById(participant.id._serialized);
mentions.push(contact);
}

mentions.push(contact);
text += `@${participant.id.user} `;
}
const names = mentions.map((mention) => `@${mention.number}`).join(' ');

return chat.sendMessage(text, { mentions });
});
return chat.sendMessage(names, { mentions });
},
};
1 change: 1 addition & 0 deletions src/app/commands/SmsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mobizon from '../../services/mobizon';

export default class ProfileCommand {
mention: string;

constructor(mention: string) {
this.mention = mention;
}
Expand Down
1 change: 0 additions & 1 deletion src/app/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { commandDispatcher } from '../utils/CommandDispatcher';
import { Message } from 'whatsapp-web.js';

import { EconomyCommand } from './EconomyCommand';
import { QuoteCommand } from './QuoteCommand';
import CepCommand from './CepCommand';
Expand Down

0 comments on commit f497c42

Please sign in to comment.