{"id":37144841,"url":"https://github.com/sealdice/sealdice-core","last_synced_at":"2026-01-14T16:59:58.106Z","repository":{"id":119136016,"uuid":"568420229","full_name":"sealdice/sealdice-core","owner":"sealdice","description":"海豹骰核心程序，新一代trpg骰点机器人。轻量易用，功能强大，支持所有主流IM平台，并能在win/linux/mac/android下使用。","archived":false,"fork":false,"pushed_at":"2026-01-10T06:17:50.000Z","size":36021,"stargazers_count":227,"open_issues_count":94,"forks_count":51,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-01-11T01:49:20.704Z","etag":null,"topics":["bot","discord","dodo","kook","minecraft","onebot","sealdice","telegram","trpg","trpg-tool"],"latest_commit_sha":null,"homepage":"https://sealdice.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sealdice.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"custom":["https://dice.weizaima.com/feed"]}},"created_at":"2022-11-20T13:36:13.000Z","updated_at":"2026-01-10T12:49:01.000Z","dependencies_parsed_at":"2023-12-31T13:29:41.111Z","dependency_job_id":"eb68b442-9ae3-4fbb-bd4c-9d5cfa81f770","html_url":"https://github.com/sealdice/sealdice-core","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"purl":"pkg:github/sealdice/sealdice-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sealdice%2Fsealdice-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sealdice%2Fsealdice-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sealdice%2Fsealdice-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sealdice%2Fsealdice-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sealdice","download_url":"https://codeload.github.com/sealdice/sealdice-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sealdice%2Fsealdice-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28427180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T16:38:47.836Z","status":"ssl_error","status_checked_at":"2026-01-14T16:34:59.695Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bot","discord","dodo","kook","minecraft","onebot","sealdice","telegram","trpg","trpg-tool"],"created_at":"2026-01-14T16:59:57.307Z","updated_at":"2026-01-14T16:59:58.101Z","avatar_url":"https://github.com/sealdice.png","language":"Go","funding_links":["https://dice.weizaima.com/feed"],"categories":[],"sub_categories":[],"readme":"# SealDice\n\n![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)\n![Core](https://img.shields.io/badge/SealDice-Core-blue)\n\n海豹 TRPG 骰点核心，开源跑团辅助工具，支持 QQ/Kook/Discord 等。\n\n轻量 · 易用 · 全能\n\n## 文档\n\n见 [使用手册](https://sealdice.github.io/sealdice-manual-next/)。\n\n## SealDice Project\n\n- [核心](https://github.com/sealdice/sealdice-core)（本仓库）：Go 后端代码仓库，也作为海豹的主仓库，Bug 可反馈在该仓库的 issue 中；\n- [UI](https://github.com/sealdice/sealdice-ui)：前端代码，基于 Vue3 + ElementPlus 开发；\n- [手册](https://github.com/sealdice/sealdice-manual-next)：官方手册源码，由 VitePress 驱动；\n- [构建](https://github.com/sealdice/sealdice-build)：自动构建仓库，用于自动化发布海豹的每日构建包与 Release；\n- [Android](https://github.com/sealdice/sealdice-android)：Android 应用源码；\n- ……\n\n注：如无特殊说明，所有代码文件均遵循 MIT 开源协议\n\n## Core 开发环境搭建\n\n### golang 开发环境\n\n编译的 golang 版本为 1.25.0。在 [构建](https://github.com/sealdice/sealdice-build) 仓库中采用对 go 进行修补的方式以支持 Windows 7 等低版本系统。\n\n因部分依赖库的需求，可能需要配置国内镜像，个人使用 \u003chttps://goproxy.cn/\u003e 镜像。\n\n#### 代码格式化\n\n本项目要求所有代码使用 goimports 进行格式化。这一行为已经设定在本项目的编辑器配置文件中。\n\n#### 在本地配置 LINTER\n\n本项目使用 golangci-lint 工具进行静态分析。\n\n此工具对于代码开发**不是**必要的。但是，本项目的 CI 流程中配置了 linter 检查，不符合规范的代码不能被合入。\n\n因此，强烈推荐开发者在本地安装此工具，请参考[这份文档](https://golangci-lint.run/welcome/install/#local-installation)。分析器的相关配置位于 `.golangci.yml` 文件中。\n\n你可能需要调整编辑器的相关配置，使用 golangci-lint 为默认的分析工具，并开启自动检查。\n\n\u003e 对于 Visual Studio Code，列出以下配置项供参考：\n\u003e\n\u003e 1. `go.lintTool` 选择 golangci-lint\n\u003e 2. `go.lintFlags` 添加一项 `--fast`\n\u003e 3. `go.lintOnSave` **不能**选择 file，因为只分析单个文件会导致无法正确解析符号引用\n\u003e\n\u003e 以上配置没有写入项目的统一设置，以允许开发者不本地使用 golangci-lint\n\n### 编译运行\n\n#### 使用 `go-task`\n\n你可以安装 [go-task](https://taskfile.dev/installation) 以执行预置好的任务。安装后可执行：\n\n```bash\n# 初次编译运行（包括安装依赖和相关工具）\ntask install run \n\n# 后续编译运行\ntask run\n```\n\n#### 手动执行\n\n你也可以按照以下步骤手动进行编译运行：\n\n##### 拉取代码并配置数据文件\n\n使用 git 拉取项目代码\n\n从已发布的海豹二进制包中，解压 `data`、`lagrange` 两个目录到代码目录下。\n\n同时需要在项目的 `static/frontend` 下放置用于打包进 core 的 ui 静态资源文件，可手动提供，也可通过命令自动从 github 拉取：\n\n```bash\ngo generate ./...\n```\n\n放置静态资源大致如下：\n\n```text\nstatic\n│\n└─frontend\n   │  CNAME\n   │  favicon.svg\n   │  index.html\n   │\n   └─assets\n```\n\n##### 运行编译命令\n\n打开项目，或使用终端访问项目目录，运行：\n\n```bash\ngo mod download\ngo install github.com/pointlander/peg@v1.0.1\ngo build\n```\n\n或者直接使用：\n\n```shell\ngo run .\n```\n\n启动项目，大功告成！\n\n## 重点\n\n### 从哪开始看\n\n从 `main.go` 开始，这里海豹分出了几个线程，一个启动核心并提供服务，另一个提供 ui 的 http 服务。\n\n可以顺藤摸瓜了解海豹如何启动，如何提供服务，如何响应指令。指令响应的部分写在 `im_session.go` 中\n\n注意有部分代码还在构思中，实际并未使用，例如 `CharacterTemplate`，请阅读时先 Find Usage 加以区分\n\n### 重要数据结构\n\n`dice.go` 中的 `Dice` 结构体存放着各种核心配置，每个 `Dice` 实例是一个骰子，而每个骰子下面可以挂靠多个端点 (EndPoint)。端点即交互渠道，例如一个 QQ 账号是一个端点。\n\n所有的端点由 `IMSession` 来统一管理，同样的，这个类也负责接收和分发指令。\n\n可能你会注意到有 `IMSession` 和 `IMSessionLegacy`，只看前一个就行，`IMSessionLegacy` 对应的是 0.99.13 的上古版本之前的数据结构，仅用于升级配置文件。\n\n`GroupInfo` 是群组信息\n\n`GroupPlayerInfo` 是玩家信息\n\n### 为海豹添加更多平台支持\n\n海豹使用叫做 `PlatformAdapter` 的接口来接入平台，只需将接口全部实现，再创建一个 `EndPointInfo` 塞入当前用户的 `IMSession` 对象之中即可。\n\n注：每次在 UI 上添加 QQ 账号，其实就是创建了一个 `EndPointInfo` 对象，并制定 Adapter 为 `PlatformAdapterQQOnebot`\n\n目前实现的两个 adapter，一个对应 onebot 协议，主要用于 QQ，另一个对应 http，用于 UI 后台的测试窗口。\n\n观察 `PlatformAdapterHttp` 如何运作起来是一个很好的切入点，因为他非常简单。\n\n### 改动扩展模块，如 dnd5e，coc7 等\n\n对应 `dice/ext_xxx.go` 系列文件\n\n推荐从 `ext_template.go` 入手，以 `ext_dnd5e.go` 为参考，因为这个模块书写时间较晚，相对较为完善。\n\n### 暂不建议修改的地方\n\n#### 表达式解析器\n\n`dice/roll.peg` 是海豹的骰点指令文法文件\n\n`dice/rollvm.go` 是骰点指令虚拟机\n\n1.5 后，已经替换使用 dicescript (RollVM V2) 作为表达式解释器，现有版本不宜轻动。\n\n关于 dicescript 的信息，请移步 \u003chttps://github.com/sealdice/dicescript\u003e\n\n而出于兼容性的考虑，V1 版本的解释器将继续保留，直到 2.0 版本。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsealdice%2Fsealdice-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsealdice%2Fsealdice-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsealdice%2Fsealdice-core/lists"}