Coder Social home page Coder Social logo

bilibili-ws's Introduction

bilibili-ws

自助 b 站弹幕服务器连接器 主程序负责保持与弹幕服务器的连接和解析弹幕数据,其他功能由插件提供。

自动加载 plugins 文件夹下的 js 文件,插件导出一个类,所有插件在程序启动时进行初始化,传入一个 ebus,ebus 目前只有一个 cmd 事件。

示例插件

module.exports = class Example {
  static disable = false; // 是否禁用插件
  constructor(ebus) {
    ebus.on("cmd", ({ message, roomInfo }) => {
      // message
      // 结构因cmd不同而有所差别
      /**
       * {
       *    cmd: '',
       *    data?: '',
       *    info?: ''
       * }
       */
      // roomInfo
      // 该消息来自的房间信息
      /**
       * {
       *  roomid: '9389401', // 来自config
       *  meta: {},// 来自config
       *  nickname: '時雨羽衣Official'// 自动根据roomid获取
       *  _roomid: 9389401, // 用户填写的roomid可能是短id,这个必定是长id
       *  masterid: 主播uid
       * }
       */
      switch (message.cmd) {
        case "WELCOME":
          console.log(
            `欢迎${message.data.uname}进入${roomInfo.nickanme}的房间`
          );
          break;
        default:
          console.log(message);
      }
    });
  }
};

bilibili-ws's People

Contributors

kooritea avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

xlsqwg

bilibili-ws's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.