-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(project): refactored function typing (#49)
* chore(typing): added mobizon package * chore(package): updated version * feat(project): refactored function typing
- Loading branch information
1 parent
c82ac1d
commit fa56ec9
Showing
10 changed files
with
66 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
declare module 'qrcode-terminal'; | ||
declare module 'mobizon-node'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
import { commandDispatcher } from '../utils/CommandDispatcher'; | ||
import { Message } from 'whatsapp-web.js'; | ||
|
||
import EconomyCommand from './EconomyCommand'; | ||
import QuoteCommand from './QuoteCommand'; | ||
import { EconomyCommand } from './EconomyCommand'; | ||
import { QuoteCommand } from './QuoteCommand'; | ||
import CepCommand from './CepCommand'; | ||
import ProfileCommand from './ProfileCommand'; | ||
import SmsCommand from './SmsCommand'; | ||
|
||
export default async (message) => { | ||
const economyCommand = new EconomyCommand(); | ||
const quoteCommand = new QuoteCommand(); | ||
const cepCommand = new CepCommand(message.body); | ||
const profileCommand = new ProfileCommand(message.body); | ||
const smsCommand = new SmsCommand(message.body); | ||
export const CommandHandler = async (message: Message): Promise<void> => { | ||
if (!message.body.startsWith('!')) return; | ||
|
||
await commandDispatcher.register('cotacao', economyCommand); | ||
await commandDispatcher.register('mencionar', quoteCommand); | ||
await commandDispatcher.register('cep', cepCommand); | ||
await commandDispatcher.register('perfil', profileCommand); | ||
await commandDispatcher.register('sms', smsCommand); | ||
await commandDispatcher.register('cotacao', EconomyCommand); | ||
await commandDispatcher.register('mencionar', QuoteCommand); | ||
await commandDispatcher.register('cep', new CepCommand(message.body)); | ||
await commandDispatcher.register('perfil', new ProfileCommand(message.body)); | ||
await commandDispatcher.register('sms', new SmsCommand(message.body)); | ||
|
||
return commandDispatcher.dispatch(message.body.slice(1), message); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
import { client } from './services/whatsapp'; | ||
import type { Message } from 'whatsapp-web.js'; | ||
import dispatchCommand from './app/commands'; | ||
import { CommandHandler } from './app/commands'; | ||
|
||
client.on('message', (message: Message) => { | ||
if (message.body.startsWith('!')) return dispatchCommand(message); | ||
}); | ||
client.on('message_create', CommandHandler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters