Skip to content

Commit

Permalink
Fix video sending, fix optional parameters on create
Browse files Browse the repository at this point in the history
danielcardeenas committed Apr 9, 2020

Partially verified

This commit is signed with the committer’s verified signature.
spydon’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent d806028 commit 3c85195
Showing 7 changed files with 40 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ session
session-*
app.js
app.ts
app2.js
gohan.jpg
006.png
src/app.ts
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "sulla",
"version": "2.3.4",
"version": "2.3.6",
"description": "Javascript whatsapp framework",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"start": "tsc && node dist/app.js",
"start": "tsc app.ts && node app.js",
"build": "npm run build:wapi && npm run build:middleware && npm run build:jsQR && tsc",
"build:sulla": "tsc",
"build:wapi": "cd src/lib/wapi/ && webpack",
@@ -59,16 +59,16 @@
},
"homepage": "https://github.com/danielcardeenas/sulla#readme",
"devDependencies": {
"@types/node": "^13.11.0",
"@types/node": "^13.11.1",
"@types/puppeteer": "^2.0.1",
"@types/sharp": "^0.24.0",
"auto-changelog": "^1.16.4",
"concurrently": "^5.1.0",
"copy-webpack-plugin": "^5.1.1",
"gulp": "^4.0.2",
"husky": "^4.2.3",
"nodemon": "^2.0.2",
"prettier": "^2.0.2",
"husky": "^4.2.4",
"nodemon": "^2.0.3",
"prettier": "^2.0.4",
"pretty-quick": "^2.0.1",
"release-it": "^13.5.2",
"ts-loader": "^6.2.2",
22 changes: 16 additions & 6 deletions src/controllers/browser.ts
Original file line number Diff line number Diff line change
@@ -45,12 +45,10 @@ async function initBrowser(
extras = {}
) {
if (options.useChrome) {
try {
const chromeInstalations = ChromeLauncher.Launcher.getInstallations();
if (chromeInstalations.length) {
extras = { ...extras, executablePath: chromeInstalations[0] };
}
} catch (error) {
const chromePath = getChrome();
if (chromePath) {
extras = { ...extras, executablePath: chromePath };
} else {
console.log('Chrome not found, using chromium');
extras = {};
}
@@ -75,3 +73,15 @@ async function getWhatsappPage(browser: Browser) {
console.assert(pages.length > 0);
return pages[0];
}

/**
* Retrieves chrome instance path
*/
function getChrome() {
try {
const chromeInstalations = ChromeLauncher.Launcher.getInstallations();
return chromeInstalations[0];
} catch (error) {
return undefined;
}
}
10 changes: 6 additions & 4 deletions src/controllers/initializer.ts
Original file line number Diff line number Diff line change
@@ -12,15 +12,17 @@ const spinner = ora();
export async function create(
session = 'session',
catchQR?: (qrCode: string) => void,
options: CreateConfig = {
options?: CreateConfig
) {
const defaultOptions: CreateConfig = {
headless: true,
devtools: false,
useChrome: true,
debug: false,
}
) {
};

spinner.start('Initializing whatsapp');
let waPage = await initWhatsapp(session, options);
let waPage = await initWhatsapp(session, { ...defaultOptions, ...options });
spinner.succeed();

spinner.start('Authenticating');
8 changes: 5 additions & 3 deletions src/lib/wapi/webpack.config.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,10 @@ const path = require('path');

module.exports = {
entry: './wapi.js',
// mode: 'development',
// devtool: 'source-map',
output: {
path: path.resolve(__dirname, '../../../dist/lib/wapi'),
filename: 'wapi.js'
}
};
filename: 'wapi.js',
},
};
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
"outDir": "./dist" /* Redirect output structure to the directory. */,
// "rootDir": "./src/", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
"removeComments": true /* Do not emit comments to output. */
"removeComments": false /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
@@ -57,5 +57,5 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": ["src/**/*"],
"exclude": ["src/middleware/middleware.ts", "src/api/app.ts", "img/*"]
"exclude": ["src/middleware/middleware.ts", "img/*"]
}

0 comments on commit 3c85195

Please sign in to comment.