Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit d00c8da

Browse files
authored
[Core] write qrcode to local file (#718)
1 parent 16454c1 commit d00c8da

File tree

5 files changed

+80
-81
lines changed

5 files changed

+80
-81
lines changed

Lagrange.OneBot/Core/Login/LoginService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public async Task StartAsync(CancellationToken token)
4747
{
4848
(string Url, byte[] QrCode)? qrcode = await _lagrange.FetchQrCode().WaitAsync(token);
4949
if (!qrcode.HasValue) return false;
50+
51+
await File.WriteAllBytesAsync($"qr-{configuration["Account:Uin"]}.png", qrcode.Value.QrCode, token);
5052
QrCodeHelper.Output(qrcode.Value.Url, _isCompatibility);
5153

5254
return await (Task<bool>)_lagrange.LoginByQrCode(token);

Lagrange.OneBot/Extensions/HostApplicationBuilderExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static HostApplicationBuilder ConfigureOneBot(this HostApplicationBuilder
9090
LiteDbUtility.IMessageEntityDeserialize
9191
);
9292

93-
string path = configuration["ConfigPath:Database"] ?? "lagrange.db";
93+
string path = configuration["ConfigPath:Database"] ?? $"lagrange-{configuration["Account:Uin"]}.db";
9494

9595
bool isFirstCreate = false;
9696
if (!File.Exists(path)) isFirstCreate = true;

Lagrange.OneBot/Resources/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"MusicSignServerUrl": "",
1212
"Account": {
1313
"Uin": 0,
14-
"Password": "",
1514
"Protocol": "Linux",
1615
"AutoReconnect": true,
1716
"GetOptimumServer": true

README.md

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ Thanks for 外国热心网友 for Provision of Azure Servlet
7272

7373
| Protocol | Support | Login | Support | Messages | Support | Operations | Support | Events | Support |
7474
| -------- | :-----: | ------------------------- | :-----: | :-------- | :-----: | :---------------- | :-----: | :------------------ | :-----: |
75-
| Windows | 🟢 | QrCode | 🟢 | Images | 🟢 | Poke | 🟢 | Captcha | 🟢 |
76-
| macOS | 🟢 | Password | 🟢 | Text / At | 🟢 | Recall | 🟢 | BotOnline | 🟢 |
75+
| Windows | 🟢 | QrCode | 🟢 | Images | 🟢 | Poke | 🟢 | Captcha | 🟢 |
76+
| macOS | 🟢 | Password | 🔴 | Text / At | 🟢 | Recall | 🟢 | BotOnline | 🟢 |
7777
| Linux | 🟢 | EasyLogin | 🟢 | Records | 🟢 | Leave Group | 🟢 | BotOffline | 🟢 |
78-
| | | UnusalDevice<br/>Password | 🔴 | QFace | 🟢 | Set Special Title | 🟢 | Message | 🟢 |
79-
| | | UnusalDevice<br/>Easy | 🟢 | Json | 🟢 | Kick Member | 🟢 | Poke | 🟢 |
80-
| | | NewDeviceVerify | 🟢 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🟢 |
81-
| | | | | Forward | 🟢 | Set Admin | 🟢 | GroupMemberDecrease | 🟢 |
82-
| | | | | Video | 🟢 | Friend Request | 🟢 | GroupMemberIncrease | 🟢 |
83-
| | | | | Reply | 🟢 | Group Request | 🟢 | GroupPromoteAdmin | 🟢 |
84-
| | | | | File | 🟢 | ~~Voice Call~~ | 🔴 | GroupInvite | 🟢 |
85-
| | | | | Poke | 🟢 | Client Key | 🟢 | GroupRequestJoin | 🟢 |
86-
| | | | | LightApp | 🟢 | Cookies | 🟢 | FriendRequest | 🟢 |
87-
| | | | | | | Send Message | 🟢 | ~~FriendTyping~~ | 🔴 |
88-
| | | | | | | | | ~~FriendVoiceCall~~ | 🔴 |
78+
| | | UnusalDevice<br/>Password | 🔴 | QFace | 🟢 | Set Special Title | 🟢 | Message | 🟢 |
79+
| | | UnusalDevice<br/>Easy | 🟢 | Json | 🟢 | Kick Member | 🟢 | Poke | 🟢 |
80+
| | | NewDeviceVerify | 🔴 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🟢 |
81+
| | | | | Forward | 🟢 | Set Admin | 🟢 | GroupMemberDecrease | 🟢 |
82+
| | | | | Video | 🟢 | Friend Request | 🟢 | GroupMemberIncrease | 🟢 |
83+
| | | | | Reply | 🟢 | Group Request | 🟢 | GroupPromoteAdmin | 🟢 |
84+
| | | | | File | 🟢 | ~~Voice Call~~ | 🔴 | GroupInvite | 🟢 |
85+
| | | | | Poke | 🟢 | Client Key | 🟢 | GroupRequestJoin | 🟢 |
86+
| | | | | LightApp | 🟢 | Cookies | 🟢 | FriendRequest | 🟢 |
87+
| | | | | | | Send Message | 🟢 | ~~FriendTyping~~ | 🔴 |
88+
| | | | | | | | | ~~FriendVoiceCall~~ | 🔴 |
8989

9090
## Lagrange.OneBot
9191

@@ -144,7 +144,7 @@ Thanks for 外国热心网友 for Provision of Azure Servlet
144144
<Summary>API</Summary>
145145

146146
| API | Support |
147-
|--------------------------------| :-----: |
147+
| ------------------------------ | :-----: |
148148
| [/send_private_msg] | 🟢 |
149149
| [/send_group_msg] | 🟢 |
150150
| [/send_msg] | 🟢 |
@@ -291,86 +291,85 @@ Thanks for 外国热心网友 for Provision of Azure Servlet
291291
292292
```json
293293
{
294-
"Logging": {
295-
"LogLevel": {
296-
"Default": "Information",
297-
"Microsoft": "Warning",
298-
"Microsoft.Hosting.Lifetime": "Information"
299-
}
300-
},
301-
"SignServerUrl": "",
302-
"Account": {
303-
"Uin": 0,
304-
"Password": "",
305-
"Protocol": "Linux",
306-
"AutoReconnect": true,
307-
"GetOptimumServer": true
308-
},
309-
"Message": {
310-
"IgnoreSelf": true,
311-
"StringPost": false
312-
},
313-
"QrCode": {
314-
"ConsoleCompatibilityMode": false
315-
},
316-
"Implementations": [
317-
{
318-
"Type": "ReverseWebSocket",
319-
"Host": "127.0.0.1",
320-
"Port": 8080,
321-
"Suffix": "/onebot/v11/ws",
322-
"ReconnectInterval": 5000,
323-
"HeartBeatInterval": 5000,
324-
"HeartBeatEnable": true,
325-
"AccessToken": ""
294+
"Logging": {
295+
"LogLevel": {
296+
"Default": "Information",
297+
"Microsoft": "Warning",
298+
"Microsoft.Hosting.Lifetime": "Information"
299+
}
326300
},
327-
{
328-
"Type": "ForwardWebSocket",
329-
"Host": "*",
330-
"Port": 8081,
331-
"HeartBeatInterval": 5000,
332-
"HeartBeatEnable": true,
333-
"AccessToken": ""
301+
"SignServerUrl": "",
302+
"Account": {
303+
"Uin": 0, // Only used to create lagrange-{uin}.db and qr-{uin}.png
304+
"Protocol": "Linux",
305+
"AutoReconnect": true,
306+
"GetOptimumServer": true
334307
},
335-
{
336-
"Type": "HttpPost",
337-
"Host": "127.0.0.1",
338-
"Port": 8082,
339-
"Suffix": "/",
340-
"HeartBeatInterval": 5000,
341-
"HeartBeatEnable": true,
342-
"AccessToken": ""
308+
"Message": {
309+
"IgnoreSelf": true,
310+
"StringPost": false
343311
},
344-
{
345-
"Type": "Http",
346-
"Host": "*",
347-
"Port": 8083,
348-
"AccessToken": ""
349-
}
350-
]
312+
"QrCode": {
313+
"ConsoleCompatibilityMode": false
314+
},
315+
"Implementations": [
316+
{
317+
"Type": "ReverseWebSocket",
318+
"Host": "127.0.0.1",
319+
"Port": 8080,
320+
"Suffix": "/onebot/v11/ws",
321+
"ReconnectInterval": 5000,
322+
"HeartBeatInterval": 5000,
323+
"HeartBeatEnable": true,
324+
"AccessToken": ""
325+
},
326+
{
327+
"Type": "ForwardWebSocket",
328+
"Host": "*",
329+
"Port": 8081,
330+
"HeartBeatInterval": 5000,
331+
"HeartBeatEnable": true,
332+
"AccessToken": ""
333+
},
334+
{
335+
"Type": "HttpPost",
336+
"Host": "127.0.0.1",
337+
"Port": 8082,
338+
"Suffix": "/",
339+
"HeartBeatInterval": 5000,
340+
"HeartBeatEnable": true,
341+
"AccessToken": ""
342+
},
343+
{
344+
"Type": "Http",
345+
"Host": "*",
346+
"Port": 8083,
347+
"AccessToken": ""
348+
}
349+
]
351350
}
352351
```
353352

354353
> [!WARNING]
355354
> Currently, `ForwardWebSocket` and `Http` are implemented based on `HttpListener`, which has the following problems:
356-
>
355+
>
357356
> 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.
358-
>
357+
>
359358
> 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`.
360359
361360
## NOTICE BEFORE LOGIN
362361

363-
- The NewDeviceLogin feature has not been implemented yet. It is recommended to use QRCode login for now.
364-
- Currently, only the signature server implementation for Linux protocol is available. It is recommended to use the Linux protocol.
362+
- The NewDeviceLogin feature has not been implemented yet. It is recommended to use QRCode login for now.
363+
- Currently, only the signature server implementation for Linux protocol is available. It is recommended to use the Linux protocol.
365364

366365
## Known Problem
367366

368-
- ~~[ ] 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.~~
367+
- ~~[ ] 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.~~
369368

370369
~~Thanks KonataDev/TheSnowfield for Provision of Signature API~~
371370

372371
~~Signature API is now not provided, you may need to find it somewhere and inherit `SignProvider` class for `CustomSignProvider` in `BotConfig`~~
373372

374-
- ~~Built-in SignServer is now provided, Enjoy!~~
373+
- ~~Built-in SignServer is now provided, Enjoy!~~
375374

376-
- Signature of Windows and macOS is missing, you need to figure out by your self
375+
- Signature of Windows and macOS is missing, you need to figure out by your self

README_zh.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ Please use Lagrange.Core responsibly and in accordance with the law.
6767
| 协议 | 支持情况 | 登录类型 | 支持情况 | 消息段 | 支持情况 | 操作 | 支持情况 | 事件 | 支持情况 |
6868
| ------- | :------: | ----------------- | :------: | :--------------- | :------: | :--------------- | :------: | :--------------- | :------: |
6969
| Windows | 🟢 | 扫码登录 | 🟢 | 图片 | 🟢 | 戳一戳 | 🟢 | 验证码 | 🟢 |
70-
| macOS | 🟢 | 密码登录 | 🟢 | 文本 / At | 🟢 | 撤回消息 | 🟢 | 机器人在线 | 🟢 |
70+
| macOS | 🟢 | 密码登录 | 🔴 | 文本 / At | 🟢 | 撤回消息 | 🟢 | 机器人在线 | 🟢 |
7171
| Linux | 🟢 | 快速登录 | 🟢 | 语音 | 🟢 | 退出群组 | 🟢 | 机器人离线 | 🟢 |
7272
| | | 异常设备<br/>密码 | 🔴 | QQ 黄脸表情 | 🟢 | 特殊头衔 | 🟢 | 消息事件 | 🟢 |
7373
| | | 异常设备<br/>快速 | 🟢 | Json | 🟢 | 移除群成员 | 🟢 | 戳一戳事件 | 🟢 |
74-
| | | 新设备验证 | 🟢 | Xml | 🟢 | 禁言群成员 | 🟢 | 消息撤回事件 | 🟢 |
74+
| | | 新设备验证 | 🔴 | Xml | 🟢 | 禁言群成员 | 🟢 | 消息撤回事件 | 🟢 |
7575
| | | | | 合并转发 | 🟢 | 设置管理员 | 🟢 | 群成员减少 | 🟢 |
7676
| | | | | 视频 | 🟢 | 处理添加好友请求 | 🟢 | 群成员增加 | 🟢 |
7777
| | | | | 回复 | 🟢 | 处理加群请求 | 🟢 | 群管理员变动 | 🟢 |
@@ -296,8 +296,7 @@ Please use Lagrange.Core responsibly and in accordance with the law.
296296
},
297297
"SignServerUrl": "",
298298
"Account": {
299-
"Uin": 0,
300-
"Password": "",
299+
"Uin": 0, // 仅用于创建 lagrange-{uin}.db 和 qr-{uin}.png
301300
"Protocol": "Linux",
302301
"AutoReconnect": true,
303302
"GetOptimumServer": true

0 commit comments

Comments
 (0)