Skip to content

Commit 8b9f731

Browse files
committed
fix: adjust qr code refresh interval
1 parent 50e7a3f commit 8b9f731

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

example/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ const main = async () => {
1717
qrcode.generate(value, { small: true })
1818
})
1919

20-
gtc.on('logged', (logged) => {
20+
gtc.on('logged', async (logged) => {
2121
if (logged) {
2222
console.log('logged')
23+
24+
const tags = await gtc.find('ID', '6283861415641') // just random phone number
25+
console.log(tags)
2326
} else {
2427
console.log('scan qr code first')
2528
}
@@ -30,9 +33,6 @@ const main = async () => {
3033
})
3134

3235
await gtc.init()
33-
34-
const tags = await gtc.find('ID', '6283861415641') // just random phone number
35-
console.log(tags)
3636
}
3737

3838
main()

src/gtc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Gtc extends EventEmitter {
4141
async #getHash() {
4242
const result = await this.#http.get(this.#base_url).then((res) => res.data)
4343
const before = result.match(/hash: '([a-fA-F0-9]+)'/)
44-
const after = result.match(/<input type="hidden" name="hash" value="([^"]+)"\/>/)
44+
const after = result.match(/<input type="hidden" name="hash" value="([a-fA-F0-9]+)"\/>/)
4545

4646
if (before) {
4747
this.#isLogged = false
@@ -83,7 +83,7 @@ class Gtc extends EventEmitter {
8383
return new Promise((resolve) => {
8484
const timeout = setTimeout(async () => {
8585
await this.#getQr()
86-
}, 100_000)
86+
}, 20_000)
8787

8888
this.on('logged', (logged) => {
8989
if (logged) {

0 commit comments

Comments
 (0)