0.0.2-alpha

This commit is contained in:
Linwenxuan05 2023-06-29 19:38:03 +08:00
parent 522817e4b0
commit 2764d7c29a
13 changed files with 66 additions and 9 deletions

View file

@ -17,6 +17,11 @@ public static class BotExt
public static async Task<bool> LoginByPassword(this BotContext bot)
=> await bot.ContextCollection.Business.WtExchangeLogic.LoginByPassword();
/// <summary>
/// Use this method to update keystore, so EasyLogin may be preformed next time by using this keystore
/// </summary>
/// <param name="bot"></param>
/// <returns></returns>
public static BotKeystore UpdateKeystore(this BotContext bot)
=> bot.ContextCollection.Keystore;
}

View file

@ -0,0 +1,6 @@
namespace Lagrange.Core.Common.Interface.Api;
public static class OperationExt
{
}

View file

@ -0,0 +1,17 @@
using Lagrange.Core.Core.Context.Attributes;
using Lagrange.Core.Core.Event.Protocol;
namespace Lagrange.Core.Core.Context.Logic.Implementation;
[BusinessLogic("OperationLogic", "Manage the user operation of the bot")]
internal class OperationLogic : LogicBase
{
private const string Tag = nameof(OperationLogic);
internal OperationLogic(ContextCollection collection) : base(collection) { }
public override async Task Incoming(ProtocolEvent e)
{
}
}

View file

@ -0,0 +1,6 @@
namespace Lagrange.Core.Core.Event.EventArg;
public class TempMessageEvent : EventBase
{
}

View file

@ -11,4 +11,11 @@ internal class PushMessageEvent : ProtocolEvent
}
public static PushMessageEvent Create() => new(0);
public enum MessageType
{
Friend,
Group,
Temp,
}
}

View file

@ -13,6 +13,8 @@ public class OidbSvcTrpcTcp0xE37_800
[ProtoMember(2)] public int Field2 { get; set; } // Unknown
[ProtoMember(10)] public OidbSvcTrpcTcp0xE37_800Body Body { get; set; }
[ProtoMember(101)] public int Field101 { get; set; } // Unknown
[ProtoMember(102)] public int Field102 { get; set; } // Unknown

View file

@ -8,7 +8,7 @@ namespace Lagrange.Core.Core.Packets.Service.Oidb;
/// <summary>
/// This class to declear a OidbSvcTrpcTcp packet 我愿称之为Protobuf版Tlv
/// <para><see cref="OidbSvcTrpcTcp0xE37_1700"/> Responsible for the uploading of NotOnlineFile, originally from OfflineFilleHandler_1700 of legacy oicq protocol</para>
/// <para><see cref="OidbSvcTrpcTcp0xE37_1700"/> Responsible for the uploading of NotOnlineFile, originally from OfflineFilleHandleSvr.pb_ftn_CMD_REQ_APPLY_UPLOAD_V3-1700 of legacy oicq protocol</para>
/// </summary>
[ProtoContract]
internal class OidbSvcTrpcTcpBase<T> where T : class

View file

@ -60,7 +60,7 @@ internal class KeyExchangeService : BaseService<KeyExchangeEvent>
Serializer.Serialize(stream, plain1);
var gcmCalc1 = new AesGcmImpl().Encrypt(stream.ToArray(), keystore.PrimeImpl.ShareKey);
var timestamp = (uint)(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds;
var timestamp = (uint)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
var plain2 = new SsoKeyExchangePlain2
{
PublicKey = keystore.PrimeImpl.GetPublicKey(false),

View file

@ -15,8 +15,8 @@ using ProtoBuf;
namespace Lagrange.Core.Core.Service.Login;
[Service("trpc.login.ecdh.EcdhService.SsoNTLoginPasswordLogin")]
[EventSubscribe(typeof(PasswordLoginEvent))]
[Service("trpc.login.ecdh.EcdhService.SsoNTLoginPasswordLogin")]
internal class PasswordLoginService : BaseService<PasswordLoginEvent>
{
protected override bool Build(PasswordLoginEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,

View file

@ -5,6 +5,7 @@ using Lagrange.Core.Core.Packets;
using Lagrange.Core.Core.Packets.System;
using Lagrange.Core.Core.Service.Abstraction;
using Lagrange.Core.Utility.Binary;
using Lagrange.Core.Utility.Extension;
using ProtoBuf;
namespace Lagrange.Core.Core.Service.System;
@ -28,6 +29,9 @@ internal class SsoAliveService : BaseService<SsoAliveEvent>
protected override bool Parse(SsoPacket input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
out SsoAliveEvent output, out List<ProtocolEvent>? extraEvents)
{
var payload = input.Payload.ReadBytes(BinaryPacket.Prefix.Uint32 | BinaryPacket.Prefix.WithPrefix);
Console.WriteLine(payload.Hex());
output = SsoAliveEvent.Result();
extraEvents = null;
return true;

View file

@ -59,15 +59,13 @@ public class FileEntity : IMessageEntity
IMessageEntity? IMessageEntity.UnpackMessageContent(ReadOnlySpan<byte> content)
{
var notOnlineFile = Serializer.Deserialize<NotOnlineFile>(content);
var extra = Serializer.Deserialize<FileExtra>(content);
var notOnlineFile = extra.File;
return notOnlineFile is { FileSize: not null, FileName: not null, FileMd5: not null }
? new FileEntity((long)notOnlineFile.FileSize, notOnlineFile.FileName, notOnlineFile.FileMd5)
: null;
}
public string ToPreviewString()
{
throw new NotImplementedException();
}
public string ToPreviewString() => $"[File] {FileName} ({FileSize})";
}

View file

@ -1,3 +1,5 @@
using Lagrange.Core.Message.Entity;
namespace Lagrange.Core.Message;
/// <summary>
@ -16,4 +18,14 @@ public sealed class MessageBuilder
}
public static MessageBuilder Group(uint groupUin, uint memberUin) => new(new MessageChain(groupUin, memberUin));
public MessageBuilder Text(string text)
{
var textEntity = new TextEntity(text);
_chain.Add(textEntity);
return this;
}
public MessageChain Build() => _chain;
}

View file

@ -81,7 +81,7 @@ internal class MessagePacker
{
var chain = ParseChain(message);
if (message.Body?.RichText.Elems != null)
if (message.Body.RichText?.Elems != null)
{
foreach (var element in message.Body.RichText.Elems)
{