Skip to content

Commit

Permalink
chore: 与上游同步
Browse files Browse the repository at this point in the history
  • Loading branch information
fy0 committed Nov 1, 2024
2 parents 1b11b0f + 0f14c8c commit d5bdd3c
Show file tree
Hide file tree
Showing 360 changed files with 6,767 additions and 1,895 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_case_contents_when_block = false
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true

Expand Down
26 changes: 13 additions & 13 deletions Lagrange.Core/BotContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ public class BotContext : IDisposable
public string? BotName => ContextCollection.Keystore.Info?.Name;

internal readonly Utility.TaskScheduler Scheduler;

internal readonly ContextCollection ContextCollection;

private readonly BotAppInfo _appInfo;
private readonly BotConfig _config;
public BotAppInfo AppInfo { get; }

public BotConfig Config { get; }

private readonly BotDeviceInfo _deviceInfo;

private readonly BotKeystore _keystore;

internal BotContext(BotConfig config, BotDeviceInfo deviceInfo, BotKeystore keystore)
{
Invoker = new EventInvoker(this);
Scheduler = new Utility.TaskScheduler();
_config = config;
_appInfo = BotAppInfo.ProtocolToAppInfo[config.Protocol];

Config = config;
AppInfo = BotAppInfo.ProtocolToAppInfo[config.Protocol];
_deviceInfo = deviceInfo;
_keystore = keystore;
ContextCollection = new ContextCollection(_keystore, _appInfo, _deviceInfo, _config, Invoker, Scheduler);

ContextCollection = new ContextCollection(_keystore, AppInfo, _deviceInfo, Config, Invoker, Scheduler);
}

public void Dispose()
{
ContextCollection.Dispose();
Expand Down
10 changes: 10 additions & 0 deletions Lagrange.Core/Common/Entity/BotCustomStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Lagrange.Core.Common.Entity;

public class BotStatus
{
public uint StatusId { get; set; }

public uint? FaceId { get; set; }

public string? Msg { get; set; }
}
3 changes: 2 additions & 1 deletion Lagrange.Core/Common/Entity/BotFileEntry.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotFileEntry : IBotFSEntry
{
internal string FileId { get; }
public string FileId { get; }

public string FileName { get; }

Expand Down
1 change: 1 addition & 0 deletions Lagrange.Core/Common/Entity/BotFolderEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotFolderEntry : IBotFSEntry
{
public string FolderId { get; set; }
Expand Down
24 changes: 15 additions & 9 deletions Lagrange.Core/Common/Entity/BotFriend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,35 @@ internal BotFriend()
Remarks = string.Empty;
PersonalSign = string.Empty;
Qid = string.Empty;
Group = default;
Avatar = string.Empty;
}
internal BotFriend(uint uin,string uid, string nickname, string remarks, string personalSign, string qid)

internal BotFriend(uint uin, string uid, string nickname, string remarks, string personalSign, string qid, BotFriendGroup group = default)
{
Uin = uin;
Uid = uid;
Nickname = nickname;
Remarks = remarks;
PersonalSign = personalSign;
Qid = qid;
Group = group;
Avatar = $"https://q1.qlogo.cn/g?b=qq&nk={uin}&s=640";
}

public uint Uin { get; set; }

internal string Uid { get; set; }

public string Nickname { get; set; }

public string Remarks { get; set; }

public string PersonalSign { get; set; }

public string Qid { get; set; }

public string Avatar => $"https://q1.qlogo.cn/g?b=qq&nk={Uin}&s=640";
public BotFriendGroup Group { get; set; }

public string Avatar { get; set; }
}
15 changes: 15 additions & 0 deletions Lagrange.Core/Common/Entity/BotFriendGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public struct BotFriendGroup
{
public uint GroupId { get; }

public string GroupName { get; }

internal BotFriendGroup(uint groupId, string groupName)
{
GroupId = groupId;
GroupName = groupName;
}
}
39 changes: 39 additions & 0 deletions Lagrange.Core/Common/Entity/BotFriendRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotFriendRequest
{
public BotFriendRequest(string targetUid, string sourceUid, uint eventState, string comment, string source, uint time)
{
TargetUid = targetUid;
SourceUid = sourceUid;
EventState = (State)eventState;
Comment = comment;
Source = source;
Time = DateTime.UnixEpoch.AddSeconds(time);
}

public string TargetUid { get; set; }

public uint TargetUin { get; set; }

public string SourceUid { get; set; }

public uint SourceUin { get; set; }

public State EventState { get; set; }


public string Comment { get; set; }

public string Source { get; set; }

public DateTime Time { get; set; }

public enum State
{
Pending = 1,
Disapproved = 2,
Approved = 3,
}
}
24 changes: 24 additions & 0 deletions Lagrange.Core/Common/Entity/BotGetGroupTodoResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotGetGroupTodoResult
{
public int Retcode { get; }

public string? ResultMessage { get; }

public uint GroupUin { get; }

public uint Sequence { get; }

public string Preview { get; }

public BotGetGroupTodoResult(int retcode, string? resultMessage, uint groupUin, uint sequence, string preview)
{
Retcode = retcode;
ResultMessage = resultMessage;
GroupUin = groupUin;
Sequence = sequence;
Preview = preview;
}
}
15 changes: 14 additions & 1 deletion Lagrange.Core/Common/Entity/BotGroup.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotGroup
{
internal BotGroup(uint groupUin, string groupName, uint memberCount, uint maxMember)
internal BotGroup(uint groupUin, string groupName, uint memberCount, uint maxMember, uint createTime, string? description, string? question, string? announcement)
{
GroupUin = groupUin;
GroupName = groupName;
MemberCount = memberCount;
MaxMember = maxMember;
CreateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(createTime);
Description = description;
Question = question;
Announcement = announcement;
}

public uint GroupUin { get; }
Expand All @@ -17,6 +22,14 @@ internal BotGroup(uint groupUin, string groupName, uint memberCount, uint maxMem
public uint MemberCount { get; }

public uint MaxMember { get; }

public DateTime CreateTime { get; }

public string? Description { get; }

public string? Question { get; }

public string? Announcement { get; }

public string Avatar => $"https://p.qlogo.cn/gh/{GroupUin}/{GroupUin}/0/";
}
52 changes: 52 additions & 0 deletions Lagrange.Core/Common/Entity/BotGroupClockInResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace Lagrange.Core.Common.Entity;

[Serializable]
public class BotGroupClockInResult
{
public BotGroupClockInResult() { }

public BotGroupClockInResult(bool isSuccess)
{
IsSuccess = isSuccess;
}

/// <summary>
/// Is the clock in successful
/// </summary>
public bool IsSuccess { get; set; } = false;

/// <summary>
/// Maybe "今日已成功打卡"
/// </summary>
public string Title { get; set; } = string.Empty;

/// <summary>
/// Maybe "已打卡N天"
/// </summary>
public string KeepDayText { get; set; } = string.Empty;

/// <summary>
/// Maybe "群内排名第N位"
/// </summary>
public string GroupRankText { get; set; } = string.Empty;

/// <summary>
/// The utc time of clock in
/// </summary>
public DateTime ClockInUtcTime { get; set; } = DateTime.UnixEpoch; // 打卡时间

/// <summary>
/// Detail info url
/// </summary>
public string DetailUrl { get; set; } = string.Empty; // https://qun.qq.com/v2/signin/detail?...

public static BotGroupClockInResult Fail() => new BotGroupClockInResult()
{
IsSuccess = false
};

public static BotGroupClockInResult Success() => new BotGroupClockInResult()
{
IsSuccess = true
};
}
23 changes: 13 additions & 10 deletions Lagrange.Core/Common/Entity/BotGroupMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ internal BotGroupMember()
MemberName = string.Empty;
SpecialTitle = string.Empty;
}
internal BotGroupMember(uint uin, string uid, GroupMemberPermission permission, uint groupLevel, string? memberCard,
string memberName, string? specialTitle, DateTime joinTime, DateTime lastMsgTime)

internal BotGroupMember(uint uin, string uid, GroupMemberPermission permission, uint groupLevel, string? memberCard,
string memberName, string? specialTitle, DateTime joinTime, DateTime lastMsgTime,DateTime shutUpTimestamp)
{
Uin = uin;
Uid = uid;
Expand All @@ -26,26 +26,29 @@ internal BotGroupMember(uint uin, string uid, GroupMemberPermission permission,
SpecialTitle = specialTitle;
JoinTime = joinTime;
LastMsgTime = lastMsgTime;
ShutUpTimestamp = shutUpTimestamp;
}

public uint Uin { get; set; }

internal string Uid { get; set; }

public GroupMemberPermission Permission { get; set; }

public uint GroupLevel { get; set; }

public string? MemberCard { get; set; }

public string MemberName { get; set; }

public string? SpecialTitle { get; set; }

public DateTime JoinTime { get; set; }

public DateTime LastMsgTime { get; set; }

public DateTime ShutUpTimestamp { get; set; }

public string Avatar => $"https://q1.qlogo.cn/g?b=qq&nk={Uin}&s=640";
}

Expand Down
20 changes: 20 additions & 0 deletions Lagrange.Core/Common/Entity/BotGroupReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Lagrange.Core.Common.Entity;

public class BotGroupReaction
{
public string FaceId { get; set; }

public uint Type { get; set; }

public uint Count { get; set; }

public bool IsAdded { get; set; }

public BotGroupReaction(string faceId, uint type, uint count, bool isAdded)
{
FaceId = faceId;
Type = type;
Count = count;
IsAdded = isAdded;
}
}
Loading

0 comments on commit d5bdd3c

Please sign in to comment.