Bladeren bron

Remove deprecated "input" with "readline" from README.md (#658)

input library is deprecated and doesn't work for input anymore.
https://github.com/gram-js/gramjs/issues/657
chinmay 1 jaar geleden
bovenliggende
commit
a969d6cfd9
1 gewijzigde bestanden met toevoegingen van 17 en 10 verwijderingen
  1. 17 10
      README.md

+ 17 - 10
README.md

@@ -15,12 +15,6 @@ Install GramJS:
 $ npm i telegram
 ```
 
-Install [input package](https://www.npmjs.com/package/input), we'll use it to prompt ourselves inside terminal for login information:
-
-```bash
-$ npm i input
-```
-
 After installation, you'll need to obtain an API ID and hash:
 
 1. Login into your [telegram account](https://my.telegram.org/)
@@ -36,22 +30,35 @@ Then run this code to send a message to yourself.
 ```javascript
 import { TelegramClient } from "telegram";
 import { StringSession } from "telegram/sessions";
-import input from "input";
+import readline from "readline";
 
 const apiId = 123456;
 const apiHash = "123456abcdfg";
 const stringSession = new StringSession(""); // fill this later with the value from session.save()
 
+const rl = readline.createInterface({
+  input: process.stdin,
+  output: process.stdout,
+});
+
 (async () => {
   console.log("Loading interactive example...");
   const client = new TelegramClient(stringSession, apiId, apiHash, {
     connectionRetries: 5,
   });
   await client.start({
-    phoneNumber: async () => await input.text("Please enter your number: "),
-    password: async () => await input.text("Please enter your password: "),
+    phoneNumber: async () =>
+      new Promise((resolve) =>
+        rl.question("Please enter your number: ", resolve)
+      ),
+    password: async () =>
+      new Promise((resolve) =>
+        rl.question("Please enter your password: ", resolve)
+      ),
     phoneCode: async () =>
-      await input.text("Please enter the code you received: "),
+      new Promise((resolve) =>
+        rl.question("Please enter the code you received: ", resolve)
+      ),
     onError: (err) => console.log(err),
   });
   console.log("You should now be connected.");