Comparing version 1.2.0 to 1.2.1
23
cli.js
@@ -5,10 +5,13 @@ #!/usr/bin/env node | ||
const input = require("input") | ||
const { startSession, eventEmitter } = require("./dist/index.cjs") | ||
const dotenv = require("dotenv") | ||
const { Api, startSession, eventEmitter } = require("./dist/index.cjs") | ||
dotenv.config() | ||
/** | ||
* Setting default API_ID and API_HASH from public data on github | ||
* Setting fallback API_ID and API_HASH from public data on github | ||
* https://github.com/zhukov/webogram/blob/master/app/js/lib/config.js | ||
*/ | ||
const API_ID = 2496 | ||
const API_HASH = "8da85b0d5bfe62527e5b244c209159c3" | ||
const API_ID = _.toNumber(process.env.API_ID || 2496) | ||
const API_HASH = _.toString(process.env.API_HASH || "8da85b0d5bfe62527e5b244c209159c3") | ||
@@ -31,4 +34,16 @@ eventEmitter | ||
}) | ||
.on("RequiresFirstAndLastNames", async (firstAndLastNamesEmitter) => { | ||
const firstName = await input.text("Enter first name :") | ||
const lastName = await input.text("Enter last name :") | ||
firstAndLastNamesEmitter(firstName, lastName) | ||
}) | ||
startSession({ apiId: API_ID, apiHash: API_HASH }) | ||
.then((client) => { | ||
return client.invoke(new Api.users.GetUsers({ id: [new Api.InputUserSelf()] })) | ||
}) | ||
.then(([{ firstName }]) => { | ||
console.log("🖐️ Hi", firstName) | ||
console.log("Currently, you are listening to 'UpdateShortMessage' events ...") | ||
}) | ||
.then(() => { | ||
@@ -35,0 +50,0 @@ eventEmitter.on("UpdateShortMessage", (event) => { |
{ | ||
"name": "plaintl", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A plain telegram listener", | ||
@@ -16,3 +16,4 @@ "main": "./src/index.mjs", | ||
"scripts": { | ||
"rollup": "rollup --config" | ||
"dev": "rollup --config --watch", | ||
"build": "rollup --config" | ||
}, | ||
@@ -19,0 +20,0 @@ "keywords": [ |
@@ -47,3 +47,3 @@ # PlainTL | ||
> For receive phone code via SMS set `apiForceSMS` to **_true_**. | ||
> For receive phone code via SMS set `forceSMS` to **_true_**. | ||
@@ -59,3 +59,3 @@ > For `logLevel`, one can select between **_error_** , **_warn_** , **_info_** , **_debug_** or **_none_**. | ||
/* optional */ | ||
apiForceSMS: false, | ||
forceSMS: false, | ||
logLevel: "info", | ||
@@ -69,7 +69,7 @@ } | ||
// async | ||
await startSession(providerParameters) | ||
const client = await startSession(providerParameters) | ||
// sync | ||
startSession(providerParameters).then(() => { | ||
// eventEmitter | ||
startSession(providerParameters).then((client) => { | ||
// | ||
}) | ||
@@ -76,0 +76,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60833
239
15