File tree Expand file tree Collapse file tree 2 files changed +36
-91
lines changed
Expand file tree Collapse file tree 2 files changed +36
-91
lines changed Original file line number Diff line number Diff line change @@ -117,12 +117,10 @@ class Client {
117117 this . customId = 0 ;
118118 }
119119 join ( pack ) {
120- return new Promise ( resolve => {
121- if ( this . _ws . readyState !== 1 ) resolve ( false ) ; //连接没有打开,加入失败
122- pack . cmd = "join" ;
123- this . channel = pack . channel ;
124- this . _send ( pack ) ;
125- } )
120+ if ( this . _ws . readyState !== 1 ) return false ; //连接没有打开,加入失败
121+ pack . cmd = "join" ;
122+ this . channel = pack . channel ;
123+ this . _send ( pack ) ;
126124 }
127125 _send ( obj ) {
128126 this . _ws . send ( JSON . stringify ( obj ) ) ;
@@ -136,6 +134,7 @@ class Client {
136134 cmd : 'chat' ,
137135 text : text
138136 }
137+ if ( this . channel == "purgatory" ) pack . cmd == "emote" ;
139138 if ( custom_id ) pack . customId = custom_id ;
140139 this . _send ( pack ) ;
141140 return true ;
@@ -154,6 +153,37 @@ class Client {
154153 return customId . toString ( ) ;
155154 customId += 1 ;
156155 }
156+ isTrip ( trip ) {
157+ return / ^ [ a - z A - Z 0 - 9 + / ] { 6 } $ / . test ( trip ) ;
158+ }
159+ isHash ( hash ) {
160+ return / ^ [ a - z A - Z 0 - 9 + / ] { 15 } $ / . test ( hash ) ;
161+ }
162+ isNick ( nick ) {
163+ return / ^ [ a - z A - Z 0 - 9 _ ] { 1 , 24 } $ / . test ( nick ) ;
164+ }
165+ selTrip ( trip ) {
166+ return this . users . filter ( ( user ) => {
167+ return user . trip == trip ;
168+ } ) || [ ]
169+ }
170+ selHash ( hash ) {
171+ return this . users . filter ( ( user ) => {
172+ return user . hash == hash ;
173+ } ) || [ ]
174+ }
175+ selNick ( nick ) {
176+ return this . users . find ( ( user ) => {
177+ return user . nick == nick ;
178+ } )
179+ }
180+ whisper ( to , text ) {
181+ this . _send ( {
182+ cmd : 'whisper' ,
183+ nick : to ,
184+ text : text
185+ } )
186+ }
157187}
158188
159189module . exports = Client
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments