File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff 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 - z A - Z 0 - 9 + / ] { 6 } $ / . test ( trip ) ;
Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments