From 22ec7c6741c9348f510c93634fe1abd8f00b4ca5 Mon Sep 17 00:00:00 2001 From: LamGC Date: Mon, 1 Mar 2021 09:08:48 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=20Framework-API=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E6=A0=87=E5=87=86=E5=8C=96=20Platform=20Enum?= =?UTF-8?q?,=20=E6=B7=BB=E5=8A=A0=E6=A0=87=E5=87=86=E5=8C=96=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BF=A1=E6=81=AF=E6=96=87=E6=A1=A3;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Add] Platform.Standard 添加私有内置的标准化 Platform 枚举类(已添加部分平台信息); [Add] Framework-API/StandardPlatform.md 添加标准化平台信息文档(用于参考或者直接使用, 帮助统一平台信息); --- .../StandardPlatform.md | 11 +++++ .../net/lamgc/cgj/bot/framework/Platform.java | 41 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 ContentGrabbingJi-framework-api/StandardPlatform.md diff --git a/ContentGrabbingJi-framework-api/StandardPlatform.md b/ContentGrabbingJi-framework-api/StandardPlatform.md new file mode 100644 index 0000000..3bd7496 --- /dev/null +++ b/ContentGrabbingJi-framework-api/StandardPlatform.md @@ -0,0 +1,11 @@ +# 由官方标准化的平台信息 + +在此定义了部分平台的平台名与标识信息,可作为参考。 + +Platform Name | Platform Identify +--- | --- +Tencent QQ | QQ +Tencent WeChat | WeChat +Discord | Discord +Telegram | Telegram +OneBot Http API | OneBot diff --git a/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/Platform.java b/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/Platform.java index 61db241..58496c2 100644 --- a/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/Platform.java +++ b/ContentGrabbingJi-framework-api/src/main/java/net/lamgc/cgj/bot/framework/Platform.java @@ -28,6 +28,9 @@ import java.util.Objects; *

{@link #platformIdentify PlatformIdentify} * 遵循 Camel-Case (骆峰命名法, 每个单词之间无空格, 单词首字母大写), * 对于平台标识由少量字母组成的则全大写(例如腾讯QQ的平台标识则为 'QQ' 而不是 'qq' 或 'Qq'). + * + *

希望各框架组件开发者能够遵循以上规则, 如出现平台识别信息混乱的情况, 不排除会有将 Platform 枚举化(固定 Platform 类型)的情况. + * * @author LamGC */ public final class Platform { @@ -86,4 +89,42 @@ public final class Platform { public int hashCode() { return Objects.hash(platformIdentify); } + + /** + * 标准化平台信息. + *

暂不公开, 仅用于 Platform 实例唯一化. + */ + private enum Standard { + /** + * 腾讯 QQ + */ + Tencent_QQ(new Platform("Tencent QQ", "QQ")), + /** + * 腾讯微信 + */ + Tencent_WeChat(new Platform("Tencent WeChat", "WeChat")), + /** + * Telegram(电报) + */ + Telegram(new Platform("Telegram", "Telegram")), + /**. + * Discord + */ + Discord(new Platform("Discord", "Discord")), + /** + * OneBot + */ + OneBot(new Platform("OneBot Http API", "OneBot")) + ; + private final Platform platform; + + Standard(Platform platform) { + this.platform = platform; + } + + public Platform getPlatform() { + return platform; + } + } + }