diff options
author | Keuin <[email protected]> | 2022-02-04 22:54:22 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-02-04 22:54:22 +0800 |
commit | dfa163e5a3cffa46f0241210f2c8be1f8e298d7a (patch) | |
tree | 72db589d79bcc3bbca45c3a34a6dac71b2f55526 /README_zh_CN.md | |
parent | 12ddbba66e6f2585e59d05d1782c0e8ce9fe6146 (diff) |
Add psmb support.
Diffstat (limited to 'README_zh_CN.md')
-rw-r--r-- | README_zh_CN.md | 208 |
1 files changed, 117 insertions, 91 deletions
diff --git a/README_zh_CN.md b/README_zh_CN.md index dc756c4..dcfb90c 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -2,16 +2,11 @@ CrossLink 的目的是连接Minecraft群组服务器和即时通讯软件。 -CrossLink 将每个子服务器的聊天窗口视为独立的端点,将每个即时通讯软件的群聊也视为独立的端点。 -服务器管理员编写配置文件,描述消息将如何在这些端点之间互相转发,从而让玩家无论在哪个子服务器 -或者哪个即时通讯软件里,都可以在一起聊天。 - -路由策略可根据需求灵活配置。由于 CrossLink 的代码完全不关心消息该从哪出现、又要被发送到哪里, -因此转发操作可被用户完全控制。用户将`按来源过滤`、`按内容过滤`、`字符串替换`、`丢弃`、`转发` -这些**基本操作(action)** 组合成为**路由规则(rule)**,有限个路由规则的有序排列形成**路由表**。 -CrossLink 按照路由表转发消息,基本操作的组合可实现自由而强大的消息转发,从而 -提供高度定制化的 Minecraft 群组服务器消息互联方案。 +CrossLink 将每个子服务器的聊天窗口视为独立的端点,将每个即时通讯软件的群聊也视为独立的端点。 服务器管理员编写配置文件,描述消息将如何在这些端点之间互相转发,从而让玩家无论在哪个子服务器 或者哪个即时通讯软件里,都可以在一起聊天。 +路由策略可根据需求灵活配置。由于 CrossLink 的代码完全不关心消息该从哪出现、又要被发送到哪里, 因此转发操作可被用户完全控制。用户将`按来源过滤`、`按内容过滤`、`字符串替换`、`丢弃`、`转发` +这些**基本操作(action)** 组合成为**路由规则(rule)**,有限个路由规则的有序排列形成**路由表**。 CrossLink 按照路由表转发消息,基本操作的组合可实现自由而强大的消息转发,从而 提供高度定制化的 +Minecraft 群组服务器消息互联方案。 # 运行环境 @@ -35,95 +30,125 @@ CrossLink 按照路由表转发消息,基本操作的组合可实现自由而� ```json5 { - "remotes": [ + "remotes": [ + { + "type": "telegram", + // this endpoint is identified with "remote:Telegram" + "id": "Telegram", + // default: true, if set to false, this remote will be ignored + "enabled": true, + // Telegram Bot token + "token": "======SECRET======", + // repeat to and from this chat + "chat_id": 123456789, + // connect to Telegram API using this proxy + "proxy": "socks://127.0.0.1:10809", + // url to custom Telegram API + "api": "https://my-telegram-api.com" + }, + { + "type": "psmb", + // this endpoint is identified as "remote:mypsmb" + "id": "mypsmb", + // but it creates zero or one or more than one sub "virtual" endpoints + "enabled": true, + "host": "1.onesmp.org", + "port": 3456, + // messages sent to this endpoint will be published to the psmb topic whose id is 'subscribe_to' + "publish_to": "chat_mc", + // messages from topics matched by this pattern will be present on this endpoint + "subscribe_from": "chat_im*", + // the unique subscription client id required by psmb protocol + "subscriber_id": 1314, + // send keep alive packet in every 20 seconds + // if the value is ignored or not positive, keepalive will be disabled + "keepalive": 20000 + }, + { + // not implemented yet, may be added in future version + "type": "json-rpc", + "id": "rpc", + "enabled": true, + "listen": ["127.0.0.1", 8008], + "methods": { + "get": "getMessage", + "put": "sendMessage" + } + } + ], + "routing": [ + // all rules are processed sequentially + // a message may match multiple rules and thus may be duplicate in your case + // if the message is dropped in an action in one rule, + // (the action type is just "drop" and it does not have any argument) + // all subsequent rules will NOT see this message + { + // inbound chat messages (remote -> all servers) + "object": "chat_message", + // match chat messages + "from": "remote:.*", + // regexp matching source, + // only messages with matched source will be + // processed by this rule, otherwise this rule is skipped + "actions": [ + // actions run sequentially { - "type": "telegram", - "id": "Telegram", // this endpoint is identified with "remote:Telegram" - "enabled": true, // default: true, if set to false, this remote will be ignored - "token": "======SECRET======", // Telegram Bot token - "chat_id": 123456789, // repeat to and from this chat - "proxy": "socks://127.0.0.1:10809", // connect to Telegram API using this proxy - "api": "https://my-telegram-api.com" // url to custom Telegram API + "type": "format", + "color": "green" }, - { - "type": "psmb", // psmb is a special case, since it is not an endpoint - "id": "mypsmb", // this stub endpoint is identified with "remote:mypsmb" - "enabled": true, // but it creates zero or one or more than one sub "virtual" endpoints - "host": "1.onesmp.org", - "port": 3456, - "subscribe_to": "chat_.+", // psmb subscription pattern - // for example: if you have topic chat_1 and chat_2 - // then they are identified with "remote:mypsmb:chat_1" and "remote:mypsmb:chat_2" - // dispatching messages from "remote:mypsmb" to virtual endpoints - // such as "remote:mypsmb:chat_1", is done by psmb stub endpoint - "topics": [ // all topics this endpoint can actually "see" - "chat_qq", // regexp in "subscribe_to" and action route "to" - "chat_wechat" // will only match endpoints declared in this list - ] - }, - { - "type": "json-rpc", - "id": "rpc", - "enabled": true, - "listen": ["127.0.0.1", 8008], - "methods": { - "get": "getMessage", - "put": "sendMessage" - } - } - ], - "routing": [ - // all rules are processed sequentially - // a message may match multiple rules and thus may be duplicate in your case - // if the message is dropped in an action in one rule, - // (the action type is just "drop" and it does not have any argument) - // all subsequent rules will NOT see this message { - // inbound chat messages (remote -> all servers) - "object": "chat_message", // match chat messages - "from": "remote:.*", // regexp matching source, - // only messages with matched source will be - // processed by this rule, otherwise this rule is skipped - "actions": [{ - "type": "format", - "color": "green" - }, { // actions run sequentially - "type": "route", // route this message to matched destinations - "to": "server:.*" // regexp matching destination - }] + // route this message to matched destinations + "type": "route", + // the regexp matching destinations + "to": "server:.*" + } + ] + }, + { + // outbound messages (starting with '#', server -> all remotes) + "object": "chat_message", + "from": "server:.*", + "actions": [ + { + // filter the message using given regexp + // if the message does not match given pattern, + // it won't be passed into subsequent actions + "type": "filter", + // match all messages starts with char '#' + "pattern": "#.+" }, { - // outbound messages (starting with '#', server -> all remotes) - "object": "chat_message", - "from": "server:.*", - "actions": [{ - "type": "filter", // filter the message using given regexp - // if the message does not match given pattern, - // it won't be passed into subsequent actions - "pattern": "#.+" // match all messages starts with char '#' - }, { - "type": "replace", // replace the message, removing heading '#' - "from": "^#(.*)", // capture all chars after the heading '#' - "to": "$1" // and make them as the output - }, { - "type": "route", // send the message to all remotes - "to": "remote:.*" - }] + // replace the message + "type": "replace", + // removing heading '#' capture all chars after the heading '#' + // and make them as the output + "from": "^#(.*)", + "to": "$1" }, { - // cross-server messages (server -> all other servers) - "object": "chat_message", - "from": "server:.*", - "actions": [{ - "type": "route", - "to": "server:.*", - "backflow": false // do not repeat to sender, true by default - // since the destination pattern will match the source, - // we have to set backflow to false to prevent - // players from seeing duplicate messages - }] + // send the message to all remotes + "type": "route", + "to": "remote:.*" + } + ] + }, + { + // cross-server messages (server -> all other servers) + "object": "chat_message", + "from": "server:.*", + "actions": [ + { + "type": "route", + "to": "server:.*", + // do not repeat to sender, true by default + // since the destination pattern will match the source, + // setting backflow to false will prevent + // players from seeing duplicate messages + "backflow": false } - ] + ] + } + ] } ``` @@ -152,4 +177,5 @@ CrossLink 基于许多开源组件,这些开源组件的许可协议和声明� - [adventure](https://github.com/KyoriPowered/adventure) - [jackson-core](https://github.com/FasterXML/jackson-core) - [gson](https://github.com/google/gson) -- [java-telegram-bot-api](https://github.com/pengrad/java-telegram-bot-api)
\ No newline at end of file +- [java-telegram-bot-api](https://github.com/pengrad/java-telegram-bot-api) +- [bson](https://mvnrepository.com/artifact/org.mongodb/bson)
\ No newline at end of file |