{"id":21242292,"url":"https://github.com/fortescarlet/catcode2","last_synced_at":"2025-07-10T20:31:22.794Z","repository":{"id":57987698,"uuid":"524688126","full_name":"ForteScarlet/CatCode2","owner":"ForteScarlet","description":"猫猫码，一个可爱的通用特殊码，CQ码的精神延续。/ Cat code, the spirit of CQ code continues, a cute universal special code.","archived":false,"fork":false,"pushed_at":"2023-05-21T06:35:43.000Z","size":207,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-06T22:11:43.840Z","etag":null,"topics":["catcode","cq","kotlin","kotlin-multiplatform","kotlin-serialization","kotlinx-serialization-library","simbot"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/ForteScarlet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-14T14:03:25.000Z","updated_at":"2024-04-08T06:46:49.000Z","dependencies_parsed_at":"2024-09-02T22:01:27.652Z","dependency_job_id":"7cf0b6e6-2c95-431c-931d-8c4f52cb4b27","html_url":"https://github.com/ForteScarlet/CatCode2","commit_stats":{"total_commits":94,"total_committers":2,"mean_commits":47.0,"dds":"0.010638297872340385","last_synced_commit":"520c9177a76a25f33daaf2f3519097c2acc31361"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/ForteScarlet/CatCode2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2FCatCode2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2FCatCode2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2FCatCode2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2FCatCode2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForteScarlet","download_url":"https://codeload.github.com/ForteScarlet/CatCode2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForteScarlet%2FCatCode2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264652672,"owners_count":23644306,"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":["catcode","cq","kotlin","kotlin-multiplatform","kotlin-serialization","kotlinx-serialization-library","simbot"],"created_at":"2024-11-21T00:58:58.776Z","updated_at":"2025-07-10T20:31:21.269Z","avatar_url":"https://github.com/ForteScarlet.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./.catcode2/logo.png\" alt=\"catcode logo\"/\u003e\n    \u003ch3\u003e\n        - 😺 CatCode Ⅱ 😺 -\n    \u003c/h3\u003e\n    \u003cspan\u003e\n        \u003ca href=\"https://github.com/ForteScarlet/CatCode2\" target=\"_blank\"\u003egithub\u003c/a\u003e\n    \u003c/span\u003e \n    \u0026nbsp;\u0026nbsp; | \u0026nbsp;\u0026nbsp;\n    \u003cspan\u003e\n        \u003ca href=\"https://gitee.com/ForteScarlet/CatCode2\" target=\"_blank\"\u003egitee\u003c/a\u003e\n    \u003c/span\u003e \u003cbr /\u003e\n    \u003csmall\u003e \u0026gt; 感谢 \u003ca href=\"https://github.com/ForteScarlet/simpler-robot\" target=\"_blank\"\u003eSimple Robot\u003c/a\u003e 开发团队成员制作的猫猫logo \u0026lt; \u003c/small\u003e \u003cbr /\u003e\n    \u0026gt; 如果有点击一下⭐的话，猫猫会很开心哦~ \u0026lt; \u003cbr /\u003e\n    \u003ca href=\"https://repo1.maven.org/maven2/love/forte/catcode2/\" target=\"_blank\" \u003e\n        \u003cimg src=\"https://img.shields.io/maven-central/v/love.forte.catcode2/catcode2-core\" alt=\"maven-central\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@catcode2/core\" target=\"_blank\" \u003e\n            \u003cimg src=\"https://img.shields.io/npm/v/@catcode2/core/latest\" alt=\"catcode2/core-latest\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.npmjs.com/package/@catcode2/core\" target=\"_blank\" \u003e\n        \u003cimg src=\"https://img.shields.io/npm/v/@catcode2/core/snapshot\" alt=\"catcode2/core-snapshot\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n*****\n\n\u003cdiv align=\"center\"\u003e\n    \u003ch3\u003e\n        猫猫码（Cat Code），一个可爱的通用特殊码，CQ码的精神延续。\n    \u003c/h3\u003e\n\u003c/div\u003e   \n\n\u003e \u003csmall\u003e\u003ci\u003eCatCode1前往 [CatCode](https://github.com/ForteScarlet/CatCode) 查看。\u003c/i\u003e\u003c/small\u003e\n\n猫猫码是一个具有特定格式的字符串格式编码，它看上去是这个样子的 👉 `[CAT:xxx,param1=value1,param2=value2]`\n\n- 以`[`开头，`]`结尾。\n- 首先是猫猫码的头标识(大小写数字或下划线，标准应为`CAT`)\n- 头标识后是猫猫码的类型(大小写数字或下划线)，与头标识之间使用冒号`:`分割。\n- 参数为多个key不重复的键值对，一对参数使用`=`连接键与值，多对参数使用`,`分割。\n- 可以没有参数。\n- 区分大小写。\n\n### **猫猫是严格的。**\n\n为了避免混淆整个存在猫猫码的文本中不允许出现：`[`、`]`、`\u0026`\n字符和制表符与换行符，猫猫码文本内中除了上述字符外，还不允许出现 `,` 与 `=` 字符。\n因此，猫猫码的转义规则为：\n\n| 源    | 转       |\n|------|---------|\n| `\u0026`  | `\u0026amp;` |\n| `[`  | `\u0026#91;` |\n| `]`  | `\u0026#93;` |\n| `,`  | `\u0026#44;` |\n| `=`  | `\u0026#61;` |\n| `\\n` | `\u0026#13;` |\n| `\\r` | `\u0026#10;` |\n| `\\t` | `\u0026#09;` |\n\n\n### **猫猫是包容的。**\n\n任何符合规则 `[HEAD:type,param=value,param=value,...]` 的特殊码均可以视为猫猫码，尽管 `HEAD` 可能并不是 `CAT`。\n\n### **猫猫是无处不在的。**\n\n**CatCode2** 核心库基于 [**Kotlin Multiplatform**](https://kotlinlang.org/docs/multiplatform.html) 支持多平台（JVM、JS、Native），\n并且 **CatCode2** 提供了基于 [**kotlinx-serialization**](https://github.com/Kotlin/kotlinx.serialization) 的多平台序列化模块支持，\n你可以借助 **kotlinx-serialization** 来自定义结构来描述你的猫猫码、序列化/反序列化你的猫猫码。\n\n## 应用\n\n### [核心库](catcode2-core)\n\n[核心库](catcode2-core) 提供了针对猫猫码字符串的解析、读写与封装的核心基础功能，是最主要也是最基本的模块。\n\n\u003e **Note**\n\u003e \n\u003e 👉 **前往 [核心库模块](catcode2-core) 获取更多信息。**\n\n### [序列化库](catcode2-serialization)\n\n**CatCode2** 提供了一些允许通过实体类作为载体来对猫猫码进行描述的模块，\n例如对 [**kotlinx-serialization**](https://github.com/Kotlin/kotlinx.serialization) 的实现。\n\n\u003e **Note**\n\u003e \n\u003e 👉 **前往 [序列化模块](catcode2-serialization) 获取更多信息。**\n\n\n## 速览\n\n```kotlin\nwalkCatCodeContinuously(\n    \"[CAT:code,k1=v1,name=forte,tar=foo]\",\n    true,\n    { head: String -\u003e println(\"head = $head\") },\n    { type: String -\u003e println(\"type = $type\") }\n) { key: String, value: String -\u003e println(\"$key: $value\") }\n```\n\n```kotlin\nval cat = catOf(\"[CAT:at,code=123]\")\n\ncat.code\ncat.toCode(\"CQ\")\ncat.head\ncat.type\ncat.keys\n\nval code: Int by cat.provider.int\n```\n\n```kotlin\nval cat = buildCat(\"foo\", \"CAT\") {\n    \"key\" - \"value\"\n    set(\"foo\", \"bar\", false)\n    this[\"age\"] = \"18\"\n    key(\"name\") value \"forte\"\n}\n\nval catCode = buildCatLiteral(\"foo\") {\n    \"key\" - \"value\"\n    set(\"foo\", \"bar\", false)\n    this[\"age\"] = \"18\"\n    key(\"name\") value \"forte\"\n}\n```\n\n\n```kotlin\n@Serializable\n@SerialName(\"at\") // or use @CatCodeTypeName(\"at\")\ndata class At(val code: Long, val name: String)\n\nfun sample() {\n    val at = At(123456L, \"forte\")\n    val catcode = CatCode.encodeToString(At.serializer(), at)\n    val newAt = CatCode.decodeFromString(At.serializer(), catcode)\n    \n    // ...\n}\n```\n\n## LICENSE\n\n[MIT LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortescarlet%2Fcatcode2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortescarlet%2Fcatcode2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortescarlet%2Fcatcode2/lists"}