-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
45 lines (39 loc) 路 1.06 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { get } from "https";
const token = "";
class DeadInside {
private timer?: NodeJS.Timer;
private number = 1000;
constructor(
private readonly token: string,
private readonly interval = 2 * 1000
) {}
start() {
this.stop();
this.createTimer();
console.log("The cycle has started");
}
private createTimer() {
this.timer = setInterval(() => {
try {
if (this.number < 0) this.number = 1000;
const status = `${this.number} - 7 = ${this.number - 7}`;
get(
`https://api.vk.com/method/status.set?text=${status}&access_token=${this.token}&v=5.81`,
(response) => {
if (response.statusCode !== 200)
throw new Error("The response code is not 200");
console.log(`${this.number} - 7 = ${this.number - 7}`);
}
);
this.number -= 7;
} catch (e) {
this.stop();
}
}, this.interval);
}
stop() {
if (this.timer) clearInterval(this.timer);
console.log("Cycle stopped");
}
}
new DeadInside(token).start();