1
0
Эх сурвалжийг харах

update example to use precompiled library

painor 5 жил өмнө
parent
commit
8a2fcc5803

+ 18 - 15
examples/simpleLogin.html

@@ -17,24 +17,27 @@
 </head>
 
 <body>
-    <form>
-        <div id="phoneDiv">
-            <label>phone number</label> <input disabled type="text" id="phone"> <button type="button" disabled id="phoneSend">Send</button>
-        </div>
-        <div id="codeDiv" style="visibility: hidden;">
-            <label>code you recieved</label> <input type="text" id="code"> <button type="button" id="codeSend">Send</button>
-        </div>
-        <div id="passDiv" style="visibility: hidden;">
-            <label>password</label> <input type="text" id="pass"> <button type="button" id="passSend">Send</button>
-        </div>
-        <div id="log-container">
-            <pre id="log"></pre>
-        </div>
+<form>
+    <div id="phoneDiv">
+        <label>phone number</label> <input disabled type="text" id="phone">
+        <button type="button" disabled id="phoneSend">Send</button>
+    </div>
+    <div id="codeDiv" style="visibility: hidden;">
+        <label>code you recieved</label> <input type="text" id="code">
+        <button type="button" id="codeSend">Send</button>
+    </div>
+    <div id="passDiv" style="visibility: hidden;">
+        <label>password</label> <input type="text" id="pass">
+        <button type="button" id="passSend">Send</button>
+    </div>
+    <div id="log-container">
+        <pre id="log"></pre>
+    </div>
 
 
-    </form>
+</form>
 </body>
-<script src="../browser/gramjs.js"></script>
+<script src="https://painor.dev/gramjs.js?version=0.0.2"></script>
 <!--Loading the library-->
 <script src="betterLogging.js"></script>
 <!--beautifies the ouput (this rewrites console.log)-->

+ 6 - 3
examples/simpleLogin.js

@@ -56,10 +56,10 @@ function codeCallback() {
 
 const { TelegramClient } = gramjs
 const { StringSession } = gramjs.session
-const apiId = // put your api id here
-const apiHash = // put your api hash here
+const apiId = // put your api id here [for example 123456789]
+const apiHash = // put your api hash here [for example '123456abcfghe']
 
-const client = new TelegramClient(new StringSession(''), apiId, apiHash)
+const client = new TelegramClient(new StringSession(''), apiId, apiHash) // you can pass a string session here from previous logins.
 // If you want to run this example in the test servers uncomment this line
 //client.session.setDC(2, '149.154.167.40', 80)
 
@@ -69,6 +69,9 @@ client.start({
     code: codeCallback,
 }).then(() => {
     console.log('%c you should now be connected', 'color:#B54128')
+    console.log('%c your string session is ' + client.save(), 'color:#B54128')
+    console.log('%c you can save it to login with it next time', 'color:#B54128')
+
 })