0.7.1 • Published 12 months ago

ac-danmu v0.7.1

Weekly downloads
30
License
GPLv3
Repository
github
Last release
12 months ago

ac-danmu.js

简介

ac-danmu.js是一个用于获取acfun直播弹幕的服务端js组件

  • 因为使用了buffer所以不能运行在浏览器环境下, 编写使用node v12 lts

可实现

  • Promise化的使用方式
  • 事件化的使用流程

使用方式

见example

const AcClient = require("ac-danmu")

//使用init(主播房间号)初始化客户端
AcClient("8500263").then((ac_client,{
    login:ture ,//default false
    userinfo: {username:"something",password:"something"} || [{username:"something",password:"something"}]//输入多组用户,每次重连会随机一个
}) => {
    //启动websocket连接
    ac_client.wsStart();
    ac_client.on("enter", () => {
        console.log("Enter room success!");
    });
    ac_client.on("recent-comment", (commmnets) => {
        //获得建立连接当前的弹幕列表
        console.log(commmnets);
    });
    ac_client.on("danmaku", (danmaku) => {
        //收到的弹幕
        console.log(danmaku);
    });
});

或者

const AcClient = require("ac-danmu")

//使用init(主播房间号)初始化客户端
ac_client = await AcClient("8500263")
//启动websocket连接
ac_client.wsStart();
ac_client.on("enter", () => {
    console.log("Enter room success!");
});
ac_client.on("recent-comment", (commmnets) => {
    //获得建立连接当前的弹幕列表
    console.log(commmnets);
});
ac_client.on("danmaku", (danmaku) => {
    //收到的弹幕
    console.log(danmaku);
});

收到的弹幕返回如下

{
    content: '晚安',
    sendTimeMs: Long {
        low: -1921110048,
        high: 372,
        unsigned: false
    },
    userInfo: ZtLiveUserInfo {
        avatar: [
            [ImageCdnNode]
        ],
        userId: Long {
            low: 147764,
            high: 0,
            unsigned: false
        },
        nickname: 'NNK',
        badge: '{"medalInfo":{"uperId":100001,"userId":100001,"clubName":"蓝钻","level":100}}',
        userIdentity: ZtLiveUserIdentity {}
    }
}

事件列表

事件触发payload类型
banana有人发送了香蕉AcfunActionSignalThrowBanana
danmaku当直播中任意用户发送弹幕产生CommonActionSignalComment
enter程序进入直播间null
follow有人关注了主播CommonActionSignalUserFollowAuthor
gift有人发送礼物CommonActionSignalGift
live-info当前直播间数据状态CommonStateSignalDisplayInfo
redpack-info不知道CommonStateSignalCurrentRedpackList
recent-comment当前弹幕列表CommonActionSignalComment[]
topuser-info前几名用户的数据CommonStateSignalTopUsers
user-enter用户进入直播间CommonActionSignalUserEnterRoom
join-club用户加入主播守护团AcfunActionSignalJoinClub

安装

npm i ac-danmu --save

0.6.10

12 months ago

0.6.11

12 months ago

0.6.3

12 months ago

0.7.1

12 months ago

0.6.4

12 months ago

0.7.0

12 months ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago