Skip to content

Commit e80aaf9

Browse files
author
cmd1152
committed
:(
1 parent 6411a1c commit e80aaf9

File tree

2 files changed

+36
-91
lines changed

2 files changed

+36
-91
lines changed

HackChat-BotLib.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff 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-zA-Z0-9+/]{6}$/.test(trip);
158+
}
159+
isHash(hash) {
160+
return /^[a-zA-Z0-9+/]{15}$/.test(hash);
161+
}
162+
isNick(nick) {
163+
return /^[a-zA-Z0-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

159189
module.exports = Client

index.js

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)