Overview
v2
is the new major version of bilibili-danmaku-client
, not compatible with the previous v1.x
versions, with many improvements and changes.
The README file is recommended for first-time users. For those migrating from v1.x
, see below.
Migration Guide
To migrate from v1.x
to v2.0
, the following API are facing a breaking change:
Creating a new DanmakuClient
Previously you write:
const client = new DanmakuClient({ room: 5440 });
While now you should write:
const client = new DanmakuClient(5440);
The first parameter is no longer an object, but a number describing the Live Room id.
Listening to events
Previously you write:
client.on('danmaku', ({ content, sender }) => console.log(`${sender.name}: ${content}`));
client.on('gift', ({ sender, giftName, num }) => console.log(`${sender.name} => ${giftName} * ${num}`));
While now you should write:
const onDanmaku = ({ content, sender }) => console.log(`${sender.name}: ${content}`);
const onGift = ({ sender, gift, num }) => console.log(`${sender.name} => ${gift.name} * ${num}`));
client.on('event', ({ name, content }) => {
switch (name) {
case 'danmaku': onDanmaku(content); break;
case 'gift': onGift(content); break;
}
}
That is, you must listen to event
event instead of the name of the event itself. See Wiki for details.
And you might have noticed, that the giftName
, giftId
and several other properties no longer exist in the gift
event. That is because we've further improved readability and uniformity of the events. For further docmentation, see Wiki.
Changelog
- Rewritten code completely. Now the code should be more elegant, more readable, and more robust.
- Added detailed in-code documentation for all code files.
- Added an integration test file at
test.js
. Use it as an example or an demonstration. - Added detailed documentation in project Wiki.
- Decoupled code and improved coherence.
- Added CI and automatic code review support.
- Added babel support. Now the code should be running on all ES5-compatible platforms. (under
@babel/polyfill
) - Added a bunch of Wiki pages and improve README.
- Added more tests to make the project more robust.
- Added a bunch of new transformers so that the package is more powerful.
- Fixed a great deal of bugs.
See commit history for a complete list of changes.
A few words
Now that bilibili-danmaku-client
has released its version 2.0, the development will be slowing down since no future release is planned at this time. Coming changes will only contain bug fixes, new transformers and small improvements like typo or documentation.
Github-related templates will be added soon, and users are welcome to add new issue, give PRs, leave comments, etc.. bilibili-danmaku-client
will always be there to listen to you!