diff --git a/Lagrange.OneBot/Core/Login/LoginService.cs b/Lagrange.OneBot/Core/Login/LoginService.cs index 5e715fa08..9114f4699 100644 --- a/Lagrange.OneBot/Core/Login/LoginService.cs +++ b/Lagrange.OneBot/Core/Login/LoginService.cs @@ -47,6 +47,8 @@ public async Task StartAsync(CancellationToken token) { (string Url, byte[] QrCode)? qrcode = await _lagrange.FetchQrCode().WaitAsync(token); if (!qrcode.HasValue) return false; + + await File.WriteAllBytesAsync($"qr-{configuration["Account:Uin"]}.png", qrcode.Value.QrCode, token); QrCodeHelper.Output(qrcode.Value.Url, _isCompatibility); return await (Task)_lagrange.LoginByQrCode(token); diff --git a/Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs b/Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs index d0dc7a1c7..33478f2e8 100644 --- a/Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs +++ b/Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs @@ -90,7 +90,7 @@ public static HostApplicationBuilder ConfigureOneBot(this HostApplicationBuilder LiteDbUtility.IMessageEntityDeserialize ); - string path = configuration["ConfigPath:Database"] ?? "lagrange.db"; + string path = configuration["ConfigPath:Database"] ?? $"lagrange-{configuration["Account:Uin"]}.db"; bool isFirstCreate = false; if (!File.Exists(path)) isFirstCreate = true; diff --git a/Lagrange.OneBot/Resources/appsettings.json b/Lagrange.OneBot/Resources/appsettings.json index 6e138431c..8a3f016bf 100644 --- a/Lagrange.OneBot/Resources/appsettings.json +++ b/Lagrange.OneBot/Resources/appsettings.json @@ -11,7 +11,6 @@ "MusicSignServerUrl": "", "Account": { "Uin": 0, - "Password": "", "Protocol": "Linux", "AutoReconnect": true, "GetOptimumServer": true diff --git a/README.md b/README.md index c76281e40..e47cc55e4 100644 --- a/README.md +++ b/README.md @@ -72,20 +72,20 @@ Thanks for 外国热心网友 for Provision of Azure Servlet | Protocol | Support | Login | Support | Messages | Support | Operations | Support | Events | Support | | -------- | :-----: | ------------------------- | :-----: | :-------- | :-----: | :---------------- | :-----: | :------------------ | :-----: | -| Windows | 🟢 | QrCode | 🟢 | Images | 🟢 | Poke | 🟢 | Captcha | 🟢 | -| macOS | 🟢 | Password | 🟢 | Text / At | 🟢 | Recall | 🟢 | BotOnline | 🟢 | +| Windows | 🟢 | QrCode | 🟢 | Images | 🟢 | Poke | 🟢 | Captcha | 🟢 | +| macOS | 🟢 | Password | 🔴 | Text / At | 🟢 | Recall | 🟢 | BotOnline | 🟢 | | Linux | 🟢 | EasyLogin | 🟢 | Records | 🟢 | Leave Group | 🟢 | BotOffline | 🟢 | -| | | UnusalDevice
Password | 🔴 | QFace | 🟢 | Set Special Title | 🟢 | Message | 🟢 | -| | | UnusalDevice
Easy | 🟢 | Json | 🟢 | Kick Member | 🟢 | Poke | 🟢 | -| | | NewDeviceVerify | 🟢 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🟢 | -| | | | | Forward | 🟢 | Set Admin | 🟢 | GroupMemberDecrease | 🟢 | -| | | | | Video | 🟢 | Friend Request | 🟢 | GroupMemberIncrease | 🟢 | -| | | | | Reply | 🟢 | Group Request | 🟢 | GroupPromoteAdmin | 🟢 | -| | | | | File | 🟢 | ~~Voice Call~~ | 🔴 | GroupInvite | 🟢 | -| | | | | Poke | 🟢 | Client Key | 🟢 | GroupRequestJoin | 🟢 | -| | | | | LightApp | 🟢 | Cookies | 🟢 | FriendRequest | 🟢 | -| | | | | | | Send Message | 🟢 | ~~FriendTyping~~ | 🔴 | -| | | | | | | | | ~~FriendVoiceCall~~ | 🔴 | +| | | UnusalDevice
Password | 🔴 | QFace | 🟢 | Set Special Title | 🟢 | Message | 🟢 | +| | | UnusalDevice
Easy | 🟢 | Json | 🟢 | Kick Member | 🟢 | Poke | 🟢 | +| | | NewDeviceVerify | 🔴 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🟢 | +| | | | | Forward | 🟢 | Set Admin | 🟢 | GroupMemberDecrease | 🟢 | +| | | | | Video | 🟢 | Friend Request | 🟢 | GroupMemberIncrease | 🟢 | +| | | | | Reply | 🟢 | Group Request | 🟢 | GroupPromoteAdmin | 🟢 | +| | | | | File | 🟢 | ~~Voice Call~~ | 🔴 | GroupInvite | 🟢 | +| | | | | Poke | 🟢 | Client Key | 🟢 | GroupRequestJoin | 🟢 | +| | | | | LightApp | 🟢 | Cookies | 🟢 | FriendRequest | 🟢 | +| | | | | | | Send Message | 🟢 | ~~FriendTyping~~ | 🔴 | +| | | | | | | | | ~~FriendVoiceCall~~ | 🔴 | ## Lagrange.OneBot @@ -144,7 +144,7 @@ Thanks for 外国热心网友 for Provision of Azure Servlet API | API | Support | -|--------------------------------| :-----: | +| ------------------------------ | :-----: | | [/send_private_msg] | 🟢 | | [/send_group_msg] | 🟢 | | [/send_msg] | 🟢 | @@ -291,86 +291,85 @@ Thanks for 外国热心网友 for Provision of Azure Servlet ```json { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "SignServerUrl": "", - "Account": { - "Uin": 0, - "Password": "", - "Protocol": "Linux", - "AutoReconnect": true, - "GetOptimumServer": true - }, - "Message": { - "IgnoreSelf": true, - "StringPost": false - }, - "QrCode": { - "ConsoleCompatibilityMode": false - }, - "Implementations": [ - { - "Type": "ReverseWebSocket", - "Host": "127.0.0.1", - "Port": 8080, - "Suffix": "/onebot/v11/ws", - "ReconnectInterval": 5000, - "HeartBeatInterval": 5000, - "HeartBeatEnable": true, - "AccessToken": "" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } }, - { - "Type": "ForwardWebSocket", - "Host": "*", - "Port": 8081, - "HeartBeatInterval": 5000, - "HeartBeatEnable": true, - "AccessToken": "" + "SignServerUrl": "", + "Account": { + "Uin": 0, // Only used to create lagrange-{uin}.db and qr-{uin}.png + "Protocol": "Linux", + "AutoReconnect": true, + "GetOptimumServer": true }, - { - "Type": "HttpPost", - "Host": "127.0.0.1", - "Port": 8082, - "Suffix": "/", - "HeartBeatInterval": 5000, - "HeartBeatEnable": true, - "AccessToken": "" + "Message": { + "IgnoreSelf": true, + "StringPost": false }, - { - "Type": "Http", - "Host": "*", - "Port": 8083, - "AccessToken": "" - } - ] + "QrCode": { + "ConsoleCompatibilityMode": false + }, + "Implementations": [ + { + "Type": "ReverseWebSocket", + "Host": "127.0.0.1", + "Port": 8080, + "Suffix": "/onebot/v11/ws", + "ReconnectInterval": 5000, + "HeartBeatInterval": 5000, + "HeartBeatEnable": true, + "AccessToken": "" + }, + { + "Type": "ForwardWebSocket", + "Host": "*", + "Port": 8081, + "HeartBeatInterval": 5000, + "HeartBeatEnable": true, + "AccessToken": "" + }, + { + "Type": "HttpPost", + "Host": "127.0.0.1", + "Port": 8082, + "Suffix": "/", + "HeartBeatInterval": 5000, + "HeartBeatEnable": true, + "AccessToken": "" + }, + { + "Type": "Http", + "Host": "*", + "Port": 8083, + "AccessToken": "" + } + ] } ``` > [!WARNING] > Currently, `ForwardWebSocket` and `Http` are implemented based on `HttpListener`, which has the following problems: -> +> > 1. On Linux, the `Host` header of an Http request must match the value of `Prefix` unless it is `+` or `*`, so configure the `Host` of `ForwardWebSocket` and `Http` to be the domain name or IP you are using to access it. -> +> > 2. On Windows, the `HttpListener` is based on the `http.sys` implementation, so you need to register `urlacl` before using it. see [netsh](https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-http). You can also start `Lagrange.OneBot` using the administrator, at which point `HttpListener` will automatically register the required `urlacl`. ## NOTICE BEFORE LOGIN -- The NewDeviceLogin feature has not been implemented yet. It is recommended to use QRCode login for now. -- Currently, only the signature server implementation for Linux protocol is available. It is recommended to use the Linux protocol. +- The NewDeviceLogin feature has not been implemented yet. It is recommended to use QRCode login for now. +- Currently, only the signature server implementation for Linux protocol is available. It is recommended to use the Linux protocol. ## Known Problem -- ~~[ ] Signature Service is currently not established, so the login tend to be failed and return code may be 45, you can establish your own sign service by rewriting the `Signature` static class.~~ +- ~~[ ] Signature Service is currently not established, so the login tend to be failed and return code may be 45, you can establish your own sign service by rewriting the `Signature` static class.~~ ~~Thanks KonataDev/TheSnowfield for Provision of Signature API~~ ~~Signature API is now not provided, you may need to find it somewhere and inherit `SignProvider` class for `CustomSignProvider` in `BotConfig`~~ -- ~~Built-in SignServer is now provided, Enjoy!~~ +- ~~Built-in SignServer is now provided, Enjoy!~~ -- Signature of Windows and macOS is missing, you need to figure out by your self +- Signature of Windows and macOS is missing, you need to figure out by your self diff --git a/README_zh.md b/README_zh.md index 72d67baf1..716f432ab 100644 --- a/README_zh.md +++ b/README_zh.md @@ -67,11 +67,11 @@ Please use Lagrange.Core responsibly and in accordance with the law. | 协议 | 支持情况 | 登录类型 | 支持情况 | 消息段 | 支持情况 | 操作 | 支持情况 | 事件 | 支持情况 | | ------- | :------: | ----------------- | :------: | :--------------- | :------: | :--------------- | :------: | :--------------- | :------: | | Windows | 🟢 | 扫码登录 | 🟢 | 图片 | 🟢 | 戳一戳 | 🟢 | 验证码 | 🟢 | -| macOS | 🟢 | 密码登录 | 🟢 | 文本 / At | 🟢 | 撤回消息 | 🟢 | 机器人在线 | 🟢 | +| macOS | 🟢 | 密码登录 | 🔴 | 文本 / At | 🟢 | 撤回消息 | 🟢 | 机器人在线 | 🟢 | | Linux | 🟢 | 快速登录 | 🟢 | 语音 | 🟢 | 退出群组 | 🟢 | 机器人离线 | 🟢 | | | | 异常设备
密码 | 🔴 | QQ 黄脸表情 | 🟢 | 特殊头衔 | 🟢 | 消息事件 | 🟢 | | | | 异常设备
快速 | 🟢 | Json | 🟢 | 移除群成员 | 🟢 | 戳一戳事件 | 🟢 | -| | | 新设备验证 | 🟢 | Xml | 🟢 | 禁言群成员 | 🟢 | 消息撤回事件 | 🟢 | +| | | 新设备验证 | 🔴 | Xml | 🟢 | 禁言群成员 | 🟢 | 消息撤回事件 | 🟢 | | | | | | 合并转发 | 🟢 | 设置管理员 | 🟢 | 群成员减少 | 🟢 | | | | | | 视频 | 🟢 | 处理添加好友请求 | 🟢 | 群成员增加 | 🟢 | | | | | | 回复 | 🟢 | 处理加群请求 | 🟢 | 群管理员变动 | 🟢 | @@ -296,8 +296,7 @@ Please use Lagrange.Core responsibly and in accordance with the law. }, "SignServerUrl": "", "Account": { - "Uin": 0, - "Password": "", + "Uin": 0, // 仅用于创建 lagrange-{uin}.db 和 qr-{uin}.png "Protocol": "Linux", "AutoReconnect": true, "GetOptimumServer": true