{"id":13431429,"url":"https://github.com/PlayerNeo42/bili-live-api","last_synced_at":"2025-03-16T11:31:39.524Z","repository":{"id":57636847,"uuid":"428565907","full_name":"PlayerNeo42/bili-live-api","owner":"PlayerNeo42","description":"bilibili(B站)直播API调用的Go语言实现","archived":true,"fork":false,"pushed_at":"2022-09-17T10:56:24.000Z","size":73,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-28T11:55:49.523Z","etag":null,"topics":["bilibili","golang","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlayerNeo42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-16T07:56:02.000Z","updated_at":"2024-10-26T13:35:10.000Z","dependencies_parsed_at":"2022-08-30T10:30:55.149Z","dependency_job_id":null,"html_url":"https://github.com/PlayerNeo42/bili-live-api","commit_stats":null,"previous_names":["agentanderson/bili-live-api","playerneo42/bili-live-api","botplayerneo/bili-live-api"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayerNeo42%2Fbili-live-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayerNeo42%2Fbili-live-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayerNeo42%2Fbili-live-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayerNeo42%2Fbili-live-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlayerNeo42","download_url":"https://codeload.github.com/PlayerNeo42/bili-live-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243863059,"owners_count":20360259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bilibili","golang","websocket"],"created_at":"2024-07-31T02:01:03.034Z","updated_at":"2025-03-16T11:31:38.811Z","avatar_url":"https://github.com/PlayerNeo42.png","language":"Go","funding_links":[],"categories":["开发"],"sub_categories":["直播脚本"],"readme":"# B站直播API\n\nB站直播相关API的Go语言实现\n\n目前仅支持直播间弹幕相关API\n\n## 支持\n\n- 礼物\n- 超级留言\n- 弹幕\n- 其他 websocket 事件\n\n详见`dto/`目录下的文件\n\n## 快速开始\n\n### 安装\n\n```shell \ngo get github.com/botplayerneo/bili-live-api\n```\n\n### 使用\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tapi \"github.com/botplayerneo/bili-live-api\"\n\t\"github.com/botplayerneo/bili-live-api/dto\"\n\t\"github.com/botplayerneo/bili-live-api/log\"\n\t\"github.com/botplayerneo/bili-live-api/websocket\"\n)\n\nfunc main() {\n\t// 设置内部 logger 打印日志等级\n\t// 或通过 log.ReplaceDefault(customLogger) 来使用自定义 logger\n\tlog.SetLogLevel(log.LevelWarn)\n\n\t// 参数为房间号\n\tl := api.NewLive(510)\n\n\t// 内部通过 type switch 来判断 handler 类型\n\t// handler 类型定义在 websocket 包中\n\terr := l.RegisterHandlers(\n\t\tdanmakuHandler(),\n\t\tgiftHandler(),\n\t\tguardHandler(),\n\t\tsuperChatHandler(),\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tl.Start()\n}\n\nfunc danmakuHandler() websocket.DanmakuHandler {\n\treturn func(danmaku *dto.Danmaku) {\n\t\tfmt.Printf(\"%s:%s\\n\", danmaku.Uname, danmaku.Content)\n\t}\n}\n\nfunc giftHandler() websocket.GiftHandler {\n\treturn func(gift *dto.Gift) {\n\t\tfmt.Printf(\"%s 赠送 [礼物%.1f￥]%s x %d\\n\", gift.Uname, float64(gift.Price)/1000, gift.GiftName, gift.Num)\n\t}\n}\n\nfunc guardHandler() websocket.GuardHandler {\n\treturn func(guard *dto.Guard) {\n\t\tfmt.Printf(\"%s 开通舰长,级别%d\", guard.Username, guard.GuardLevel)\n\t}\n}\n\nfunc superChatHandler() websocket.SuperChatHandler {\n\treturn func(superChat *dto.SuperChat) {\n\t\tfmt.Printf(\"[%d￥SC]%s:%s\\n\", superChat.Price, superChat.UserInfo.Uname, superChat.Message)\n\t}\n}\n\n```\n\n## 相关\n\n项目组织结构参考: [botgo](https://github.com/tencent-connect/botgo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPlayerNeo42%2Fbili-live-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPlayerNeo42%2Fbili-live-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPlayerNeo42%2Fbili-live-api/lists"}