Skip to content

Commit

Permalink
add comma after username to communicate with unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinptt0323 committed Sep 30, 2017
1 parent f83943d commit ff8ffda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sites/ptt/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class Bot extends EventEmitter {

async login(username, password) {
if (this._state.login) return;
await this.send(`${username}${key.Enter}${password}${key.Enter}`);
username = username.replace(/,/g, '');
await this.send(`${username},${key.Enter}${password}${key.Enter}`);
let ret;
while ((ret = await this._checkLogin()) === null) {
await sleep(400);
Expand Down
11 changes: 11 additions & 0 deletions test/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,16 @@ describe('Connection', () => {
});
});
});
it('should login success with correct username (w/ trailing comma) and password', () => {
const ptt = new pttbot();
return new Promise((resolve, reject) => {
ptt.once('connect', () => {
ptt.login(username + ',', password)
.then(ret => assert.strictEqual(ret, true))
.then(resolve)
.catch(reject);
});
});
});
});
});

0 comments on commit ff8ffda

Please sign in to comment.