Skip to content

Commit d83255d

Browse files
author
cmd1152
committed
:(
1 parent 6f866d7 commit d83255d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

HackChat-BotLib.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class Client {
150150
})
151151
}
152152
getcustomId() {
153-
return customId.toString();
154-
customId += 1;
153+
return this.customId.toString();
154+
this.customId += 1;
155155
}
156156
isTrip(trip) {
157157
return /^[a-zA-Z0-9+/]{6}$/.test(trip);

test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
let Client = require("./HackChat-BotLib.js");
2+
let client = new Client("wss://hack.chat/chat-ws");
3+
let join_channel = "your-channel";
4+
5+
client.onjoin = () => {
6+
client.join({ //发送加入数据包
7+
channel: join_channel,
8+
nick: 'my_bot',
9+
password: '123456'
10+
})
11+
//也可以读取 client.joined 判断有没有加入频道
12+
}
13+
14+
client.onmessage = (raw, json) => {
15+
console.log(json);
16+
}
17+
18+
client.onjoined = () => {
19+
client.chat("Hello, world!");
20+
let id = client.getcustomId();
21+
client.chat("UpdateMessage Test",id);
22+
setTimeout(()=>{
23+
client.updatemessage(id,'overwrite','good')
24+
},3000);
25+
console.log("加入成功");
26+
}
27+
28+
client.ping = 10000;
29+

0 commit comments

Comments
 (0)