Giter Site home page Giter Site logo

lagrangedev / lagrange.core Goto Github PK

View Code? Open in Web Editor NEW
1.5K 17.0 200.0 3.22 MB

An Implementation of NTQQ Protocol, with Pure C#, Derived from Konata.Core

License: GNU General Public License v3.0

C# 99.92% Dockerfile 0.06% Shell 0.02%
csharp ntqq qq-protocol qqbot

lagrange.core's Introduction

Lagrange.Core Core OneBot C# C#

License Telegram

Image

> English < | 简体中文

Related Projects

Lagrange.Core NTQQ Protocol Implementation(👈Here
OpenShamrock Based on Xposed, OneBot Bot Framework
Chronocat Based on Electron, modular Satori Bot Framework

Document

Lagrange.Doc

Docker guide

Out of Active Feature Requesting

Lagrange.Core has completed nearly all the function and task scheduled by Linwenxuan05, so mostly enhance to the library would be concentrated to the repo for next.

Feature request would be accepted but implemented with a long duration.

The new function of NTQQ supported in following versions would be added as well.

Disclaimer

The Lagrange.Core project, including its developers, contributors, and affiliated individuals or entities, hereby explicitly disclaim any association with, support for, or endorsement of any form of illegal behavior. This disclaimer extends to any use or application of the Lagrange.Core project that may be contrary to local, national, or international laws, regulations, or ethical guidelines.

Lagrange.Core is an open-source software project designed to facilitate lawful and ethical applications in its intended use cases. It is the responsibility of each user to ensure that their usage of Lagrange.Core complies with all applicable laws and regulations in their jurisdiction.

The developers and contributors of Lagrange.Core assume no liability whatsoever for any actions taken by users that violate the law or engage in any form of illicit activity. Users are solely responsible for their own actions and any consequences that may arise from the use of Lagrange.Core.

Furthermore, any discussions, suggestions, or guidance provided by the Lagrange.Core community, including its developers, contributors, and users, should not be interpreted as legal advice. It is strongly recommended that users seek independent legal counsel to understand the legal implications of their actions and ensure compliance with the relevant laws and regulations.

By using or accessing Lagrange.Core, the user acknowledges and agrees to release the developers, contributors, and affiliated individuals or entities from any and all liability arising from the use or misuse of the project, including any legal consequences incurred as a result of their actions.

Please use Lagrange.Core responsibly and in accordance with the law.

SignServer

https://sign.lagrangecore.org/api/sign

Thanks for 外国热心网友 for Provision of Azure Servlet

** Built-in SignServer is now provided, Enjoy! **

Features List

Protocol Support Login Support Messages Support Operations Support Events Support
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 🔴

Lagrange.OneBot

The Binary for development could be found in Actions Artifacts

Message Segement
Message Segement Support
Text 🟢
Face 🟢
Image 🟢
Record 🟢
Video 🟢
At 🟢
Rps 🟢
Dice 🟢
Shake 🔴
Poke 🟢
Anonymous 🔴
Share 🔴
Contact 🔴
Location 🟢
Music 🔴
Reply 🟢
Forward 🟢
Node 🟢
Xml 🔴
Json 🟢
API
API Support
/send_private_msg 🟢
/send_group_msg 🟢
/send_msg 🟢
/delete_msg 🟢
/get_msg 🟢
/get_forward_msg 🟢
/send_like 🟢
/set_group_kick 🟢
/set_group_ban 🟢
/set_group_anonymous_ban 🔴
/set_group_whole_ban 🟢
/set_group_admin 🟢
/set_group_anonymous 🔴
/set_group_card 🟢
/set_group_name 🟢
/set_group_leave 🟢
/set_group_special_title 🟢
/set_friend_add_request 🟢
/set_group_add_request 🟢
/get_login_info 🟢
/get_stranger_info 🟢
/get_friend_list 🟢
/get_group_info 🟢
/get_group_list 🟢
/get_group_member_info 🟢
/get_group_member_list 🟢
/get_group_honor_info 🟢
/get_cookies 🟢
/get_csrf_token 🟢
/get_credentials 🟢
/get_record 🔴
/get_image 🔴
/can_send_image 🟢
/can_send_record 🟢
/get_status 🟢
/get_version_info 🟢
/set_restart 🟢
/clean_cache 🔴
Event
PostType EventName Support
Message Private Message 🟢
Message Group Message 🟢
Notice Group File Upload 🟢
Notice Group Admin Change 🟢
Notice Group Member Decrease 🟢
Notice Group Member Increase 🟢
Notice Group Mute 🟢
Notice Friend Add 🟢
Notice Group Recall Message 🟢
Notice Friend Recall Message 🟢
Notice Group Poke 🔴
Notice Group red envelope luck king 🔴
Notice Group Member Honor Changed 🔴
Request Add Friend Request 🟢
Request Group Request/Invitations 🟢
Meta LifeCycle 🟢
Meta Heartbeat 🟢
Communication
CommunicationType Support
Http 🟢
Http-Post 🟢
ForwardWebSocket 🟢
ReverseWebSocket 🟢

appsettings.json Example

As the Password is empty here, this indicates that QRCode login is used

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "SignServerUrl": "https://sign.lagrangecore.org/api/sign",
  "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": ""
    },
    {
      "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. 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.

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.

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!

  • Signature of Windows and macOS is missing, you need to figure out by your self

lagrange.core's People

Contributors

aicorein avatar blokura avatar caelumlux avatar coloryr avatar cracktc avatar darkcwk avatar decrabbityyy avatar dogdie233 avatar endymx avatar eric2788 avatar executor-cheng avatar initialencounter avatar ishkong avatar linwenxuan05 avatar luooooob avatar lvlinkeji avatar muuushin avatar myot233 avatar neppure avatar nscrosu avatar photonspk avatar pk5ls20 avatar serfend avatar spadelushen avatar sweetymajo avatar thesnowfield avatar xeronowo avatar xzhouqd avatar yukari316 avatar zaitonn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lagrange.core's Issues

群成员变动事件推送异常

在踢出群员/群员入群时,正向/反向 WebSocket服务下均无法收到JSON对象

开启反向WebSocket服务时的Log:

ubuntu@VM-8-9-ubuntu:~/qqbot/lagrange$ ./Lagrange.OneBot
info: Lagrange.OneBot.LagrangeApp[0]
      [LagrangeWebSvcCollection]: Single Connection has been configured
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /home/ubuntu/qqbot/lagrange
info: Lagrange.OneBot.LagrangeApp[0]
      Lagrange.OneBot Implementation has started
info: Lagrange.OneBot.LagrangeApp[0]
      Protocol:  | 3.1.2-13107
info: Lagrange.OneBot.LagrangeApp[0]
      [OneBotSigner]: Signature Service is successfully established
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:34] [SocketContext] [VERBOSE]: Server: http://117.62.242.155:8080/ Latency: 32
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:34] [SocketContext] [VERBOSE]: Server: http://180.110.193.149:8080/ Latency: 35
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:34] [SocketContext] [VERBOSE]: Server: http://180.109.192.57:8080/ Latency: 34
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:34] [ServiceContext] [DEBUG]: Outgoing SSOFrame: trpc.login.ecdh.EcdhService.SsoKeyExchange
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:37] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.login.ecdh.EcdhService.SsoKeyExchange
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:37] [WtExchangeLogic] [INFORMATION]: Trying to Login by EasyLogin...
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:37] [WtExchangeLogic] [INFORMATION]: Key Exchange successfully!
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:37] [ServiceContext] [DEBUG]: Outgoing SSOFrame: trpc.login.ecdh.EcdhService.SsoNTLoginEasyLogin
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.login.ecdh.EcdhService.SsoNTLoginEasyLogin
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [WtExchangeLogic] [INFORMATION]: Login Success
info: Lagrange.OneBot.LagrangeApp[0]
      Bot Online: 2200814351
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Outgoing SSOFrame: trpc.qq_new_tech.status_svc.StatusService.Register
trce: Lagrange.OneBot.LagrangeApp[0]
      [ReverseWSService] Send: {"sub_type":"connect","meta_event_type":"lifecycle","time":1699958618,"self_id":2200814351,"post_type":"meta_event"}
trce: Lagrange.OneBot.LagrangeApp[0]
      [ReverseWSService] Send: {"interval":5000,"status":{"app_initialized":true,"app_enabled":true,"app_good":true,"online":true,"good":true},"meta_event_type":"heartbeat","time":1699958618,"self_id":2200814351,"post_type":"meta_event"}
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.qq_new_tech.status_svc.StatusService.Register
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [WtExchangeLogic] [INFORMATION]: Register Status: register success
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Outgoing SSOFrame: trpc.msg.register_proxy.RegisterProxy.SsoInfoSync
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.msg.register_proxy.RegisterProxy.SsoInfoSync
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Unsuccessful SSOFrame Payload: 32003A004084A7D38E0440FEB1CD8F04408888E48F04
warn: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [WARNING]: Unsupported SSOFrame Received: trpc.msg.register_proxy.RegisterProxy.PushParams
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.msg.register_proxy.RegisterProxy.InfoSyncPush
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:38] [CachingLogic] [VERBOSE]: Caching group entities: 24
trce: Lagrange.OneBot.LagrangeApp[0]
      [ReverseWSService] Send: {"interval":5000,"status":{"app_initialized":true,"app_enabled":true,"app_good":true,"online":true,"good":true},"meta_event_type":"heartbeat","time":1699958623,"self_id":2200814351,"post_type":"meta_event"}
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:44] [ServiceContext] [DEBUG]: Outgoing SSOFrame: Heartbeat.Alive
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:46] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.msg.olpush.OlPushService.MsgPush
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:46] [ServiceContext] [DEBUG]: Outgoing SSOFrame: OidbSvcTrpcTcp.0xfd4_1
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:47] [ServiceContext] [DEBUG]: Incoming SSOFrame: OidbSvcTrpcTcp.0xfd4_1
info: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:47] [CachingLogic] [VERBOSE]: Caching group members: 865444787
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:47] [ServiceContext] [DEBUG]: Outgoing SSOFrame: OidbSvcTrpcTcp.0xfe7_3
trce: Lagrange.OneBot.LagrangeApp[0]
      [2023-11-14 18:43:47] [ServiceContext] [DEBUG]: Incoming SSOFrame: OidbSvcTrpcTcp.0xfe7_3
trce: Lagrange.OneBot.LagrangeApp[0]
      [ReverseWSService] Send: {"interval":5000,"status":{"app_initialized":true,"app_enabled":true,"app_good":true,"online":true,"good":true},"meta_event_type":"heartbeat","time":1699958628,"self_id":2200814351,"post_type":"meta_event"}

无法at全体成员

at全体成员时,出现以下错误

warn: Lagrange.OneBot.Core.Operation.OperationService[0]
      Unexpected error encountered while handling message.
      System.FormatException: The input string 'all' was not in a correct format.
         at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
         at System.UInt32.Parse(String s)
         at Lagrange.OneBot.Core.Message.Entity.AtSegment.Build(MessageBuilder builder, ISegment segment) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Message\Entity\AtSegment.cs:line 22
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.BuildMessages(MessageBuilder builder, String message) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\MessageCommon.cs:line 155
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.ParseChain(OneBotGroupMessageText message) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\MessageCommon.cs:line 113
         at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonObject payload) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\SendGroupMessageOperation.cs:line 18
         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\OperationService.cs:line 51

部分表情无法解析

例如
图片
在日志中显示了警告

trce: Lagrange.Core.BotContext[0]
      [2023-12-16 03:18:58] [BusinessContext] [DEBUG]: 0000004F98244686000000000000000400000029747270632E6D73672E6F6C707573682E4F6C50757368536572766963652E4D73675075736800000004000000000000000AA80100C80102657CA6A2000001280AA1020A50088BF5FDC7041218755F37787A33324D66583368634D6A737573337742706D6718E90720CF8194800228DF9AA6EE08421F0884DAC5E3021001184E2203E38080280230013A087465737434626F744810121C085220EFA4845F28BC1E30A2CDF2AB06380160EFA484DF80808080011AAE010AAB010A20080010A2CDF2AB0618EFA4845F2000280A300038860140024A06E5AE8BE4BD931220AA031D0821121708950212085BE6B1AAE6B1AA5D1A085BE6B1AAE6B1AA5D180112064A0408004001124DAA024A5000600068009A0141080820CB50C80100F00100F80100900200980300A00300B00300C00300D00300E803008A040608020801100B9004800BB80400C00400CA0400F804808008880500120E82010B0A03E38080180120102801
warn: Lagrange.Core.BotContext[0]
      [2023-12-16 03:18:58] [BusinessContext] [WARNING]: Invalid wire-type (Variant); this usually means you have over-written a file without truncating or setting the length; see https://stackoverflow.com/q/2152978/23354
warn: Lagrange.Core.BotContext[0]
      [2023-12-16 03:18:58] [BusinessContext] [WARNING]: Error while handling msf push: 12 trpc.msg.olpush.OlPushService.MsgPush

无法at全体成员

at全体成员时,出现以下错误

warn: Lagrange.OneBot.Core.Operation.OperationService[0]
      Unexpected error encountered while handling message.
      System.FormatException: The input string 'all' was not in a correct format.
         at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
         at System.UInt32.Parse(String s)
         at Lagrange.OneBot.Core.Message.Entity.AtSegment.Build(MessageBuilder builder, ISegment segment) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Message\Entity\AtSegment.cs:line 22
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.BuildMessages(MessageBuilder builder, String message) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\MessageCommon.cs:line 155
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.ParseChain(OneBotGroupMessageText message) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\MessageCommon.cs:line 113
         at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonObject payload) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\Message\SendGroupMessageOperation.cs:line 18
         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\OperationService.cs:line 51

Json serialization exception causes program crash

winserver 系统日志

错误应用程序名称: Lagrange.OneBot.exe,版本: 0.0.1.0,时间戳: 0x65310000
错误模块名称: KERNELBASE.dll,版本: 10.0.17763.3887,时间戳: 0x3e07c6b6
异常代码: 0xe0434352
错误偏移量: 0x00000000000349b9
错误进程 ID: 0x4ea8
错误应用程序启动时间: 0x01da47a4632347b7
错误应用程序路径: C:\Server\Lagrange.OneBot_win-x64\Lagrange.OneBot.exe
错误模块路径: C:\Windows\System32\KERNELBASE.dll
报告 ID: 143af6c6-f1de-4894-800c-3327c59cbda7
错误程序包全名: 
错误程序包相对应用程序 ID: 

Application: Lagrange.OneBot.exe
CoreCLR Version: 7.0.1523.57226
.NET Version: 7.0.15
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Operation\OperationService.cs:line 42
   at Lagrange.OneBot.Core.Network.LagrangeWebSvcCollection.<>c__DisplayClass6_1.<<StartAsync>b__0>d.MoveNext() in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Network\LagrangeWebSvcCollection.cs:line 48
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()


[FATAL]: Tag: 禁止登录

[2024-01-13 23:20:18] [WtExchangeLogic] [FATAL]: Tag: 禁止登录
State: 登录失败,请前往QQ官网im.qq.com下载最新版QQ后重试,或通过问题反馈与我们联系。
trce: Lagrange.Core.BotContext[0]

[Bug Report][OneBot] 使用ForwardWebSocket时WebScoket客户端无法接收到消息

错误内容:onebot项目启用ForwardWebSocket时,可以发出推送,但是客户端无法接收到推送。

系统环境:Debian11

错误日志:

Lagrange日志:

info: Lagrange.OneBot.LagrangeApp[0]
      [ForwardWSService]: Connected
trce: Lagrange.OneBot.LagrangeApp[0]
      [ForwardWSService] Send: {"sub_type":"connect","meta_event_type":"lifecycle","time":1698414978,"self_id":449427853,"post_type":"meta_event"}

该段日志反复出现,判定客户端断线,客户端反复重连。

客户端代码(Python):

class CQBot(websocket.WebSocketApp):
	def __init__(self, config: CqHttpConfig):
		self.config = config
		websocket.enableTrace(True)
		url = 'ws://{}:{}/'.format(self.config.http_address, self.config.http_port)
		super().__init__(url, on_message=self.on_message, on_close=self.on_close)

	def start(self):
		self.run_forever(ping_interval=60,ping_timeout=5)

if __name__ == '__main__':
	cq_bot = CQBot(config)
	cq_bot.start()

客户端仅能在最开始建立连接时接收到推送,一段时间后接受不到推送。

發送圖片時偶爾會出現 Index Out Of Range

發送;

(圖片nsfw, 不知是否風控問題導致的錯誤?)

[ForwardWSService] Receive: {"action":"send_group_msg","params":{"group_id":123456789,"message":[{"type":"text","data":{"text":"作者: 逆流茶会 "}},{"type":"text","data":{"text":"\n"}},{"type":"text","data":{"text":"标签: ##原创10000users加入书籤, #オリジナル10000users入り, #逆流茶会"}},{"type":"text","data":{"text":"\n"}},{"type":"text","data":{"text":"大图: https://i.pixiv.cat/img-original/img/2023/06/28/00/00/15/109403330_p0.jpg "}},{"type":"text","data":{"text":"\n"}},{"type":"image","data":{"file":"https://i.pixiv.cat/c/540x540_70/img-master/img/2023/06/28/00/00/15/109403330_p0_master1200.jpg","cache":0}}]},"echo":66}

錯誤日誌:

image

         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs eventArgs) in /App/Lagrange.OneBot/Core/Operation/OperationService.cs:line 73

         at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonObject payload) in /App/Lagrange.OneBot/Core/Operation/Message/SendGroupMessageOperation.cs:line 22

         at Lagrange.Core.Internal.Context.Logic.Implementation.OperationLogic.SendMessage(MessageChain chain) in /App/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs:line 42

      System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

      Error while handling Lagrange.OneBot.Core.Network.MsgRecvEventArgs: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

         at Lagrange.Core.Internal.Context.BusinessContext.SendEvent(ProtocolEvent event) in /App/Lagrange.Core/Internal/Context/BusinessContext.cs:line 121

         at Lagrange.Core.Internal.Service.Message.SendMessageService.Build(SendMessageEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, BinaryPacket& output, List`1& extraPackets) in /App/Lagrange.Core/Internal/Service/Message/SendMessageService.cs:line 18

         at Lagrange.Core.Internal.Context.ServiceContext.ResolvePacketByEvent(ProtocolEvent protocolEvent) in /App/Lagrange.Core/Internal/Context/ServiceContext.cs:line 65

         at Lagrange.Core.Message.MessagePacker.Build(MessageChain chain, String selfUid) in /App/Lagrange.Core/Message/MessagePacker.cs:line 66

      [2023-11-16 12:10:02] [BusinessContext] [WARNING]:    at Lagrange.Core.Message.Entity.ImageEntity.Lagrange.Core.Message.IMessageEntity.PackElement() in /App/Lagrange.Core/Message/Entity/ImageEntity.cs:line 65

      [2023-11-16 12:10:02] [BusinessContext] [WARNING]: Exception of type 'System.ArgumentOutOfRangeException' was thrown. (Parameter 'type')

      [2023-11-16 12:10:02] [BusinessContext] [WARNING]:    at Lagrange.Core.Internal.Service.Message.ImageGroupUploadService.Build(ImageGroupUploadEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, BinaryPacket& output, List`1& extraPackets) in /App/Lagrange.Core/Internal/Service/Message/ImageGroupUploadService.cs:line 33

      [ForwardWSService] Send: {"status":"failed","retcode":200,"data":"Index was out of range. Must be non-negative and less than the size of the collection. (Parameter \u0027index\u0027)","echo":66}

仓库的代码无法在 Alpine Linux 环境运行,已安装 dotnet 7.0 。下面提供测试环境的 GitHub Actions 代码。

https://github.com/LagrangeDev/Lagrange.Core/actions下载的最新的Lagrange.OneBot_linux-x64可以在Debian系统运行,但无法在Alpine 环境运行。

运行环境为已经安装了dotnet7-sdkAlpine 3.19.1的x64系统,错误日志为:

Lagrange.OneBot: cannot execute: required file not found

甚至无法在安装了dotnet7-sdkAlpine环境通过编译,下面是提供测试的GitHub Actions代码。直接复制到 .github/workflows/ 手动运行即可。

name: CI

on:

  workflow_dispatch:

jobs:
  
  build:
    
    runs-on: ubuntu-latest

    steps:
      
      - uses: actions/checkout@v3

      - uses: jirutka/setup-alpine@v1

      - name: Run script inside Alpine chroot as root
        run: |
          cat /etc/alpine-release
          apk add --no-cache --update --no-progress bash dotnet7-sdk git
          dotnet --info
          git clone https://github.com/LagrangeDev/Lagrange.Core.git
          cd Lagrange.Core
          dotnet publish Lagrange.OneBot/Lagrange.OneBot.csproj \
              -c Release \
              -o out \
              --no-self-contained \
              -p:PublishSingleFile=true \
              -p:IncludeContentInSingleFile=true
        shell: alpine.sh --root {0}

启动时报错

info: Lagrange.OneBot.LagrangeApp[0]
      [LagrangeWebSvcCollection]: Multi Connection has been configured
trce: Lagrange.OneBot.LagrangeApp[0]
      [ForwardWSService] Send: {"interval":5000,"status":{"app_initialized":true,"app_enabled":true,"app_good":true,"online":true,"good":true},"meta_event_type":"heartbeat","time":1698572749,"self_id":31******89,"post_type":"meta_event"}
Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Extensions.Logging.Logger`1[Lagrange.OneBot.LagrangeApp]' while attempting to activate 'Lagrange.OneBot.Core.Operation.OperationService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Lagrange.OneBot.LagrangeApp..ctor(IHost host) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\LagrangeApp.cs:line 41
   at Lagrange.OneBot.LagrangeAppBuilder.Build() in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\LagrangeAppBuilder.cs:line 91
   at Lagrange.OneBot.Program.Main(String[] args) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Program.cs:line 18

正向ws链接无法接收多链接

我使用Lagrange.OneBot + MiraiCQ

发现图片发送后MiraiCQ卡死的问题,在MiraiCQ提出issue后开发者回复我Lagrange仅能接收单ws链接

MiraiCQ在发送消息时,对于较大的消息(如图片),会新建立一个连接来发送,发送完成后再断开这个连接。
而Lagrange.Core目前不支持多个正向ws连接。

详细原issue请见:
super1207/MiraiCQ#33

Onebot的Group Message的raw_message字段为空字符串

如题,日志如下
(为看着方便已将日志中的json格式化,并且用星号代替了敏感信息)

trce: Lagrange.OneBot.Core.Network.Service.ForwardWSService[0]
      [ForwardWSService] Send: 
{
    "message_type": "group",
    "sub_type": "normal",
    "message_id": **********,
    "group_id": **********,
    "user_id": **********,
    "anonymous": null,
    "message": [
        {
            "type": "text",
            "data": {
                "text": "lagrange"
            }
        }
    ],
    "raw_message": "",
    "font": 0,
    "sender": {
        "user_id": **********,
        "nickname": "**********",
        "card": null,
        "sex": "unknown",
        "age": 0,
        "area": "",
        "level": "2",
        "role": "member",
        "title": ""
    },
    "time": 1704251194,
    "self_id": **********,
    "post_type": "message"
}

[Bug Report][Core] Cannot receive Group RecordEntity send by QQMobile

Enviroment:
Using Lagrange.Core@520c7ab
Windows 11 X64

Action:
A record is sent from QQMobile

Expect:
GroupMessageEvent with a RecordEntity MessageChain would be received

Actual:
trpc.msg.olpush.OlPushService.MsgPush is shown but GroupMessageEvent is not received

Log:

trce: Lagrange.Core.BotContext[0]
      [ServiceContext] Outgoing SSOFrame: Heartbeat.Alive
// Message send
trce: Lagrange.Core.BotContext[0]
      [ServiceContext] Incoming SSOFrame: trpc.msg.olpush.OlPushService.MsgPush
// And nothing happened
trce: Lagrange.Core.BotContext[0]
      [ServiceContext] Outgoing SSOFrame: Heartbeat.Alive
trce: Lagrange.Core.BotContext[0]

Typo in #848783c

invitor(wrong) => inviter(correct)
at GroupMember(Increase/Decrease)Event

Actions [OneBot] Fixed NotifyService.cs#117 版本在正向 WebSocket 的 /event 路径无法收到消息

[OneBot] Fixed NotifyService.cs#117 中的 Lagrange.OneBot_linux-x64 版本无法在正向 WebSocket 的 /event 路径收到消息

查看日志有警告信息

warn: Lagrange.OneBot.Core.Network.LagrangeWebSvcCollection[6]
      [LagrangeWebSvcCollection]: WebService send message failed.
      Fleck.ConnectionNotAvailableException: Data sent while closing or after close. Ignoring.
         at Lagrange.OneBot.Core.Network.Service.ForwardWSService.SendJsonAsync[T](T json, String identifier, CancellationToken cancellationToken)
         at Lagrange.OneBot.Core.Network.LagrangeWebSvcCollection.SendJsonAsync[T](T json, String identifier, CancellationToken cancellationToken)

上个版本
[Core] Fixed that newFace would not be parsed correctly #116
Lagrange.OneBot_linux-x64 可以收到消息

[Bug Report][Onebot] 无法处理Bot是群主的群消息和私聊消息

该问题出现自 Commit#0c2b764
群聊log

fail: Lagrange.Core.BotContext[0]
      [2024-01-04 07:07:23] [EventInvoker] [EXCEPTION]:    at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, Byte level, IndexNode last)
         at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, IndexNode last)
         at LiteDB.Engine.LiteEngine.InsertDocument(Snapshot snapshot, BsonDocument doc, BsonAutoId autoId, IndexService indexer, DataService data)
         at LiteDB.Engine.LiteEngine.<>c__DisplayClass7_0.<Insert>b__0(TransactionService transaction)
         at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
         at LiteDB.Engine.LiteEngine.Insert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
         at LiteDB.LiteCollection`1.Insert(BsonValue id, T entity)
         at Lagrange.OneBot.Core.Message.MessageService.OnGroupMessageReceived(BotContext bot, GroupMessageEvent e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Message\MessageService.cs:line 78
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass3_0.<.ctor>b__6(GroupMessageEvent e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 24
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass4_0`1.<RegisterEvent>b__0(EventBase e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 35
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass5_0.<PostEvent>b__0() in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 43
      Cannot insert duplicate key in unique index '_id'. The duplicate value is '{"$numberLong":"2021196032"}'.

私聊log

fail: Lagrange.Core.BotContext[0]
      [2024-01-04 07:09:54] [EventInvoker] [EXCEPTION]:    at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, Byte level, IndexNode last)
         at LiteDB.Engine.IndexService.AddNode(CollectionIndex index, BsonValue key, PageAddress dataBlock, IndexNode last)
         at LiteDB.Engine.LiteEngine.InsertDocument(Snapshot snapshot, BsonDocument doc, BsonAutoId autoId, IndexService indexer, DataService data)
         at LiteDB.Engine.LiteEngine.<>c__DisplayClass7_0.<Insert>b__0(TransactionService transaction)
         at LiteDB.Engine.LiteEngine.AutoTransaction[T](Func`2 fn)
         at LiteDB.Engine.LiteEngine.Insert(String collection, IEnumerable`1 docs, BsonAutoId autoId)
         at LiteDB.LiteCollection`1.Insert(BsonValue id, T entity)
         at Lagrange.OneBot.Core.Message.MessageService.OnFriendMessageReceived(BotContext bot, FriendMessageEvent e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.OneBot\Core\Message\MessageService.cs:line 57
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass3_0.<.ctor>b__5(FriendMessageEvent e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 23
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass4_0`1.<RegisterEvent>b__0(EventBase e) in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 35
         at Lagrange.Core.Event.EventInvoker.<>c__DisplayClass5_0.<PostEvent>b__0() in D:\a\Lagrange.Core\Lagrange.Core\Lagrange.Core\Event\EventInvoker.cs:line 43
      Cannot insert duplicate key in unique index '_id'. The duplicate value is '{"$numberLong":"256"}'.

onebot项目在发送图片时读取的path路径错误导致退出进程

十分感谢开发者对onebot的支持

错误内容:onebot项目在发送图片时读取的图片路径是从Lagrange.OneBot的目录开始,而发送的图片目录是从根目录开始,导致图片无法读取退出进程

系统环境:Ubuntu22.04
错误日志:

trce: Lagrange.OneBot.LagrangeApp[0]
      [ReverseWSService] Receive: {"action": "send_msg", "params": {"user_id": *********, "group_id": **********, "message_type": "group", "message": [{"type": "at", "data": {"qq": "*********"}}, {"type": "text", "data": {"text": " "}}, {"type": "image", "data": {"file": "file:///home/my/bot/zhenxun_bot/resources/image/sign/today_card/********_sign_2023-10-19.png", "type": null, "cache": "true", "proxy": "true", "timeout": null}}]}, "echo": "1"}
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path '/home/my/bot/Lagrange.Core/Lagrange.OneBot/home/my/bot/zhenxun_bot/resources/image/sign/today_card/**********_sign_2023-10-19.png'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException)
   at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.File.ReadAllBytes(String path)
   at Lagrange.OneBot.Core.Message.Entity.ImageSegment.Build(MessageBuilder builder, ISegment segment) in /home/my/bot/Lagrange.Core/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs:line 34
   at Lagrange.OneBot.Core.Operation.Message.SendMessageOperation.ParseChain(OneBotMessage message) in /home/my/bot/Lagrange.Core/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs:line 53
   at Lagrange.OneBot.Core.Operation.Message.SendMessageOperation.HandleOperation(String echo, BotContext context, JsonObject payload) in /home/my/bot/Lagrange.Core/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs:line 35
   at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(String data) in /home/my/bot/Lagrange.Core/Lagrange.OneBot/Core/Operation/OperationService.cs:line 38
   at Lagrange.OneBot.Core.Operation.OperationService.<.ctor>b__3_0(Object _, MsgRecvEventArgs e) in /home/my/bot/Lagrange.Core/Lagrange.OneBot/Core/Operation/OperationService.cs:line 28
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

Lagrange.OneBot项目和onebot项目同时一台机器上运行
图片路径在'/home/my/bot/zhenxun_bot/resources/image/sign/today_card/*'下,实际上只要发送图片都会先从Lagrange.OneBot目录往下读取,然后出现错误退出进程

目前只是在做onebot测试,并没有完全使用,这个问题检查Lagrange.OneBot的文档说明应该是bug
文档位置:https://github.com/botuniverse/onebot-11/blob/master/message/segment.md#%E5%9B%BE%E7%89%87

屏蔽机器人自身发送的消息

识别到Bot自身发送的指令,在未屏蔽的状态下可能会反复触发包含指令的内容导致刷屏,应该不接收bot发送的消息

image

使用多个反向ws连接时会无法连接到其中一个

在Implementations下配置了两条连接,之前一直都是正常的。
更新到 Actions 6988945049 后,只有其中一个连接能正常连通,连通的那条会将一条消息识别成两条,发送消息时会发送四条甚至六条;另一个连接无法正确接收及发送信息。
一张截图

扫码登陆后Unable to connect to the remote server: Connection refused (127.0.0.1:20028)

描述

扫码登陆后,无限循环输出这段错误:

warn: Lagrange.OneBot.Core.Network.Service.ReverseWSService[3]
      [ReverseWSService] Client disconnected
      System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server
       ---> System.Net.Http.HttpRequestException: Connection refused (127.0.0.1:20028)
       ---> System.Net.Sockets.SocketException (111): Connection refused
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
         at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
         at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken)
         at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
         at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
         at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options)
         at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken)
         at Lagrange.OneBot.Core.Network.Service.ReverseWSService.ExecuteAsync(CancellationToken stoppingToken) in /App/Lagrange.OneBot/Core/Network/Service/ReverseWSService.cs:line 123

视频

https://github.com/LagrangeDev/Lagrange.Core/assets/86581525/da82cc8f-34a3-4f41-a956-c7d73e1dd545
很抱歉是拍屏(日志在上面已经给出,所以不用看的很清楚,问题应该不大?)

完整日志

6600多行,但全是循环…
logs.txt

appsettings.json

{
    "Logging": {
        "LogLevel": {
            "Default": "Trace",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "SignServerUrl": "",
    "Account": {
        "Uin": 0,
        "Password": "",
        "Protocol": "Linux",
        "AutoReconnect": true,
        "GetOptimumServer": true
    },
    "Message": {
      "IgnoreSelf": true
    },
    "Implementation": {
        "ForwardWebSocket": {
            "Host": "127.0.0.1",
            "Port": 20029,
            "HeartBeatInterval": 5000,
            "AccessToken": ""
        },
        "ReverseWebSocket": {
            "Host": "127.0.0.1",
            "Port": 20028,
            "Suffix": "/onebot/v11/ws",
            "ReconnectInterval": 5000,
            "HeartBeatInterval": 5000,
            "AccessToken": ""
        },
        "Http": {
            "Host": "",
            "Port": 0,
            "EventEnabled": false
        },
        "HttpPost": {
            "Host": "127.0.0.1",
            "Port": 20028,
            "Suffix": "/onebot/v11/http",
            "Timeout": 0
        }
    }
}

启动命令

docker run -d -v /etc/appsettings.json:/app/appsettings.json eric1008818/lagrange.onebot:edge

环境

#101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 5.15.0-91-generic
using docker

正向ws断连会导致lagrange崩溃

使用ubuntu 22.04
lgr下的目前最新的actions里的
image
采用正向ws 从nb连接到在服务器上的lgr

lgr.log:

info: Lagrange.Core.BotContext[0]
      [2024-02-17 13:12:59] [MessagingLogic] [VERBOSE]: [MessageChain(330986863)(1772360572)] [Forward]: Sequence: 3454060 | [Mention]: @再聊二游是**(1935161782) | [Text]:   | [Mention]: @再聊二游是**(1935161782) | [Text]:  斗破大陆
?�
info: Lagrange.OneBot.Core.Network.Service.ForwardWSService[0]
      [ForwardWSService] Connected(Conn: 29f6742e-6815-4acb-b6ca-56dc8f193038)
info: Lagrange.Core.BotContext[0]
      [2024-02-17 13:13:02] [MessagingLogic] [VERBOSE]: [MessageChain(746562954)(1948263978)] [Text]: 好家伙
warn: Lagrange.OneBot.Core.Network.Service.ForwardWSService[0]
      [ForwardWSService: Disconnected(Conn: 29f6742e-6815-4acb-b6ca-56dc8f193038)
Unhandled exception. System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
   at System.Net.Sockets.NetworkStream.EndWrite(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
   at Lagrange.OneBot.Core.Network.Service.ForwardWSService.SendJsonAsync[T](T json, String identifier, CancellationToken cancellationToken) in /root/Lagrange.Core/Lagrange.OneBot/Core/Network/Service/ForwardWSService.cs:line 118
   at Lagrange.OneBot.Core.Network.LagrangeWebSvcCollection.<>c__DisplayClass6_1.<<StartAsync>b__0>d.MoveNext() in /root/Lagrange.Core/Lagrange.OneBot/Core/Network/LagrangeWebSvcCollection.cs:line 50
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
2/17/2024 1:13:02 PM [Info] Failed to send. Disconnecting. System.AggregateException: One or more errors occurred. (Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.)
 ---> System.ObjectDisposedException: Cannot access a disAborted (core dumped)

lgr的conf:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ConfigPath": {
    "Keystore": "./data/keystore.json",
    "DeviceInfo": "./data/device.json",
    "Database":  "./data/Lagrange.db"
  },
  "SignServerUrl": "url2sign",
  "Account": {
    "Uin": 09,
    "Password": "*",
    "Protocol": "Linux",
    "AutoReconnect": true,
    "GetOptimumServer": true
  },
  "Message": {
    "IgnoreSelf": true
  },
  "Implementations": [
    {
      "Type": "ForwardWebSocket",
      "Host": "0.0.0.0",
      "Port": 6700,
      "HeartBeatInterval": 5000,
      "AccessToken": "mytoken"
    }
  ]
}

nb2的日志:
这一段循环

02-17 15:34:36 [ERROR] nonebot | OneBot V11 | Error while setup websocket to ws://127.0.0.1:6700/. Trying to reconnect...
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/root/bot/.venv/lib/python3.10/site-packages/nonebot/__init__.py", line 333, in run
    get_driver().run(*args, **kwargs)
  File "/root/bot/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 185, in run
    uvicorn.run(
  File "/root/bot/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 587, in run
    server.run()
  File "/root/bot/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 62, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
> File "/root/bot/.venv/lib/python3.10/site-packages/nonebot/adapters/onebot/v11/adapter.py", line 331, in _forward_ws
    async with self.websocket(request) as ws:
  File "/usr/lib/python3.10/contextlib.py", line 199, in aenter
    return await anext(self.gen)
  File "/root/bot/.venv/lib/python3.10/site-packages/nonebot/internal/adapter/adapter.py", line 98, in websocket
    async with self.driver.websocket(setup) as ws:
  File "/usr/lib/python3.10/contextlib.py", line 199, in aenter
    return await anext(self.gen)
  File "/root/bot/.venv/lib/python3.10/site-packages/nonebot/drivers/websockets.py", line 74, in websocket
    async with connection as ws:
  File "/root/bot/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 629, in aenter
    return await self
  File "/root/bot/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 647, in await_impl_timeout
    return await self.await_impl()
  File "/root/bot/.venv/lib/python3.10/site-packages/websockets/legacy/client.py", line 651, in await_impl
    _transport, _protocol = await self._create_connection()
  File "uvloop/loop.pyx", line 2039, in create_connection
    raise exceptions[0]
  File "uvloop/loop.pyx", line 2016, in uvloop.loop.Loop.create_connection
    await waiter
ConnectionRefusedError: [Errno 111] Connection refused

nb2的配置:
.env.dev:

LOG_LEVEL=DEBUG
DRIVER=~fastapi+~websockets
ONEBOT_WS_URLS=["ws://127.0.0.1:6700/"]
ONEBOT_ACCESS_TOKEN=mytoken
SUPERUSERS=["012"]

抛砖引玉:一个不成熟的bot启动示例

说明:

1.启动示例:await LagrangeRunning.RunSync();
2._Utility.SaveJson方法很简单,自己写。
3.SaveDeviceInfo(BotDeviceInfo)和SaveKeyStore(bot.UpdateKeystore())放在online事件中不知道是否合理。
4.未解决问题:每次都要扫码登录(即使手机上已经勾选‘下次不扫码直接登录’)

代码如下:
using Lagrange.Core;
using Lagrange.Core.Common;
using Lagrange.Core.Common.Interface;
using Lagrange.Core.Common.Interface.Api;
using MyUtility;
namespace Lagrange.Running

{
public static class LagrangeRunning
{
static BotDeviceInfo BotDeviceInfo = LoadDeviceInfo();
static BotContext bot = BotFactory.Create(new BotConfig(), BotDeviceInfo, LoadKeyStore());

    static LagrangeRunning()
    {
        BotInit();
    }
    static void BotInit()
    {
        bot.Invoker.OnBotLogEvent += (context, @event) =>
        {
            if (@event.ToString().Contains("Heartbeat.Alive") == false)
                Console.WriteLine(@event.ToString());
        };

        bot.Invoker.OnBotOnlineEvent += (context, @event) =>
        {
            Console.WriteLine(@event.ToString());
            SaveDeviceInfo(BotDeviceInfo);
            SaveKeyStore(bot.UpdateKeystore());
        };
        bot.Invoker.OnGroupMessageReceived += (context, @event) =>
        {
            Console.WriteLine(@event.Chain.ToString());
        };
    }
    public static async Task RunSync()
    {
        var qrcode = bot.FetchQrCode().Result;
        if (qrcode == null) Console.WriteLine("Failed to fetch qrcode");
        else
        {
            File.WriteAllBytes("qrcode.png", qrcode);
            Console.WriteLine("请用手机QQ扫码登录:qrcode.png");
        }
        await bot.LoginByQrCode();
    }
    static BotDeviceInfo LoadDeviceInfo()
    {
        var deviceInfo = _Utility.LoadJson<BotDeviceInfo>("deviceinfo");
        if (deviceInfo != null) return deviceInfo;
        else return BotDeviceInfo.GenerateInfo();
    }

    static bool SaveDeviceInfo(BotDeviceInfo deviceInfo) => _Utility.SaveJson(deviceInfo, "deviceinfo");
    static BotKeystore LoadKeyStore()
    {
        var keyStore = _Utility.LoadJson<BotKeystore>("keystore");
        if (keyStore != null) return keyStore;
        else return new BotKeystore();
    }
    static bool SaveKeyStore(BotKeystore keyStore) => _Utility.SaveJson(keyStore, "keystore");


}

}

bot向正向websocket时发送长消息时报错

如何复现:
群聊中输入 .st 力量30str30敏捷80dex80意志90pow90体质40con40外貌70app70教育90edu90体型60siz60智力50灵感50int50san90san值90理智90理智值90幸运60运气60mp18魔法18hp10体力10会计5人类学1估价5考古学1取悦15魅惑15攀爬20计算机5计算机使用5电脑5信用25信誉25信用评级25克苏鲁0克苏鲁神话0cm0乔装50闪避50汽车20驾驶20汽车驾驶20电气维修10电子学1话术70斗殴25手枪20急救50历史5恐吓15跳跃20母语90法律45图书馆70图书馆使用70聆听70开锁41撬锁41锁匠41机械维修10医学1博物学10自然学10领航10导航10神秘学10重型操作1重型机械1操作重型机械1重型1说服10精神分析1心理学35骑术5妙手10侦查70潜行20生存10游泳20投掷20追踪40动物驯养5潜水1爆破1读唇1催眠1炮术1
日志:

warn: Lagrange.Core.BotContext[0]
      [2024-02-15 18:34:05] [BusinessContext] [WARNING]: Error while handling msf push: 12 trpc.msg.olpush.OlPushService.MsgPush
trce: Lagrange.Core.BotContext[0]
      [2024-02-15 18:34:05] [BusinessContext] [DEBUG]: 0000004F9CEF0380000000000000000400000029747270632E6D73672E6F6C707573682E4F6C50757368536572766963652E4D73675075736800000004000000000000000AA80100C8010265CDE892000004B10AAA090A6608E5D2E08A0D1218755F333147374444686E6F6C6A646F554D6F79506A7272671801200128E7C0EA860D423A08CDD4ADC40310011896072213E59684E5BF836B70EFBC8CE4BB8EE4B88D7363280130013A12E5919CE69CAFE7A094E7A9B6E4B8ADE5BF834808121E085220FEA3CEDB0228DDCD043092D1B7AE06380160FEA3CEDB82808080011A9F080A9C080A2708001092D1B7AE0618FEA3CEDB0220002809300038860140224A0CE5BEAEE8BDAFE99B85E9BB9112AE060AAB060AA4062E737420E58A9BE9878F33307374723330E6958FE68DB738306465783830E6848FE5BF973930706F773930E4BD93E8B4A83430636F6E3430E5A496E8B28C37306170703730E69599E882B239306564753930E4BD93E59E8B363073697A3630E699BAE58A9B3530E781B5E6849F3530696E74353073616E393073616EE580BC3930E79086E699BA3930E79086E699BAE580BC3930E5B9B8E8BF903630E8BF90E6B09436306D703138E9AD94E6B395313868703130E4BD93E58A9B3130E4BC9AE8AEA135E4BABAE7B1BBE5ADA631E4BCB0E4BBB735E88083E58FA4E5ADA631E58F96E682A63135E9AD85E683913135E69480E788AC3230E8AEA1E7AE97E69CBA35E8AEA1E7AE97E69CBAE4BDBFE794A835E794B5E8849135E4BFA1E794A83235E4BFA1E8AA893235E4BFA1E794A8E8AF84E7BAA73235E5858BE88B8FE9B28130E5858BE88B8FE9B281E7A59EE8AF9D30636D30E4B994E8A3853530E997AAE981BF3530E6B1BDE8BDA63230E9A9BEE9A9B63230E6B1BDE8BDA6E9A9BEE9A9B63230E794B5E6B094E7BBB4E4BFAE3130E794B5E5AD90E5ADA631E8AF9DE69CAF3730E69697E6AEB43235E6898BE69EAA3230E680A5E695913530E58E86E58FB235E68190E590933135E8B7B3E8B7833230E6AF8DE8AFAD3930E6B395E5BE8B3435E59BBEE4B9A6E9A6863730E59BBEE4B9A6E9A686E4BDBFE794A83730E88186E590AC3730E5BC80E994813431E692ACE994813431E99481E58CA03431E69CBAE6A2B0E7BBB4E4BFAE3130E58CBBE5ADA631E58D9AE789A9E5ADA63130E887AAE784B6E5ADA63130E9A286E888AA3130E5AFBCE888AA3130E7A59EE7A798E5ADA63130E9878DE59E8BE6938DE4BD9C31E9878DE59E8BE69CBAE6A2B031E6938DE4BD9CE9878DE59E8BE69CBAE6A2B031E9878DE59E8B31E8AFB4E69C8D3130E7B2BEE7A59EE58886E69E9031E5BF83E79086E5ADA63335E9AA91E69CAF35E5A699E6898B3130E4BEA6E69FA53730E6BD9CE8A18C3230E7949FE5AD983130E6B8B8E6B3B33230E68A95E68EB73230E8BFBDE8B8AA3430E58AA8E789A9E9A9AFE585BB35E6BD9CE6B0B431E78886E7A0B431E8AFBBE5948731E582ACE79CA031E782AEE69CAF311A005A00129901AA02950130023A40414C2F777A635773666E354F653734724962316C413666657A30594B4964576631736230344E422B63417766626C3258734854583850586D4B726575595769305000600068009A0148080820CB50800101C80100F00100F801009002009803D302A00308B00300C00301D00300E803008A0406080208011031900480818010B8048202C00400CA0400F80480800888050012044A020800121E82011B1213E59684E5BF836B70EFBC8CE4BB8EE4B88D7363180120082801
warn: Lagrange.Core.BotContext[0]
      [2024-02-15 18:34:05] [BusinessContext] [WARNING]: Specified argument was out of the range of valid values. (Parameter 'length')
trce: Lagrange.Core.BotContext[0]

请求实现Onebot中的get_friend_list

在使用Overflow连接Lagrange时,由于Lagrange未实现get_friend_list而导致Overflow完全无法启动

Overflow日志中的报错部分如下:

2024-01-03 13:32:15 W/Onebot: Request failed: [get_friend_list, echo=2] 
2024-01-03 13:32:15 E/main: Failed to init MiraiConsole.
java.lang.NullPointerException: impl.getFriendList().data must not be null
        at top.mrxiaom.overflow.internal.contact.BotWrapper.updateContacts(BotWrapper.kt:52)
        at top.mrxiaom.overflow.internal.contact.BotWrapper$updateContacts$1.invokeSuspend(BotWrapper.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at top.mrxiaom.overflow.internal.plugin.OverflowCoreAsPlugin$TheLoader.enable(OverflowCoreAsPlugin.kt:155)
        at net.mamoe.mirai.console.plugin.PluginManager.enablePlugin(PluginManager.kt:173)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.enableAllLoadedPlugins$mirai_console(PluginManagerImpl.kt:193)
        at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:360)
        at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:512)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:182)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:181)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:59)

Lagrange中相关日志如下(敏感信息已用星号代替):

trce: Lagrange.OneBot.Core.Network.Service.ForwardWSService[0]
      [ForwardWSService] Receive(Conn: **********): {"action":"get_friend_list","echo":2}
trce: Lagrange.OneBot.Core.Network.Service.ForwardWSService[0]
      [ForwardWSService] Send: {"status":"failed","retcode":404,"data":null,"echo":2}

新QQ无法扫码登录

新申请的QQ,扫描登录提示:

fail: Lagrange.Core.BotContext[0]
[2024-02-01 21:44:04] [WtExchangeLogic] [FATAL]: Login failed: 45
fail: Lagrange.Core.BotContext[0]
[2024-02-01 21:44:04] [WtExchangeLogic] [FATAL]: Tag: 禁止登录
State: 登录失败,请前往QQ官网im.qq.com下载最新版QQ后重试,或通过问题反馈与我们联系。

无法登录

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.