diff --git a/Lagrange.Core/Common/Interface/Api/BotExt.cs b/Lagrange.Core/Common/Interface/Api/BotExt.cs
index 951b2946b..e709267ad 100644
--- a/Lagrange.Core/Common/Interface/Api/BotExt.cs
+++ b/Lagrange.Core/Common/Interface/Api/BotExt.cs
@@ -9,37 +9,18 @@ public static class BotExt
///
/// return url and qrcode image in PNG format
public static Task<(string Url, byte[] QrCode)?> FetchQrCode(this BotContext bot)
- => bot.ContextCollection.Business.WtExchangeLogic.FetchQrCode(CancellationToken.None);
-
- ///
- /// Fetch the qrcode for QRCode Login
- ///
- /// return url and qrcode image in PNG format
- public static Task<(string Url, byte[] QrCode)?> FetchQrCode(this BotContext bot, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.WtExchangeLogic.FetchQrCode(cancellationToken);
+ => bot.ContextCollection.Business.WtExchangeLogic.FetchQrCode();
///
/// Use this method to login by QrCode, you should call first
///
- public static Task LoginByQrCode(this BotContext bot)
- => bot.ContextCollection.Business.WtExchangeLogic.LoginByQrCode(CancellationToken.None);
-
- ///
- /// Use this method to login by QrCode, you should call first
- ///
- public static Task LoginByQrCode(this BotContext bot, CancellationToken cancellationToken)
+ public static Task LoginByQrCode(this BotContext bot, CancellationToken cancellationToken = default)
=> bot.ContextCollection.Business.WtExchangeLogic.LoginByQrCode(cancellationToken);
///
/// Use this method to login by password, EasyLogin may be preformed if there is sig in
///
- public static Task LoginByPassword(this BotContext bot)
- => bot.ContextCollection.Business.WtExchangeLogic.LoginByPassword(CancellationToken.None);
-
- ///
- /// Use this method to login by password, EasyLogin may be preformed if there is sig in
- ///
- public static Task LoginByPassword(this BotContext bot, CancellationToken cancellationToken)
+ public static Task LoginByPassword(this BotContext bot, CancellationToken cancellationToken = default)
=> bot.ContextCollection.Business.WtExchangeLogic.LoginByPassword(cancellationToken);
///
@@ -49,11 +30,8 @@ public static Task LoginByPassword(this BotContext bot, CancellationToken
public static bool SubmitCaptcha(this BotContext bot, string ticket, string randStr)
=> bot.ContextCollection.Business.WtExchangeLogic.SubmitCaptcha(ticket, randStr);
- public static Task SetNeedToConfirmSwitch(this BotContext bot, bool needToConfirm)
- => bot.ContextCollection.Business.OperationLogic.SetNeedToConfirmSwitch(needToConfirm, CancellationToken.None);
-
- public static Task SetNeedToConfirmSwitch(this BotContext bot, bool needToConfirm, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetNeedToConfirmSwitch(needToConfirm, cancellationToken);
+ public static Task SetNeedToConfirmSwitch(this BotContext bot, bool needToConfirm)
+ => bot.ContextCollection.Business.OperationLogic.SetNeedToConfirmSwitch(needToConfirm);
///
/// Use this method to update keystore, so EasyLogin may be preformed next time by using this keystore
@@ -68,4 +46,4 @@ public static BotKeystore UpdateKeystore(this BotContext bot)
///
public static BotDeviceInfo UpdateDeviceInfo(this BotContext bot)
=> bot.ContextCollection.Device;
-}
+}
\ No newline at end of file
diff --git a/Lagrange.Core/Common/Interface/Api/GroupExt.cs b/Lagrange.Core/Common/Interface/Api/GroupExt.cs
index 3e9327a7b..6e7270e9f 100644
--- a/Lagrange.Core/Common/Interface/Api/GroupExt.cs
+++ b/Lagrange.Core/Common/Interface/Api/GroupExt.cs
@@ -1,4 +1,3 @@
-using System.Globalization;
using Lagrange.Core.Common.Entity;
using Lagrange.Core.Event.EventArg;
using Lagrange.Core.Message;
@@ -17,19 +16,7 @@ public static class GroupExt
/// The duration in seconds, 0 for unmute member
/// Successfully muted or not
public static Task MuteGroupMember(this BotContext bot, uint groupUin, uint targetUin, uint duration)
- => bot.ContextCollection.Business.OperationLogic.MuteGroupMember(groupUin, targetUin, duration, CancellationToken.None);
-
- ///
- /// Mute the member in the group, Bot must be admin
- ///
- /// target BotContext
- /// The uin for target group
- /// The uin for target member in such group
- /// The duration in seconds, 0 for unmute member
- /// The cancellation token
- /// Successfully muted or not
- public static Task MuteGroupMember(this BotContext bot, uint groupUin, uint targetUin, uint duration, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.MuteGroupMember(groupUin, targetUin, duration, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.MuteGroupMember(groupUin, targetUin, duration);
///
/// Mute the group
@@ -39,18 +26,7 @@ public static Task MuteGroupMember(this BotContext bot, uint groupUin, uin
/// true for mute and false for unmute
/// Successfully muted or not
public static Task MuteGroupGlobal(this BotContext bot, uint groupUin, bool isMute)
- => bot.ContextCollection.Business.OperationLogic.MuteGroupGlobal(groupUin, isMute, CancellationToken.None);
-
- ///
- /// Mute the group
- ///
- /// target BotContext
- /// The uin for target group
- /// true for mute and false for unmute
- /// The cancellation token
- /// Successfully muted or not
- public static Task MuteGroupGlobal(this BotContext bot, uint groupUin, bool isMute, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.MuteGroupGlobal(groupUin, isMute, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.MuteGroupGlobal(groupUin, isMute);
///
///
@@ -61,230 +37,115 @@ public static Task MuteGroupGlobal(this BotContext bot, uint groupUin, boo
/// whether the kicked member can request
/// Successfully kicked or not
public static Task KickGroupMember(this BotContext bot, uint groupUin, uint targetUin, bool rejectAddRequest)
- => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, "", CancellationToken.None);
-
-
- ///
- ///
- ///
- /// target BotContext
- /// The uin for target group
- /// The uin for target member in such group
- /// whether the kicked member can request
- /// The cancellation token
- /// Successfully kicked or not
- public static Task KickGroupMember(this BotContext bot, uint groupUin, uint targetUin, bool rejectAddRequest, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, "", cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, "");
public static Task KickGroupMember(this BotContext bot, uint groupUin, uint targetUin, bool rejectAddRequest, string reason)
- => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, reason, CancellationToken.None);
-
- public static Task KickGroupMember(this BotContext bot, uint groupUin, uint targetUin, bool rejectAddRequest, string reason, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, reason, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.KickGroupMember(groupUin, targetUin, rejectAddRequest, reason);
public static Task SetGroupAdmin(this BotContext bot, uint groupUin, uint targetUin, bool isAdmin)
- => bot.ContextCollection.Business.OperationLogic.SetGroupAdmin(groupUin, targetUin, isAdmin, CancellationToken.None);
-
- public static Task SetGroupAdmin(this BotContext bot, uint groupUin, uint targetUin, bool isAdmin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupAdmin(groupUin, targetUin, isAdmin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupAdmin(groupUin, targetUin, isAdmin);
// 300204 Check group manager:Not an administrator
public static Task<(int, string?)> SetGroupTodo(this BotContext bot, uint groupUin, uint sequence)
- => bot.ContextCollection.Business.OperationLogic.SetGroupTodo(groupUin, sequence, CancellationToken.None);
-
- // 300204 Check group manager:Not an administrator
- public static Task<(int, string?)> SetGroupTodo(this BotContext bot, uint groupUin, uint sequence, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupTodo(groupUin, sequence, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupTodo(groupUin, sequence);
public static Task<(int, string?)> RemoveGroupTodo(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.RemoveGroupTodo(groupUin, CancellationToken.None);
-
- public static Task<(int, string?)> RemoveGroupTodo(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RemoveGroupTodo(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RemoveGroupTodo(groupUin);
public static Task<(int, string?)> FinishGroupTodo(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.FinishGroupTodo(groupUin, CancellationToken.None);
-
- public static Task<(int, string?)> FinishGroupTodo(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FinishGroupTodo(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FinishGroupTodo(groupUin);
public static Task GetGroupTodo(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.GetGroupTodo(groupUin, CancellationToken.None);
-
- public static Task GetGroupTodo(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GetGroupTodo(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GetGroupTodo(groupUin);
public static Task SetGroupBot(this BotContext bot, uint targetUin, uint On, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.SetGroupBot(targetUin, On, groupUin, CancellationToken.None);
-
- public static Task SetGroupBot(this BotContext bot, uint targetUin, uint On, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupBot(targetUin, On, groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupBot(targetUin, On, groupUin);
[Obsolete("Cosider using SetGroupBotHD(BotContext, uint, uint, string?, string?) instead")]
public static Task SetGroupBotHD(this BotContext bot, uint targetUin, uint groupUin)
=> bot.SetGroupBotHD(targetUin, groupUin, null, null);
public static Task SetGroupBotHD(this BotContext bot, uint targetUin, uint groupUin, string? data_1, string? data_2)
- => bot.ContextCollection.Business.OperationLogic.SetGroupBotHD(targetUin, groupUin, data_1, data_2, CancellationToken.None);
- public static Task SetGroupBotHD(this BotContext bot, uint targetUin, uint groupUin, string? data_1, string? data_2, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupBotHD(targetUin, groupUin, data_1, data_2, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupBotHD(targetUin, groupUin, data_1, data_2);
public static Task RenameGroupMember(this BotContext bot, uint groupUin, uint targetUin, string targetName)
- => bot.ContextCollection.Business.OperationLogic.RenameGroupMember(groupUin, targetUin, targetName, CancellationToken.None);
-
- public static Task RenameGroupMember(this BotContext bot, uint groupUin, uint targetUin, string targetName, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RenameGroupMember(groupUin, targetUin, targetName, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RenameGroupMember(groupUin, targetUin, targetName);
public static Task RenameGroup(this BotContext bot, uint groupUin, string targetName)
- => bot.ContextCollection.Business.OperationLogic.RenameGroup(groupUin, targetName, CancellationToken.None);
-
- public static Task RenameGroup(this BotContext bot, uint groupUin, string targetName, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RenameGroup(groupUin, targetName, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RenameGroup(groupUin, targetName);
public static Task RemarkGroup(this BotContext bot, uint groupUin, string targetRemark)
- => bot.ContextCollection.Business.OperationLogic.RemarkGroup(groupUin, targetRemark, CancellationToken.None);
-
- public static Task RemarkGroup(this BotContext bot, uint groupUin, string targetRemark, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RemarkGroup(groupUin, targetRemark, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RemarkGroup(groupUin, targetRemark);
public static Task LeaveGroup(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.LeaveGroup(groupUin, CancellationToken.None);
-
- public static Task LeaveGroup(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.LeaveGroup(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.LeaveGroup(groupUin);
public static Task InviteGroup(this BotContext bot, uint groupUin, Dictionary invitedUins)
- => bot.ContextCollection.Business.OperationLogic.InviteGroup(groupUin, invitedUins, CancellationToken.None);
-
- public static Task InviteGroup(this BotContext bot, uint groupUin, Dictionary invitedUins, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.InviteGroup(groupUin, invitedUins, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.InviteGroup(groupUin, invitedUins);
public static Task SetGroupRequest(this BotContext bot, BotGroupRequest request, bool accept = true, string reason = "")
- => bot.ContextCollection.Business.OperationLogic.SetGroupRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason, CancellationToken.None);
-
- public static Task SetGroupRequest(this BotContext bot, BotGroupRequest request, bool accept, string reason, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason);
public static Task SetGroupFilteredRequest(this BotContext bot, BotGroupRequest request, bool accept = true, string reason = "")
- => bot.ContextCollection.Business.OperationLogic.SetGroupFilteredRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason, CancellationToken.None);
-
- public static Task SetGroupFilteredRequest(this BotContext bot, BotGroupRequest request, bool accept, string reason, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetGroupFilteredRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetGroupFilteredRequest(request.GroupUin, request.Sequence, (uint)request.EventType, accept, reason);
public static Task SetFriendRequest(this BotContext bot, FriendRequestEvent request, bool accept = true)
- => bot.ContextCollection.Business.OperationLogic.SetFriendRequest(request.SourceUid, accept, CancellationToken.None);
-
- public static Task SetFriendRequest(this BotContext bot, FriendRequestEvent request, bool accept, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetFriendRequest(request.SourceUid, accept, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetFriendRequest(request.SourceUid, accept);
public static Task GroupPoke(this BotContext bot, uint groupUin, uint friendUin)
- => bot.ContextCollection.Business.OperationLogic.GroupPoke(groupUin, friendUin, CancellationToken.None);
-
- public static Task GroupPoke(this BotContext bot, uint groupUin, uint friendUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupPoke(groupUin, friendUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupPoke(groupUin, friendUin);
public static Task SetEssenceMessage(this BotContext bot, MessageChain chain)
- => bot.ContextCollection.Business.OperationLogic.SetEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF), CancellationToken.None);
-
- public static Task SetEssenceMessage(this BotContext bot, MessageChain chain, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF), cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF));
public static Task RemoveEssenceMessage(this BotContext bot, MessageChain chain)
- => bot.ContextCollection.Business.OperationLogic.RemoveEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF), CancellationToken.None);
-
- public static Task RemoveEssenceMessage(this BotContext bot, MessageChain chain, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RemoveEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF), cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RemoveEssenceMessage(chain.GroupUin ?? 0, chain.Sequence, (uint)(chain.MessageId & 0xFFFFFFFF));
public static Task GroupSetSpecialTitle(this BotContext bot, uint groupUin, uint targetUin, string title)
- => bot.ContextCollection.Business.OperationLogic.GroupSetSpecialTitle(groupUin, targetUin, title, CancellationToken.None);
-
- public static Task GroupSetSpecialTitle(this BotContext bot, uint groupUin, uint targetUin, string title, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupSetSpecialTitle(groupUin, targetUin, title, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupSetSpecialTitle(groupUin, targetUin, title);
public static Task GroupSetMessageReaction(this BotContext bot, uint groupUin, uint sequence, string code)
- => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, true, CancellationToken.None);
-
- public static Task GroupSetMessageReaction(this BotContext bot, uint groupUin, uint sequence, string code, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, true, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, true);
public static Task GroupSetMessageReaction(this BotContext bot, uint groupUin, uint sequence, string code, bool isSet)
- => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, isSet, CancellationToken.None);
-
- public static Task GroupSetMessageReaction(this BotContext bot, uint groupUin, uint sequence, string code, bool isSet, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, isSet, cancellationToken);
-
+ => bot.ContextCollection.Business.OperationLogic.SetMessageReaction(groupUin, sequence, code, isSet);
+
public static Task GroupSetAvatar(this BotContext bot, uint groupUin, ImageEntity imageEntity)
- => bot.ContextCollection.Business.OperationLogic.GroupSetAvatar(groupUin, imageEntity, CancellationToken.None);
+ => bot.ContextCollection.Business.OperationLogic.GroupSetAvatar(groupUin, imageEntity);
- public static Task GroupSetAvatar(this BotContext bot, uint groupUin, ImageEntity imageEntity, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupSetAvatar(groupUin, imageEntity, cancellationToken);
-
public static Task<(uint, uint)> GroupRemainAtAll(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.GroupRemainAtAll(groupUin, CancellationToken.None);
-
- public static Task<(uint, uint)> GroupRemainAtAll(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupRemainAtAll(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupRemainAtAll(groupUin);
#region Group File System
public static Task FetchGroupFSSpace(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSSpace(groupUin, CancellationToken.None);
-
- public static Task FetchGroupFSSpace(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSSpace(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroupFSSpace(groupUin);
public static Task FetchGroupFSCount(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSCount(groupUin, CancellationToken.None);
-
- public static Task FetchGroupFSCount(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSCount(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroupFSCount(groupUin);
public static Task> FetchGroupFSList(this BotContext bot, uint groupUin, string targetDirectory = "/")
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSList(groupUin, targetDirectory, CancellationToken.None);
-
- public static Task> FetchGroupFSList(this BotContext bot, uint groupUin, string targetDirectory, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSList(groupUin, targetDirectory, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroupFSList(groupUin, targetDirectory);
public static Task FetchGroupFSDownload(this BotContext bot, uint groupUin, string fileId)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSDownload(groupUin, fileId, CancellationToken.None);
-
- public static Task FetchGroupFSDownload(this BotContext bot, uint groupUin, string fileId, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupFSDownload(groupUin, fileId, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroupFSDownload(groupUin, fileId);
public static Task<(int RetCode, string RetMsg)> GroupFSMove(this BotContext bot, uint groupUin, string fileId, string parentDirectory, string targetDirectory)
- => bot.ContextCollection.Business.OperationLogic.GroupFSMove(groupUin, fileId, parentDirectory, targetDirectory, CancellationToken.None);
-
- public static Task<(int RetCode, string RetMsg)> GroupFSMove(this BotContext bot, uint groupUin, string fileId, string parentDirectory, string targetDirectory, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSMove(groupUin, fileId, parentDirectory, targetDirectory, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSMove(groupUin, fileId, parentDirectory, targetDirectory);
public static Task<(int RetCode, string RetMsg)> GroupFSDelete(this BotContext bot, uint groupUin, string fileId)
- => bot.ContextCollection.Business.OperationLogic.GroupFSDelete(groupUin, fileId, CancellationToken.None);
-
- public static Task<(int RetCode, string RetMsg)> GroupFSDelete(this BotContext bot, uint groupUin, string fileId, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSDelete(groupUin, fileId, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSDelete(groupUin, fileId);
public static Task<(int RetCode, string RetMsg)> GroupFSCreateFolder(this BotContext bot, uint groupUin, string name)
- => bot.ContextCollection.Business.OperationLogic.GroupFSCreateFolder(groupUin, name, CancellationToken.None);
-
- public static Task<(int RetCode, string RetMsg)> GroupFSCreateFolder(this BotContext bot, uint groupUin, string name, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSCreateFolder(groupUin, name, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSCreateFolder(groupUin, name);
public static Task<(int RetCode, string RetMsg)> GroupFSDeleteFolder(this BotContext bot, uint groupUin, string folderId)
- => bot.ContextCollection.Business.OperationLogic.GroupFSDeleteFolder(groupUin, folderId, CancellationToken.None);
-
- public static Task<(int RetCode, string RetMsg)> GroupFSDeleteFolder(this BotContext bot, uint groupUin, string folderId, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSDeleteFolder(groupUin, folderId, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSDeleteFolder(groupUin, folderId);
public static Task<(int RetCode, string RetMsg)> GroupFSRenameFolder(this BotContext bot, uint groupUin, string folderId, string newFolderName)
- => bot.ContextCollection.Business.OperationLogic.GroupFSRenameFolder(groupUin, folderId, newFolderName, CancellationToken.None);
-
- public static Task<(int RetCode, string RetMsg)> GroupFSRenameFolder(this BotContext bot, uint groupUin, string folderId, string newFolderName, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSRenameFolder(groupUin, folderId, newFolderName, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSRenameFolder(groupUin, folderId, newFolderName);
public static Task GroupFSUpload(this BotContext bot, uint groupUin, FileEntity fileEntity, string targetDirectory = "/")
- => bot.ContextCollection.Business.OperationLogic.GroupFSUpload(groupUin, fileEntity, targetDirectory, CancellationToken.None);
-
- public static Task GroupFSUpload(this BotContext bot, uint groupUin, FileEntity fileEntity, string targetDirectory, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupFSUpload(groupUin, fileEntity, targetDirectory, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupFSUpload(groupUin, fileEntity, targetDirectory);
#endregion
-}
+}
\ No newline at end of file
diff --git a/Lagrange.Core/Common/Interface/Api/OperationExt.cs b/Lagrange.Core/Common/Interface/Api/OperationExt.cs
index 355afb399..3900a4416 100644
--- a/Lagrange.Core/Common/Interface/Api/OperationExt.cs
+++ b/Lagrange.Core/Common/Interface/Api/OperationExt.cs
@@ -13,18 +13,7 @@ public static class OperationExt
/// force the cache to be refreshed
///
public static Task> FetchFriends(this BotContext bot, bool refreshCache = false)
- => bot.ContextCollection.Business.OperationLogic.FetchFriends(refreshCache, CancellationToken.None);
-
-
- ///
- /// Fetch the friend list of account from server or cache
- ///
- /// target BotContext
- /// The cancellation token
- /// force the cache to be refreshed
- ///
- public static Task> FetchFriends(this BotContext bot, bool refreshCache, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchFriends(refreshCache, CancellationToken.None);
+ => bot.ContextCollection.Business.OperationLogic.FetchFriends(refreshCache);
///
/// Fetch the member list of the group from server or cache
@@ -34,18 +23,7 @@ public static Task> FetchFriends(this BotContext bot, bool refre
/// force the cache to be refreshed
///
public static Task> FetchMembers(this BotContext bot, uint groupUin, bool refreshCache = false)
- => bot.ContextCollection.Business.OperationLogic.FetchMembers(groupUin, CancellationToken.None, refreshCache);
-
- ///
- /// Fetch the member list of the group from server or cache
- ///
- /// target BotContext
- ///
- /// The cancellation token
- /// force the cache to be refreshed
- ///
- public static Task> FetchMembers(this BotContext bot, uint groupUin, bool refreshCache, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchMembers(groupUin, cancellationToken, refreshCache);
+ => bot.ContextCollection.Business.OperationLogic.FetchMembers(groupUin, refreshCache);
///
/// Fetch the group list of the account from server or cache
@@ -54,17 +32,7 @@ public static Task> FetchMembers(this BotContext bot, uint
/// force the cache to be refreshed
///
public static Task> FetchGroups(this BotContext bot, bool refreshCache = false)
- => bot.ContextCollection.Business.OperationLogic.FetchGroups(refreshCache, CancellationToken.None);
-
- ///
- /// Fetch the group list of the account from server or cache
- ///
- /// target BotContext
- /// The cancellation token
- /// force the cache to be refreshed
- ///
- public static Task> FetchGroups(this BotContext bot, bool refreshCache, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroups(refreshCache, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroups(refreshCache);
///
/// Fetch the cookies/pskey for accessing other site
@@ -73,17 +41,7 @@ public static Task> FetchGroups(this BotContext bot, bool refresh
/// the domain for the cookie to be valid
/// the list of cookies
public static Task> FetchCookies(this BotContext bot, List domains)
- => bot.ContextCollection.Business.OperationLogic.GetCookies(domains, CancellationToken.None);
-
- ///
- /// Fetch the cookies/pskey for accessing other site
- ///
- /// target BotContext
- /// the domain for the cookie to be valid
- /// The cancellation token
- /// the list of cookies
- public static Task> FetchCookies(this BotContext bot, List domains, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GetCookies(domains, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GetCookies(domains);
///
/// Send the message
@@ -91,37 +49,17 @@ public static Task> FetchCookies(this BotContext bot, List
/// target BotContext
/// the chain constructed by
public static Task SendMessage(this BotContext bot, MessageChain chain)
- => bot.ContextCollection.Business.OperationLogic.SendMessage(chain, CancellationToken.None);
-
- ///
- /// Send the message
- ///
- /// target BotContext
- /// the chain constructed by
- /// The cancellation token
- public static Task SendMessage(this BotContext bot, MessageChain chain, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SendMessage(chain, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SendMessage(chain);
///
/// Recall the group message from Bot itself by
///
/// target BotContext
/// The uin for target group of the message
- /// The return value for
+ /// The return value for
/// Successfully recalled or not
public static Task RecallGroupMessage(this BotContext bot, uint groupUin, MessageResult result)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, result, CancellationToken.None);
-
- ///
- /// Recall the group message from Bot itself by
- ///
- /// target BotContext
- /// The uin for target group of the message
- /// The return value for
- /// The cancellation token
- /// Successfully recalled or not
- public static Task RecallGroupMessage(this BotContext bot, uint groupUin, MessageResult result, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, result, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, result);
///
/// Recall the group message by
@@ -130,17 +68,7 @@ public static Task RecallGroupMessage(this BotContext bot, uint groupUin,
/// target MessageChain, must be Group
/// Successfully recalled or not
public static Task RecallGroupMessage(this BotContext bot, MessageChain chain)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(chain, CancellationToken.None);
-
- ///
- /// Recall the group message by
- ///
- /// target BotContext
- /// target MessageChain, must be Group
- /// The cancellation token
- /// Successfully recalled or not
- public static Task RecallGroupMessage(this BotContext bot, MessageChain chain, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(chain, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(chain);
///
/// Recall the group message by sequence
@@ -150,39 +78,17 @@ public static Task RecallGroupMessage(this BotContext bot, MessageChain ch
/// The sequence for target message
/// Successfully recalled or not
public static Task RecallGroupMessage(this BotContext bot, uint groupUin, uint sequence)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, sequence, CancellationToken.None);
-
- ///
- /// Recall the group message by sequence
- ///
- /// target BotContext
- /// The uin for target group of the message
- /// The sequence for target message
- /// The cancellation token
- /// Successfully recalled or not
- public static Task RecallGroupMessage(this BotContext bot, uint groupUin, uint sequence, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, sequence, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RecallGroupMessage(groupUin, sequence);
///
/// Recall the group message from Bot itself by
///
/// target BotContext
/// The uin for target friend of the message
- /// The return value for
+ /// The return value for
/// Successfully recalled or not
public static Task RecallFriendMessage(this BotContext bot, uint friendUin, MessageResult result)
- => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(friendUin, result, CancellationToken.None);
-
- ///
- /// Recall the group message from Bot itself by
- ///
- /// target BotContext
- /// The uin for target friend of the message
- /// The return value for
- /// The cancellation token
- /// Successfully recalled or not
- public static Task RecallFriendMessage(this BotContext bot, uint friendUin, MessageResult result, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(friendUin, result, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(friendUin, result);
///
/// Recall the group message by
@@ -191,17 +97,7 @@ public static Task RecallFriendMessage(this BotContext bot, uint friendUin
/// target MessageChain, must be Friend
/// Successfully recalled or not
public static Task RecallFriendMessage(this BotContext bot, MessageChain chain)
- => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(chain, CancellationToken.None);
-
- ///
- /// Recall the group message by
- ///
- /// target BotContext
- /// target MessageChain, must be Friend
- /// The cancellation token
- /// Successfully recalled or not
- public static Task RecallFriendMessage(this BotContext bot, MessageChain chain, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(chain, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RecallFriendMessage(chain);
///
/// Fetch Notifications and requests such as friend requests and Group Join Requests
@@ -209,16 +105,7 @@ public static Task RecallFriendMessage(this BotContext bot, MessageChain c
/// target BotContext
///
public static Task?> FetchGroupRequests(this BotContext bot)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupRequests(CancellationToken.None);
-
- ///
- /// Fetch Notifications and requests such as friend requests and Group Join Requests
- ///
- /// target BotContext
- /// The cancellation token
- ///
- public static Task?> FetchGroupRequests(this BotContext bot, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchGroupRequests(cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchGroupRequests();
///
///
@@ -226,16 +113,7 @@ public static Task RecallFriendMessage(this BotContext bot, MessageChain c
///
///
public static Task?> FetchFriendRequests(this BotContext bot)
- => bot.ContextCollection.Business.OperationLogic.FetchFriendRequests(CancellationToken.None);
-
- ///
- ///
- ///
- ///
- /// The cancellation token
- ///
- public static Task?> FetchFriendRequests(this BotContext bot, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchFriendRequests(cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchFriendRequests();
///
/// set status
@@ -244,17 +122,7 @@ public static Task RecallFriendMessage(this BotContext bot, MessageChain c
/// The status code
///
public static Task SetStatus(this BotContext bot, uint status)
- => bot.ContextCollection.Business.OperationLogic.SetStatus(status, CancellationToken.None);
-
- ///
- /// set status
- ///
- /// target BotContext
- /// The status code
- /// The cancellation token
- ///
- public static Task SetStatus(this BotContext bot, uint status, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetStatus(status, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetStatus(status);
///
/// set custom status
@@ -264,48 +132,22 @@ public static Task SetStatus(this BotContext bot, uint status, Cancellatio
/// text that would shown
///
public static Task SetCustomStatus(this BotContext bot, uint faceId, string text)
- => bot.ContextCollection.Business.OperationLogic.SetCustomStatus(faceId, text, CancellationToken.None);
-
- ///
- /// set custom status
- ///
- /// target BotContext
- /// faceId that is same as the
- /// text that would shown
- /// The cancellation token
- ///
- public static Task SetCustomStatus(this BotContext bot, uint faceId, string text, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetCustomStatus(faceId, text, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetCustomStatus(faceId, text);
public static Task GroupTransfer(this BotContext bot, uint groupUin, uint targetUin)
- => bot.ContextCollection.Business.OperationLogic.GroupTransfer(groupUin, targetUin, CancellationToken.None);
-
- public static Task GroupTransfer(this BotContext bot, uint groupUin, uint targetUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupTransfer(groupUin, targetUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupTransfer(groupUin, targetUin);
public static Task RequestFriend(this BotContext bot, uint targetUin, string question = "", string message = "")
- => bot.ContextCollection.Business.OperationLogic.RequestFriend(targetUin, question, message, CancellationToken.None);
-
- public static Task RequestFriend(this BotContext bot, uint targetUin, string question, string message, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.RequestFriend(targetUin, question, message, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.RequestFriend(targetUin, question, message);
public static Task Like(this BotContext bot, uint targetUin, uint count = 1)
- => bot.ContextCollection.Business.OperationLogic.Like(targetUin, count, CancellationToken.None);
-
- public static Task Like(this BotContext bot, uint targetUin, uint count, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.Like(targetUin, count, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.Like(targetUin, count);
///
/// Get the client key for all sites
///
public static Task GetClientKey(this BotContext bot)
- => bot.ContextCollection.Business.OperationLogic.GetClientKey(CancellationToken.None);
-
- ///
- /// Get the client key for all sites
- ///
- public static Task GetClientKey(this BotContext bot, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GetClientKey(cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GetClientKey();
///
/// Get the history message record, max 30 seqs
@@ -315,18 +157,7 @@ public static Task Like(this BotContext bot, uint targetUin, uint count, C
/// Start Sequence of the message
/// End Sequence of the message
public static Task?> GetGroupMessage(this BotContext bot, uint groupUin, uint startSequence, uint endSequence)
- => bot.ContextCollection.Business.OperationLogic.GetGroupMessage(groupUin, startSequence, endSequence, CancellationToken.None);
-
- ///
- /// Get the history message record, max 30 seqs
- ///
- /// target BotContext
- /// target GroupUin
- /// Start Sequence of the message
- /// End Sequence of the message
- /// The cancellation token
- public static Task?> GetGroupMessage(this BotContext bot, uint groupUin, uint startSequence, uint endSequence, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GetGroupMessage(groupUin, startSequence, endSequence, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GetGroupMessage(groupUin, startSequence, endSequence);
///
/// Get the history message record for private message
@@ -336,18 +167,7 @@ public static Task Like(this BotContext bot, uint targetUin, uint count, C
/// timestamp of the message chain
/// number of message to be fetched before timestamp
public static Task?> GetRoamMessage(this BotContext bot, uint friendUin, uint timestamp, uint count)
- => bot.ContextCollection.Business.OperationLogic.GetRoamMessage(friendUin, timestamp, count, CancellationToken.None);
-
- ///
- /// Get the history message record for private message
- ///
- /// target BotContext
- /// target FriendUin
- /// timestamp of the message chain
- /// number of message to be fetched before timestamp
- /// The cancellation token
- public static Task?> GetRoamMessage(this BotContext bot, uint friendUin, uint timestamp, uint count, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GetRoamMessage(friendUin, timestamp, count, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GetRoamMessage(friendUin, timestamp, count);
///
/// Get the history message record for private message
@@ -358,40 +178,17 @@ public static Task Like(this BotContext bot, uint targetUin, uint count, C
public static Task?> GetRoamMessage(this BotContext bot, MessageChain targetChain, uint count)
{
uint timestamp = (uint)new DateTimeOffset(targetChain.Time).ToUnixTimeSeconds();
- return bot.ContextCollection.Business.OperationLogic.GetRoamMessage(targetChain.FriendUin, timestamp, count, CancellationToken.None);
- }
-
- ///
- /// Get the history message record for private message
- ///
- /// target BotContext
- /// target chain
- /// number of message to be fetched before timestamp
- /// The cancellation token
- public static Task?> GetRoamMessage(this BotContext bot, MessageChain targetChain, uint count, CancellationToken cancellationToken)
- {
- uint timestamp = (uint)new DateTimeOffset(targetChain.Time).ToUnixTimeSeconds();
- return bot.ContextCollection.Business.OperationLogic.GetRoamMessage(targetChain.FriendUin, timestamp, count, cancellationToken);
+ return bot.ContextCollection.Business.OperationLogic.GetRoamMessage(targetChain.FriendUin, timestamp, count);
}
public static Task?> GetC2cMessage(this BotContext bot, uint friendUin, uint startSequence, uint endSequence)
{
- return bot.ContextCollection.Business.OperationLogic.GetC2cMessage(friendUin, startSequence, endSequence, CancellationToken.None);
- }
-
- public static Task?> GetC2cMessage(this BotContext bot, uint friendUin, uint startSequence, uint endSequence, CancellationToken cancellationToken)
- {
- return bot.ContextCollection.Business.OperationLogic.GetC2cMessage(friendUin, startSequence, endSequence, cancellationToken);
+ return bot.ContextCollection.Business.OperationLogic.GetC2cMessage(friendUin, startSequence, endSequence);
}
public static Task<(int code, List? chains)> GetMessagesByResId(this BotContext bot, string resId)
{
- return bot.ContextCollection.Business.OperationLogic.GetMessagesByResId(resId, CancellationToken.None);
- }
-
- public static Task<(int code, List? chains)> GetMessagesByResId(this BotContext bot, string resId, CancellationToken cancellationToken)
- {
- return bot.ContextCollection.Business.OperationLogic.GetMessagesByResId(resId, cancellationToken);
+ return bot.ContextCollection.Business.OperationLogic.GetMessagesByResId(resId);
}
///
@@ -401,59 +198,28 @@ public static Task Like(this BotContext bot, uint targetUin, uint count, C
/// target groupUin
///
public static Task GroupClockIn(this BotContext bot, uint groupUin)
- => bot.ContextCollection.Business.OperationLogic.GroupClockIn(groupUin, CancellationToken.None);
-
- ///
- /// Do group clock in (群打卡)
- ///
- /// target BotContext
- /// target groupUin
- /// The cancellation token
- ///
- public static Task GroupClockIn(this BotContext bot, uint groupUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.GroupClockIn(groupUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.GroupClockIn(groupUin);
public static Task FetchUserInfo(this BotContext bot, uint uin, bool refreshCache = false)
- => bot.ContextCollection.Business.OperationLogic.FetchUserInfo(uin, refreshCache, CancellationToken.None);
-
- public static Task FetchUserInfo(this BotContext bot, uint uin, bool refreshCache, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchUserInfo(uin, refreshCache, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchUserInfo(uin, refreshCache);
public static Task?> FetchCustomFace(this BotContext bot)
- => bot.ContextCollection.Business.OperationLogic.FetchCustomFace(CancellationToken.None);
-
- public static Task?> FetchCustomFace(this BotContext bot, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchCustomFace(cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchCustomFace();
public static Task UploadLongMessage(this BotContext bot, List chains)
- => bot.ContextCollection.Business.OperationLogic.UploadLongMessage(chains, CancellationToken.None);
-
- public static Task UploadLongMessage(this BotContext bot, List chains, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.UploadLongMessage(chains, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.UploadLongMessage(chains);
public static Task MarkAsRead(this BotContext bot, MessageChain targetChain)
{
uint timestamp = (uint)(targetChain.Time - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
- return bot.ContextCollection.Business.OperationLogic.MarkAsRead(targetChain.GroupUin ?? 0, targetChain.Uid, targetChain.Sequence, timestamp, CancellationToken.None);
- }
-
- public static Task MarkAsRead(this BotContext bot, MessageChain targetChain, CancellationToken cancellationToken)
- {
- uint timestamp = (uint)(targetChain.Time - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
- return bot.ContextCollection.Business.OperationLogic.MarkAsRead(targetChain.GroupUin ?? 0, targetChain.Uid, targetChain.Sequence, timestamp, cancellationToken);
+ return bot.ContextCollection.Business.OperationLogic.MarkAsRead(targetChain.GroupUin ?? 0, targetChain.Uid, targetChain.Sequence, timestamp);
}
public static Task UploadFriendFile(this BotContext bot, uint targetUin, FileEntity fileEntity)
- => bot.ContextCollection.Business.OperationLogic.UploadFriendFile(targetUin, fileEntity, CancellationToken.None);
-
- public static Task UploadFriendFile(this BotContext bot, uint targetUin, FileEntity fileEntity, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.UploadFriendFile(targetUin, fileEntity, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.UploadFriendFile(targetUin, fileEntity);
public static Task FriendPoke(this BotContext bot, uint friendUin)
- => bot.ContextCollection.Business.OperationLogic.FriendPoke(friendUin, CancellationToken.None);
-
- public static Task FriendPoke(this BotContext bot, uint friendUin, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FriendPoke(friendUin, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FriendPoke(friendUin);
///
/// Send a special window shake to friend
@@ -462,17 +228,7 @@ public static Task FriendPoke(this BotContext bot, uint friendUin, Cancell
/// face type
/// count of face
public static Task FriendSpecialShake(this BotContext bot, uint friendUin, SpecialPokeFaceType type, uint count)
- => bot.ContextCollection.Business.OperationLogic.FriendSpecialShake(friendUin, type, count, CancellationToken.None);
-
- ///
- /// Send a special window shake to friend
- ///
- /// target friend uin
- /// face type
- /// count of face
- /// The cancellation token
- public static Task FriendSpecialShake(this BotContext bot, uint friendUin, SpecialPokeFaceType type, uint count, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FriendSpecialShake(friendUin, type, count, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FriendSpecialShake(friendUin, type, count);
///
/// Send a window shake to friend
@@ -481,23 +237,10 @@ public static Task FriendSpecialShake(this BotContext bot, uint f
/// face type
/// How big the face will be displayed ([0,3] is valid)
public static Task FriendShake(this BotContext bot, uint friendUin, PokeFaceType type, ushort strength)
- => bot.ContextCollection.Business.OperationLogic.FriendShake(friendUin, type, strength, CancellationToken.None);
-
- ///
- /// Send a window shake to friend
- ///
- /// target friend uin
- /// face type
- /// How big the face will be displayed ([0,3] is valid)
- /// The cancellation token
- public static Task FriendShake(this BotContext bot, uint friendUin, PokeFaceType type, ushort strength, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FriendShake(friendUin, type, strength, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FriendShake(friendUin, type, strength);
public static Task?> FetchMarketFaceKey(this BotContext bot, List faceIds)
- => bot.ContextCollection.Business.OperationLogic.FetchMarketFaceKey(faceIds, CancellationToken.None);
-
- public static Task?> FetchMarketFaceKey(this BotContext bot, List faceIds, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.FetchMarketFaceKey(faceIds, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.FetchMarketFaceKey(faceIds);
///
/// Set the avatar of the bot itself
@@ -505,14 +248,5 @@ public static Task FriendShake(this BotContext bot, uint friendUi
/// target
/// The avatar object,
public static Task SetAvatar(this BotContext bot, ImageEntity avatar)
- => bot.ContextCollection.Business.OperationLogic.SetAvatar(avatar, CancellationToken.None);
-
- ///
- /// Set the avatar of the bot itself
- ///
- /// target
- /// The avatar object,
- /// The cancellation token
- public static Task SetAvatar(this BotContext bot, ImageEntity avatar, CancellationToken cancellationToken)
- => bot.ContextCollection.Business.OperationLogic.SetAvatar(avatar, cancellationToken);
+ => bot.ContextCollection.Business.OperationLogic.SetAvatar(avatar);
}
diff --git a/Lagrange.Core/Internal/Context/BusinessContext.cs b/Lagrange.Core/Internal/Context/BusinessContext.cs
index 40f213054..9b5e44658 100644
--- a/Lagrange.Core/Internal/Context/BusinessContext.cs
+++ b/Lagrange.Core/Internal/Context/BusinessContext.cs
@@ -73,16 +73,12 @@ private void RegisterLogics()
}
}
- public async Task PushEvent(ProtocolEvent @event, CancellationToken cancellationToken)
+ public async Task PushEvent(ProtocolEvent @event)
{
try
{
var packets = Collection.Service.ResolvePacketByEvent(@event);
- foreach (var packet in packets)
- {
- cancellationToken.ThrowIfCancellationRequested();
- await Collection.Packet.PostPacket(packet);
- }
+ foreach (var packet in packets) await Collection.Packet.PostPacket(packet);
}
catch
{
@@ -95,32 +91,25 @@ public async Task PushEvent(ProtocolEvent @event, CancellationToken cancel
///
/// Send Event to the Server, goes through the given context
///
- public async Task> SendEvent(ProtocolEvent @event, CancellationToken cancellationToken)
+ public async Task> SendEvent(ProtocolEvent @event)
{
- await HandleOutgoingEvent(@event, cancellationToken);
+ await HandleOutgoingEvent(@event);
var result = new List();
-
- cancellationToken.ThrowIfCancellationRequested();
-
+
try
{
var packets = Collection.Service.ResolvePacketByEvent(@event);
foreach (var packet in packets)
{
- var returnVal = await Collection.Packet.SendPacket(packet, cancellationToken);
+ var returnVal = await Collection.Packet.SendPacket(packet);
var resolved = Collection.Service.ResolveEventByPacket(returnVal);
foreach (var protocol in resolved)
{
- await HandleIncomingEvent(protocol, cancellationToken);
+ await HandleIncomingEvent(protocol);
result.Add(protocol);
}
}
}
- catch (TaskCanceledException)
- {
- // if task is cancelled, we should throw the exception
- throw;
- }
catch (Exception e)
{
Collection.Log.LogWarning(Tag, $"Error when processing the event: {@event}");
@@ -130,7 +119,7 @@ public async Task> SendEvent(ProtocolEvent @event, Cancellat
return result;
}
- public async Task HandleIncomingEvent(ProtocolEvent @event, CancellationToken cancellationToken)
+ public async Task HandleIncomingEvent(ProtocolEvent @event)
{
_businessLogics.TryGetValue(typeof(ProtocolEvent), out var baseLogics);
_businessLogics.TryGetValue(@event.GetType(), out var normalLogics);
@@ -143,12 +132,7 @@ public async Task HandleIncomingEvent(ProtocolEvent @event, CancellationTo
{
try
{
- await logic.Incoming(@event, cancellationToken);
- }
- catch (TaskCanceledException)
- {
- // if task is cancelled, we should throw the exception
- throw;
+ await logic.Incoming(@event);
}
catch (Exception e)
{
@@ -161,7 +145,7 @@ public async Task HandleIncomingEvent(ProtocolEvent @event, CancellationTo
return true;
}
- public async Task HandleOutgoingEvent(ProtocolEvent @event, CancellationToken cancellationToken)
+ public async Task HandleOutgoingEvent(ProtocolEvent @event)
{
_businessLogics.TryGetValue(typeof(ProtocolEvent), out var baseLogics);
_businessLogics.TryGetValue(@event.GetType(), out var normalLogics);
@@ -174,12 +158,7 @@ public async Task HandleOutgoingEvent(ProtocolEvent @event, CancellationTo
{
try
{
- await logic.Outgoing(@event, cancellationToken);
- }
- catch (TaskCanceledException)
- {
- // if task is cancelled, we should throw the exception
- throw;
+ await logic.Outgoing(@event);
}
catch (Exception e)
{
@@ -204,7 +183,7 @@ public async Task HandleServerPacket(SsoPacket packet)
var events = Collection.Service.ResolveEventByPacket(packet);
foreach (var @event in events)
{
- var isSuccessful = await Collection.Business.HandleIncomingEvent(@event, CancellationToken.None);
+ var isSuccessful = await Collection.Business.HandleIncomingEvent(@event);
if (!isSuccessful) break;
success = true;
@@ -220,4 +199,4 @@ public async Task HandleServerPacket(SsoPacket packet)
return success;
}
-}
+}
\ No newline at end of file
diff --git a/Lagrange.Core/Internal/Context/HighwayContext.cs b/Lagrange.Core/Internal/Context/HighwayContext.cs
index 01a3bdfd0..8f7789b50 100644
--- a/Lagrange.Core/Internal/Context/HighwayContext.cs
+++ b/Lagrange.Core/Internal/Context/HighwayContext.cs
@@ -57,7 +57,7 @@ public HighwayContext(ContextCollection collection, BotKeystore keystore, BotApp
_concurrent = config.HighwayConcurrent;
}
- public async Task UploadResources(MessageChain chain, CancellationToken cancellationToken = default)
+ public async Task UploadResources(MessageChain chain)
{
foreach (var entity in chain)
{
@@ -65,8 +65,8 @@ public async Task UploadResources(MessageChain chain, CancellationToken cancella
{
try
{
- if (chain.IsGroup) await uploader.UploadGroup(Collection, chain, entity, cancellationToken);
- else await uploader.UploadPrivate(Collection, chain, entity, cancellationToken);
+ if (chain.IsGroup) await uploader.UploadGroup(Collection, chain, entity);
+ else await uploader.UploadPrivate(Collection, chain, entity);
}
catch
{
@@ -76,7 +76,7 @@ public async Task UploadResources(MessageChain chain, CancellationToken cancella
}
}
- public async Task ManualUploadEntity(IMessageEntity entity, CancellationToken cancellationToken = default)
+ public async Task ManualUploadEntity(IMessageEntity entity)
{
if (_uploaders.TryGetValue(entity.GetType(), out var uploader))
{
@@ -86,7 +86,7 @@ public async Task ManualUploadEntity(IMessageEntity entity, CancellationToken ca
string uid = Collection.Keystore.Uid ?? "";
var chain = new MessageChain(uin, uid, uid) { entity };
- await uploader.UploadPrivate(Collection, chain, entity, cancellationToken);
+ await uploader.UploadPrivate(Collection, chain, entity);
}
catch
{
@@ -95,11 +95,11 @@ public async Task ManualUploadEntity(IMessageEntity entity, CancellationToken ca
}
}
- public async Task UploadSrcByStreamAsync(int commonId, Stream data, byte[] ticket, byte[] md5, byte[]? extendInfo = null, CancellationToken cancellation = default)
+ public async Task UploadSrcByStreamAsync(int commonId, Stream data, byte[] ticket, byte[] md5, byte[]? extendInfo = null)
{
if (_uri == null)
{
- var highwayUrlEvent = await Collection.Business.SendEvent(HighwayUrlEvent.Create(), cancellation);
+ var highwayUrlEvent = await Collection.Business.SendEvent(HighwayUrlEvent.Create());
var result = (HighwayUrlEvent)highwayUrlEvent[0];
_uri = result.HighwayUrls[1][0];
}
@@ -114,7 +114,7 @@ public async Task UploadSrcByStreamAsync(int commonId, Stream data, byte[]
while (offset < fileSize)
{
var buffer = new byte[Math.Min(_chunkSize, fileSize - offset)];
- int payload = await data.ReadAsync(buffer.AsMemory(), cancellation);
+ int payload = await data.ReadAsync(buffer.AsMemory());
uint uin = Collection.Keystore.Uin;
uint sequence = Interlocked.Increment(ref _sequence);
var reqBody = new UpBlock(commonId, uin, sequence, (ulong)fileSize, (ulong)offset, ticket, md5, buffer, extendInfo);
@@ -123,7 +123,7 @@ public async Task UploadSrcByStreamAsync(int commonId, Stream data, byte[]
if (upBlocks.Count >= _concurrent || data.Position == data.Length)
{
- var tasks = upBlocks.Select(x => SendUpBlockAsync(x, _uri, cancellation)).ToArray();
+ var tasks = upBlocks.Select(x => SendUpBlockAsync(x, _uri)).ToArray();
var results = await Task.WhenAll(tasks);
success &= results.All(x => x);
@@ -134,7 +134,7 @@ public async Task UploadSrcByStreamAsync(int commonId, Stream data, byte[]
return success;
}
- private async Task SendUpBlockAsync(UpBlock upBlock, Uri server, CancellationToken cancellation = default)
+ private async Task SendUpBlockAsync(UpBlock upBlock, Uri server)
{
var head = new DataHighwayHead
{
@@ -171,7 +171,7 @@ private async Task SendUpBlockAsync(UpBlock upBlock, Uri server, Cancellat
};
bool isEnd = upBlock.Offset + (ulong)upBlock.Block.Length == upBlock.FileSize;
- var payload = await SendPacketAsync(highwayHead, new BinaryPacket(upBlock.Block), server, end: isEnd, cancellation: cancellation);
+ var payload = await SendPacketAsync(highwayHead, new BinaryPacket(upBlock.Block), server, isEnd);
var (respHead, resp) = ParsePacket(payload);
Collection.Log.LogDebug(Tag, $"Highway Block Result: {respHead.ErrorCode} | {respHead.MsgSegHead?.RetCode} | {respHead.BytesRspExtendInfo?.Hex()} | {resp.ToArray().Hex()}");
@@ -179,7 +179,7 @@ private async Task SendUpBlockAsync(UpBlock upBlock, Uri server, Cancellat
return respHead.ErrorCode == 0;
}
- private Task SendPacketAsync(ReqDataHighwayHead head, BinaryPacket buffer, Uri server, bool end = true, CancellationToken cancellation = default)
+ private Task SendPacketAsync(ReqDataHighwayHead head, BinaryPacket buffer, Uri server, bool end = true)
{
using var stream = new MemoryStream();
Serializer.Serialize(stream, head);
@@ -192,7 +192,7 @@ private Task SendPacketAsync(ReqDataHighwayHead head, BinaryPacket
.WritePacket(buffer)
.WriteByte(0x29); // packet end
- return SendDataAsync(writer.ToArray(), server, end, cancellation);
+ return SendDataAsync(writer.ToArray(), server, end);
}
private static (RespDataHighwayHead, BinaryPacket) ParsePacket(BinaryPacket packet)
@@ -210,7 +210,7 @@ private static (RespDataHighwayHead, BinaryPacket) ParsePacket(BinaryPacket pack
throw new InvalidOperationException("Invalid packet");
}
- private async Task SendDataAsync(byte[] packet, Uri server, bool end, CancellationToken cancellation)
+ private async Task SendDataAsync(byte[] packet, Uri server, bool end)
{
var content = new ByteArrayContent(packet);
var request = new HttpRequestMessage(HttpMethod.Post, server)
@@ -221,8 +221,8 @@ private async Task SendDataAsync(byte[] packet, Uri server, bool e
{ "Connection" , end ? "close" : "keep-alive" },
}
};
- var response = await _client.SendAsync(request, cancellation);
- var data = await response.Content.ReadAsByteArrayAsync(cancellation);
+ var response = await _client.SendAsync(request);
+ var data = await response.Content.ReadAsByteArrayAsync();
return new BinaryPacket(data);
}
@@ -242,4 +242,4 @@ public void Dispose()
{
_client.Dispose();
}
-}
+}
\ No newline at end of file
diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/CachingLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/CachingLogic.cs
index c7e766474..645946768 100644
--- a/Lagrange.Core/Internal/Context/Logic/Implementation/CachingLogic.cs
+++ b/Lagrange.Core/Internal/Context/Logic/Implementation/CachingLogic.cs
@@ -37,25 +37,25 @@ internal CachingLogic(ContextCollection collection) : base(collection)
_cacheUsers = new ConcurrentDictionary();
}
- public override Task Incoming(ProtocolEvent e, CancellationToken cancellationToken)
+ public override Task Incoming(ProtocolEvent e)
{
return e switch
{
- GroupSysDecreaseEvent groupSysDecreaseEvent when groupSysDecreaseEvent.MemberUid != Collection.Keystore.Uid => CacheUid(groupSysDecreaseEvent.GroupUin, force: true, cancellationToken: cancellationToken),
- GroupSysIncreaseEvent groupSysIncreaseEvent => CacheUid(groupSysIncreaseEvent.GroupUin, force: true, cancellationToken: cancellationToken),
- GroupSysAdminEvent groupSysAdminEvent => CacheUid(groupSysAdminEvent.GroupUin, force: true, cancellationToken: cancellationToken),
+ GroupSysDecreaseEvent groupSysDecreaseEvent when groupSysDecreaseEvent.MemberUid != Collection.Keystore.Uid => CacheUid(groupSysDecreaseEvent.GroupUin, true),
+ GroupSysIncreaseEvent groupSysIncreaseEvent => CacheUid(groupSysIncreaseEvent.GroupUin, true),
+ GroupSysAdminEvent groupSysAdminEvent => CacheUid(groupSysAdminEvent.GroupUin, true),
_ => Task.CompletedTask,
};
}
- public async Task> GetCachedGroups(bool refreshCache, CancellationToken cancellationToken)
+ public async Task> GetCachedGroups(bool refreshCache)
{
if (_cachedGroupEntities.Count == 0 || refreshCache)
{
_cachedGroupEntities.Clear();
var fetchGroupsEvent = FetchGroupsEvent.Create();
- var events = await Collection.Business.SendEvent(fetchGroupsEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(fetchGroupsEvent);
var groups = ((FetchGroupsEvent)events[0]).Groups;
_cachedGroupEntities.AddRange(groups);
@@ -65,60 +65,60 @@ public async Task> GetCachedGroups(bool refreshCache, Cancellatio
return _cachedGroupEntities;
}
- public async Task ResolveUid(uint? groupUin, uint friendUin, CancellationToken cancellationToken)
+ public async Task ResolveUid(uint? groupUin, uint friendUin)
{
- if (_uinToUid.Count == 0) await ResolveFriendsUidAndFriendGroups(cancellationToken);
+ if (_uinToUid.Count == 0) await ResolveFriendsUidAndFriendGroups();
if (groupUin == null) return _uinToUid.GetValueOrDefault(friendUin);
- await CacheUid(groupUin.Value, false, cancellationToken);
+ await CacheUid(groupUin.Value);
return _uinToUid.GetValueOrDefault(friendUin);
}
- public async Task ResolveUin(uint? groupUin, string friendUid, bool force, CancellationToken cancellationToken)
+ public async Task ResolveUin(uint? groupUin, string friendUid, bool force = false)
{
- if (_uinToUid.Count == 0) await ResolveFriendsUidAndFriendGroups(cancellationToken);
+ if (_uinToUid.Count == 0) await ResolveFriendsUidAndFriendGroups();
if (groupUin == null) return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;
- await CacheUid(groupUin.Value, force: force, cancellationToken: cancellationToken);
+ await CacheUid(groupUin.Value, force);
return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;
}
- public async Task> GetCachedMembers(uint groupUin, bool refreshCache, CancellationToken cancellationToken)
+ public async Task> GetCachedMembers(uint groupUin, bool refreshCache)
{
if (!_cachedGroupMembers.TryGetValue(groupUin, out var members) || refreshCache)
{
- await ResolveMembersUid(groupUin, cancellationToken);
+ await ResolveMembersUid(groupUin);
return _cachedGroupMembers.TryGetValue(groupUin, out members) ? members : new List();
}
return members;
}
- public async Task> GetCachedFriends(bool refreshCache, CancellationToken cancellationToken)
+ public async Task> GetCachedFriends(bool refreshCache)
{
- if (_cachedFriends.Count == 0 || refreshCache) await ResolveFriendsUidAndFriendGroups(cancellationToken);
+ if (_cachedFriends.Count == 0 || refreshCache) await ResolveFriendsUidAndFriendGroups();
return _cachedFriends;
}
- public async Task GetCachedUsers(uint uin, bool refreshCache, CancellationToken cancellationToken)
+ public async Task GetCachedUsers(uint uin, bool refreshCache)
{
- if (!_cacheUsers.ContainsKey(uin) || refreshCache) await ResolveUser(uin, cancellationToken);
+ if (!_cacheUsers.ContainsKey(uin) || refreshCache) await ResolveUser(uin);
if (!_cacheUsers.TryGetValue(uin, out BotUserInfo? info)) return null;
return info;
}
- private async Task CacheUid(uint groupUin, bool force, CancellationToken cancellationToken)
+ private async Task CacheUid(uint groupUin, bool force = false)
{
if (!_cachedGroups.Contains(groupUin) || force)
{
Collection.Log.LogVerbose(Tag, $"Caching group members: {groupUin}");
- await ResolveMembersUid(groupUin, cancellationToken);
+ await ResolveMembersUid(groupUin);
_cachedGroups.Add(groupUin);
}
}
- private async Task ResolveFriendsUidAndFriendGroups(CancellationToken cancellationToken)
+ private async Task ResolveFriendsUidAndFriendGroups()
{
uint? next = null;
var friends = new List();
@@ -126,7 +126,7 @@ private async Task ResolveFriendsUidAndFriendGroups(CancellationToken cancellati
do
{
var @event = FetchFriendsEvent.Create(next);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count == 0)
{
@@ -153,10 +153,10 @@ private async Task ResolveFriendsUidAndFriendGroups(CancellationToken cancellati
_cachedFriends.AddRange(friends);
}
- private async Task ResolveMembersUid(uint groupUin, CancellationToken cancellationToken)
+ private async Task ResolveMembersUid(uint groupUin)
{
var fetchFriendsEvent = FetchMembersEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(fetchFriendsEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(fetchFriendsEvent);
if (events.Count != 0)
{
@@ -166,7 +166,7 @@ private async Task ResolveMembersUid(uint groupUin, CancellationToken cancellati
while (token != null)
{
var next = FetchMembersEvent.Create(groupUin, token);
- var results = await Collection.Business.SendEvent(next, cancellationToken);
+ var results = await Collection.Business.SendEvent(next);
@event.Members.AddRange(((FetchMembersEvent)results[0]).Members);
token = ((FetchMembersEvent)results[0]).Token;
}
@@ -181,13 +181,13 @@ private async Task ResolveMembersUid(uint groupUin, CancellationToken cancellati
}
}
- private async Task ResolveUser(uint uin, CancellationToken cancellationToken)
+ private async Task ResolveUser(uint uin)
{
- var events = await Collection.Business.SendEvent(FetchUserInfoEvent.Create(uin), cancellationToken);
+ var events = await Collection.Business.SendEvent(FetchUserInfoEvent.Create(uin));
if (events.Count != 0 && events[0] is FetchUserInfoEvent { } @event)
{
_cacheUsers.AddOrUpdate(uin, @event.UserInfo, (_key, _value) => @event.UserInfo);
}
}
-}
+}
\ No newline at end of file
diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs
index f9267a8fe..9da1c8f2c 100644
--- a/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs
+++ b/Lagrange.Core/Internal/Context/Logic/Implementation/MessagingLogic.cs
@@ -46,15 +46,15 @@ internal class MessagingLogic : LogicBase
internal MessagingLogic(ContextCollection collection) : base(collection) { }
- public override async Task Incoming(ProtocolEvent e, CancellationToken cancellationToken)
+ public override async Task Incoming(ProtocolEvent e)
{
switch (e)
{
case PushMessageEvent push:
{
if (push.Chain.Count == 0) return;
- await ResolveIncomingChain(push.Chain, cancellationToken);
- await ResolveChainMetadata(push.Chain, cancellationToken);
+ await ResolveIncomingChain(push.Chain);
+ await ResolveChainMetadata(push.Chain);
MessageFilter.Filter(push.Chain);
var chain = push.Chain;
@@ -76,8 +76,8 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
foreach (var chain in get.Chains)
{
if (chain.Count == 0) return;
- await ResolveIncomingChain(chain, cancellationToken);
- await ResolveChainMetadata(chain, cancellationToken);
+ await ResolveIncomingChain(chain);
+ await ResolveChainMetadata(chain);
MessageFilter.Filter(chain);
}
break;
@@ -87,40 +87,40 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
foreach (var chain in get.Chains)
{
if (chain.Count == 0) return;
- await ResolveIncomingChain(chain, cancellationToken);
- await ResolveChainMetadata(chain, cancellationToken);
+ await ResolveIncomingChain(chain);
+ await ResolveChainMetadata(chain);
MessageFilter.Filter(chain);
}
break;
}
case GroupSysInviteEvent invite:
{
- uint invitorUin = await Collection.Business.CachingLogic.ResolveUin(null, invite.InvitorUid, false, cancellationToken) ?? 0;
+ uint invitorUin = await Collection.Business.CachingLogic.ResolveUin(null, invite.InvitorUid) ?? 0;
var inviteArgs = new GroupInvitationEvent(invite.GroupUin, invitorUin);
Collection.Invoker.PostEvent(inviteArgs);
break;
}
case GroupSysAdminEvent admin:
{
- uint adminUin = await Collection.Business.CachingLogic.ResolveUin(admin.GroupUin, admin.Uid, false, cancellationToken) ?? 0;
+ uint adminUin = await Collection.Business.CachingLogic.ResolveUin(admin.GroupUin, admin.Uid) ?? 0;
var adminArgs = new GroupAdminChangedEvent(admin.GroupUin, adminUin, admin.IsPromoted);
Collection.Invoker.PostEvent(adminArgs);
break;
}
case GroupSysIncreaseEvent increase:
{
- uint memberUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.MemberUid, true, cancellationToken) ?? 0;
+ uint memberUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.MemberUid, true) ?? 0;
uint? invitorUin = null;
- if (increase.InvitorUid != null) invitorUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.InvitorUid, false, cancellationToken);
+ if (increase.InvitorUid != null) invitorUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.InvitorUid);
var increaseArgs = new GroupMemberIncreaseEvent(increase.GroupUin, memberUin, invitorUin, increase.Type);
Collection.Invoker.PostEvent(increaseArgs);
break;
}
case GroupSysDecreaseEvent decrease:
{
- uint memberUin = await Collection.Business.CachingLogic.ResolveUin(decrease.GroupUin, decrease.MemberUid, false, cancellationToken) ?? 0;
+ uint memberUin = await Collection.Business.CachingLogic.ResolveUin(decrease.GroupUin, decrease.MemberUid) ?? 0;
uint? operatorUin = null;
- if (decrease.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(decrease.GroupUin, decrease.OperatorUid, false, cancellationToken);
+ if (decrease.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(decrease.GroupUin, decrease.OperatorUid);
var decreaseArgs = new GroupMemberDecreaseEvent(decrease.GroupUin, memberUin, operatorUin, decrease.Type);
Collection.Invoker.PostEvent(decreaseArgs);
break;
@@ -139,7 +139,7 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
}
case GroupSysReactionEvent reaction:
{
- uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(reaction.TargetGroupUin, reaction.OperatorUid, false, cancellationToken) ?? 0;
+ uint operatorUin = await Collection.Business.CachingLogic.ResolveUin(reaction.TargetGroupUin, reaction.OperatorUid) ?? 0;
var pokeArgs = new GroupReactionEvent(reaction.TargetGroupUin, reaction.TargetSequence, operatorUin, reaction.IsAdd, reaction.Code, reaction.Count);
Collection.Invoker.PostEvent(pokeArgs);
break;
@@ -159,25 +159,25 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
case GroupSysMuteEvent groupMute:
{
uint? operatorUin = null;
- if (groupMute.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(groupMute.GroupUin, groupMute.OperatorUid, false, cancellationToken);
+ if (groupMute.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(groupMute.GroupUin, groupMute.OperatorUid);
var muteArgs = new GroupMuteEvent(groupMute.GroupUin, operatorUin, groupMute.IsMuted);
Collection.Invoker.PostEvent(muteArgs);
break;
}
case GroupSysMemberMuteEvent memberMute:
{
- uint memberUin = await Collection.Business.CachingLogic.ResolveUin(memberMute.GroupUin, memberMute.TargetUid, false, cancellationToken) ?? 0;
+ uint memberUin = await Collection.Business.CachingLogic.ResolveUin(memberMute.GroupUin, memberMute.TargetUid) ?? 0;
uint? operatorUin = null;
- if (memberMute.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(memberMute.GroupUin, memberMute.OperatorUid, false, cancellationToken);
+ if (memberMute.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(memberMute.GroupUin, memberMute.OperatorUid);
var muteArgs = new GroupMemberMuteEvent(memberMute.GroupUin, memberUin, operatorUin, memberMute.Duration);
Collection.Invoker.PostEvent(muteArgs);
break;
}
case GroupSysRecallEvent recall:
{
- uint authorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.AuthorUid, false, cancellationToken) ?? 0;
+ uint authorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.AuthorUid) ?? 0;
uint operatorUin = 0;
- if (recall.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.OperatorUid, false, cancellationToken) ?? 0;
+ if (recall.OperatorUid != null) operatorUin = await Collection.Business.CachingLogic.ResolveUin(recall.GroupUin, recall.OperatorUid) ?? 0;
var recallArgs = new GroupRecallEvent(recall.GroupUin, authorUin, operatorUin, recall.Sequence, recall.Time, recall.Random, recall.Tip);
Collection.Invoker.PostEvent(recallArgs);
break;
@@ -185,7 +185,7 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
case GroupSysRequestJoinEvent join:
{
var fetchUidEvent = FetchUserInfoEvent.Create(join.TargetUid);
- var results = await Collection.Business.SendEvent(fetchUidEvent, cancellationToken);
+ var results = await Collection.Business.SendEvent(fetchUidEvent);
uint targetUin = results.Count == 0 ? 0 : ((FetchUserInfoEvent)results[0]).UserInfo.Uin;
var joinArgs = new GroupJoinRequestEvent(join.GroupUin, targetUin);
@@ -194,10 +194,10 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
}
case GroupSysRequestInvitationEvent invitation:
{
- uint invitorUin = await Collection.Business.CachingLogic.ResolveUin(invitation.GroupUin, invitation.InvitorUid, false, cancellationToken) ?? 0;
+ uint invitorUin = await Collection.Business.CachingLogic.ResolveUin(invitation.GroupUin, invitation.InvitorUid) ?? 0;
var fetchUidEvent = FetchUserInfoEvent.Create(invitation.TargetUid);
- var results = await Collection.Business.SendEvent(fetchUidEvent, cancellationToken);
+ var results = await Collection.Business.SendEvent(fetchUidEvent);
uint targetUin = results.Count == 0 ? 0 : ((FetchUserInfoEvent)results[0]).UserInfo.Uin;
var invitationArgs = new GroupInvitationRequestEvent(invitation.GroupUin, targetUin, invitorUin);
@@ -206,7 +206,7 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
}
case FriendSysRecallEvent recall:
{
- uint fromUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.FromUid, false, cancellationToken) ?? 0;
+ uint fromUin = await Collection.Business.CachingLogic.ResolveUin(null, recall.FromUid) ?? 0;
var recallArgs = new FriendRecallEvent(fromUin, recall.ClientSequence, recall.Time, recall.Random, recall.Tip);
Collection.Invoker.PostEvent(recallArgs);
break;
@@ -230,7 +230,7 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
foreach (var chain in multi.Chains)
{
if (chain.Count == 0) continue;
- await ResolveIncomingChain(chain, cancellationToken);
+ await ResolveIncomingChain(chain);
MessageFilter.Filter(chain);
}
}
@@ -246,7 +246,7 @@ public override async Task Incoming(ProtocolEvent e, CancellationToken cancellat
}
}
- public override async Task Outgoing(ProtocolEvent e, CancellationToken cancellationToken)
+ public override async Task Outgoing(ProtocolEvent e)
{
switch (e)
{
@@ -254,23 +254,23 @@ public override async Task Outgoing(ProtocolEvent e, CancellationToken cancellat
{
foreach (var chain in chains)
{
- await ResolveChainMetadata(chain, cancellationToken);
- await ResolveOutgoingChain(chain, cancellationToken);
- await Collection.Highway.UploadResources(chain, cancellationToken);
+ await ResolveChainMetadata(chain);
+ await ResolveOutgoingChain(chain);
+ await Collection.Highway.UploadResources(chain);
}
break;
}
case SendMessageEvent send: // resolve Uin to Uid
{
- await ResolveChainMetadata(send.Chain, cancellationToken);
- await ResolveOutgoingChain(send.Chain, cancellationToken);
- await Collection.Highway.UploadResources(send.Chain, cancellationToken);
+ await ResolveChainMetadata(send.Chain);
+ await ResolveOutgoingChain(send.Chain);
+ await Collection.Highway.UploadResources(send.Chain);
break;
}
}
}
- private async Task ResolveIncomingChain(MessageChain chain, CancellationToken cancellationToken)
+ private async Task ResolveIncomingChain(MessageChain chain)
{
foreach (var entity in chain)
{
@@ -279,7 +279,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
case FileEntity { FileHash: not null, FileUuid: not null } file: // private
{
var @event = FileDownloadEvent.Create(file.FileUuid, file.FileHash, chain.Uid, chain.SelfUid);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (FileDownloadEvent)results[0];
@@ -291,7 +291,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
case FileEntity { FileId: not null } file when chain.GroupUin is not null: // group
{
var @event = GroupFSDownloadEvent.Create(chain.GroupUin.Value, file.FileId);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (GroupFSDownloadEvent)results[0];
@@ -303,7 +303,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
case MultiMsgEntity { ResId: not null } multi:
{
var @event = MultiMsgDownloadEvent.Create(chain.Uid ?? "", multi.ResId);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (MultiMsgDownloadEvent)results[0];
@@ -318,7 +318,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
? RecordGroupDownloadEvent.Create(chain.GroupUin ?? 0, record.MsgInfo)
: RecordDownloadEvent.Create(chain.Uid ?? string.Empty, record.MsgInfo);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (RecordDownloadEvent)results[0];
@@ -333,7 +333,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
? RecordGroupDownloadEvent.Create(chain.GroupUin ?? 0, record.AudioUuid)
: RecordDownloadEvent.Create(chain.Uid ?? string.Empty, record.AudioUuid);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (RecordDownloadEvent)results[0];
@@ -345,10 +345,10 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
case VideoEntity { VideoUuid: not null } video:
{
string uid = (chain.IsGroup
- ? await Collection.Business.CachingLogic.ResolveUid(chain.GroupUin, chain.FriendUin, cancellationToken)
+ ? await Collection.Business.CachingLogic.ResolveUid(chain.GroupUin, chain.FriendUin)
: chain.Uid) ?? "";
var @event = VideoDownloadEvent.Create(video.VideoUuid, uid, video.FilePath, "", "", chain.IsGroup);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (VideoDownloadEvent)results[0];
@@ -363,7 +363,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
? ImageGroupDownloadEvent.Create(image.GroupUin ?? 0, image.MsgInfo)
: ImageDownloadEvent.Create(image.FriendUid ?? string.Empty, image.MsgInfo);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (ImageDownloadEvent)results[0];
@@ -376,7 +376,7 @@ private async Task ResolveIncomingChain(MessageChain chain, CancellationToken ca
}
}
- private async Task ResolveOutgoingChain(MessageChain chain, CancellationToken cancellationToken)
+ private async Task ResolveOutgoingChain(MessageChain chain)
{
foreach (var entity in chain)
{
@@ -385,24 +385,24 @@ private async Task ResolveOutgoingChain(MessageChain chain, CancellationToken ca
case ForwardEntity forward when forward.TargetUin != 0:
{
var cache = Collection.Business.CachingLogic;
- forward.Uid = await cache.ResolveUid(chain.GroupUin, forward.TargetUin, cancellationToken) ?? throw new Exception($"Failed to resolve Uid for Uin {forward.TargetUin}");
+ forward.Uid = await cache.ResolveUid(chain.GroupUin, forward.TargetUin) ?? throw new Exception($"Failed to resolve Uid for Uin {forward.TargetUin}");
break;
}
case MentionEntity mention when mention.Uin != 0:
{
var cache = Collection.Business.CachingLogic;
- mention.Uid = await cache.ResolveUid(chain.GroupUin, mention.Uin, cancellationToken) ?? throw new Exception($"Failed to resolve Uid for Uin {mention.Uin}");
+ mention.Uid = await cache.ResolveUid(chain.GroupUin, mention.Uin) ?? throw new Exception($"Failed to resolve Uid for Uin {mention.Uin}");
if (chain is { IsGroup: true, GroupUin: not null } && mention.Name is null)
{
- var members = await Collection.Business.CachingLogic.GetCachedMembers(chain.GroupUin.Value, false, cancellationToken);
+ var members = await Collection.Business.CachingLogic.GetCachedMembers(chain.GroupUin.Value, false);
var member = members.FirstOrDefault(x => x.Uin == mention.Uin);
if (member != null) mention.Name = $"@{member.MemberCard ?? member.MemberName}";
}
else if (chain is { IsGroup: false } && mention.Name is null)
{
- var friends = await Collection.Business.CachingLogic.GetCachedFriends(false, cancellationToken);
+ var friends = await Collection.Business.CachingLogic.GetCachedFriends(false);
string? friend = friends.FirstOrDefault(x => x.Uin == mention.Uin)?.Nickname;
if (friend != null) mention.Name = $"@{friend}";
}
@@ -414,7 +414,7 @@ private async Task ResolveOutgoingChain(MessageChain chain, CancellationToken ca
if (chain.GroupUin != null) foreach (var c in multiMsg.Chains) c.GroupUin = chain.GroupUin;
var multiMsgEvent = MultiMsgUploadEvent.Create(chain.GroupUin, multiMsg.Chains);
- var results = await Collection.Business.SendEvent(multiMsgEvent, cancellationToken);
+ var results = await Collection.Business.SendEvent(multiMsgEvent);
if (results.Count != 0)
{
var result = (MultiMsgUploadEvent)results[0];
@@ -425,7 +425,7 @@ private async Task ResolveOutgoingChain(MessageChain chain, CancellationToken ca
case MultiMsgEntity { ResId: not null, Chains.Count: 0 } multiMsg:
{
var @event = MultiMsgDownloadEvent.Create(chain.Uid ?? "", multiMsg.ResId);
- var results = await Collection.Business.SendEvent(@event, cancellationToken);
+ var results = await Collection.Business.SendEvent(@event);
if (results.Count != 0)
{
var result = (MultiMsgDownloadEvent)results[0];
@@ -442,11 +442,11 @@ private async Task ResolveOutgoingChain(MessageChain chain, CancellationToken ca
/// for both Incoming and Outgoing MessageChain
///
/// The target chain
- private async Task ResolveChainMetadata(MessageChain chain, CancellationToken cancellationToken)
+ private async Task ResolveChainMetadata(MessageChain chain)
{
if (chain is { IsGroup: true, GroupUin: not null })
{
- var groups = await Collection.Business.CachingLogic.GetCachedMembers(chain.GroupUin.Value, false, cancellationToken);
+ var groups = await Collection.Business.CachingLogic.GetCachedMembers(chain.GroupUin.Value, false);
chain.GroupMemberInfo = chain.FriendUin == 0
? groups.FirstOrDefault(x => x.Uin == Collection.Keystore.Uin)
: groups.FirstOrDefault(x => x.Uin == chain.FriendUin);
@@ -455,7 +455,7 @@ private async Task ResolveChainMetadata(MessageChain chain, CancellationToken ca
}
else
{
- var friends = await Collection.Business.CachingLogic.GetCachedFriends(false, cancellationToken);
+ var friends = await Collection.Business.CachingLogic.GetCachedFriends(false);
if (friends.FirstOrDefault(x => x.Uin == chain.FriendUin) is { } friend)
{
chain.FriendInfo = friend;
diff --git a/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs b/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs
index 5b182c060..fdf82a6aa 100644
--- a/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs
+++ b/Lagrange.Core/Internal/Context/Logic/Implementation/OperationLogic.cs
@@ -18,29 +18,29 @@ internal class OperationLogic : LogicBase
internal OperationLogic(ContextCollection collection) : base(collection) { }
- public async Task> GetCookies(List domains, CancellationToken cancellation)
+ public async Task> GetCookies(List domains)
{
var fetchCookieEvent = FetchCookieEvent.Create(domains);
- var events = await Collection.Business.SendEvent(fetchCookieEvent, cancellation);
+ var events = await Collection.Business.SendEvent(fetchCookieEvent);
return events.Count != 0 ? ((FetchCookieEvent)events[0]).Cookies : new List();
}
- public Task> FetchFriends(bool refreshCache = false, CancellationToken cancellationToken = default) =>
- Collection.Business.CachingLogic.GetCachedFriends(refreshCache, cancellationToken);
+ public Task> FetchFriends(bool refreshCache = false) =>
+ Collection.Business.CachingLogic.GetCachedFriends(refreshCache);
- public Task> FetchMembers(uint groupUin, CancellationToken cancellationToken, bool refreshCache = false) =>
- Collection.Business.CachingLogic.GetCachedMembers(groupUin, refreshCache, cancellationToken);
+ public Task> FetchMembers(uint groupUin, bool refreshCache = false) =>
+ Collection.Business.CachingLogic.GetCachedMembers(groupUin, refreshCache);
- public Task> FetchGroups(bool refreshCache, CancellationToken cancellationToken) =>
- Collection.Business.CachingLogic.GetCachedGroups(refreshCache, cancellationToken);
+ public Task> FetchGroups(bool refreshCache) =>
+ Collection.Business.CachingLogic.GetCachedGroups(refreshCache);
- public async Task SendMessage(MessageChain chain, CancellationToken cancellation)
+ public async Task SendMessage(MessageChain chain)
{
uint clientSeq = chain.ClientSequence;
ulong messageId = chain.MessageId;
var sendMessageEvent = SendMessageEvent.Create(chain);
- var events = await Collection.Business.SendEvent(sendMessageEvent, cancellation);
+ var events = await Collection.Business.SendEvent(sendMessageEvent);
if (events.Count == 0) return new MessageResult { Result = 9057 };
var result = ((SendMessageEvent)events[0]).MsgResult;
@@ -49,47 +49,47 @@ public async Task SendMessage(MessageChain chain, CancellationTok
return result;
}
- public async Task MuteGroupMember(uint groupUin, uint targetUin, uint duration, CancellationToken cancellationToken)
+ public async Task MuteGroupMember(uint groupUin, uint targetUin, uint duration)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin);
if (uid == null) return false;
var muteGroupMemberEvent = GroupMuteMemberEvent.Create(groupUin, duration, uid);
- var events = await Collection.Business.SendEvent(muteGroupMemberEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(muteGroupMemberEvent);
return events.Count != 0 && ((GroupMuteMemberEvent)events[0]).ResultCode == 0;
}
- public async Task MuteGroupGlobal(uint groupUin, bool isMute, CancellationToken cancellationToken)
+ public async Task MuteGroupGlobal(uint groupUin, bool isMute)
{
var muteGroupMemberEvent = GroupMuteGlobalEvent.Create(groupUin, isMute);
- var events = await Collection.Business.SendEvent(muteGroupMemberEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(muteGroupMemberEvent);
return events.Count != 0 && ((GroupMuteGlobalEvent)events[0]).ResultCode == 0;
}
- public async Task KickGroupMember(uint groupUin, uint targetUin, bool rejectAddRequest, string reason, CancellationToken cancellationToken)
+ public async Task KickGroupMember(uint groupUin, uint targetUin, bool rejectAddRequest, string reason)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin);
if (uid == null) return false;
var muteGroupMemberEvent = GroupKickMemberEvent.Create(groupUin, uid, rejectAddRequest, reason);
- var events = await Collection.Business.SendEvent(muteGroupMemberEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(muteGroupMemberEvent);
return events.Count != 0 && ((GroupKickMemberEvent)events[0]).ResultCode == 0;
}
- public async Task SetGroupAdmin(uint groupUin, uint targetUin, bool isAdmin, CancellationToken cancellationToken)
+ public async Task SetGroupAdmin(uint groupUin, uint targetUin, bool isAdmin)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin);
if (uid == null) return false;
var setGroupAdminEvent = GroupSetAdminEvent.Create(groupUin, uid, isAdmin);
- var events = await Collection.Business.SendEvent(setGroupAdminEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(setGroupAdminEvent);
return events.Count != 0 && ((GroupSetAdminEvent)events[0]).ResultCode == 0;
}
- public async Task<(int, string?)> SetGroupTodo(uint groupUin, uint sequence, CancellationToken cancellationToken)
+ public async Task<(int, string?)> SetGroupTodo(uint groupUin, uint sequence)
{
var setGroupTodoEvent = GroupSetTodoEvent.Create(groupUin, sequence);
- var events = await Collection.Business.SendEvent(setGroupTodoEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(setGroupTodoEvent);
if (events.Count == 0) return (-1, "No Events");
@@ -98,10 +98,10 @@ public async Task SetGroupAdmin(uint groupUin, uint targetUin, bool isAdmi
return (@event.ResultCode, @event.ResultMessage);
}
- public async Task<(int, string?)> RemoveGroupTodo(uint groupUin, CancellationToken cancellationToken)
+ public async Task<(int, string?)> RemoveGroupTodo(uint groupUin)
{
var setGroupTodoEvent = GroupRemoveTodoEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(setGroupTodoEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(setGroupTodoEvent);
if (events.Count == 0) return (-1, "No Event");
@@ -110,10 +110,10 @@ public async Task SetGroupAdmin(uint groupUin, uint targetUin, bool isAdmi
return (@event.ResultCode, @event.ResultMessage);
}
- public async Task<(int, string?)> FinishGroupTodo(uint groupUin, CancellationToken cancellationToken)
+ public async Task<(int, string?)> FinishGroupTodo(uint groupUin)
{
var setGroupTodoEvent = GroupFinishTodoEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(setGroupTodoEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(setGroupTodoEvent);
if (events.Count == 0) return (-1, "No Event");
@@ -122,10 +122,10 @@ public async Task SetGroupAdmin(uint groupUin, uint targetUin, bool isAdmi
return (@event.ResultCode, @event.ResultMessage);
}
- public async Task GetGroupTodo(uint groupUin, CancellationToken cancellationToken)
+ public async Task GetGroupTodo(uint groupUin)
{
var setGroupTodoEvent = GroupGetTodoEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(setGroupTodoEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(setGroupTodoEvent);
if (events.Count == 0) return new(-1, "No Event", 0, 0, string.Empty);
@@ -140,73 +140,73 @@ public async Task GetGroupTodo(uint groupUin, Cancellatio
);
}
- public async Task SetGroupBot(uint BotId, uint On, uint groupUin, CancellationToken cancellationToken)
+ public async Task SetGroupBot(uint BotId, uint On, uint groupUin)
{
var muteBotEvent = GroupSetBotEvent.Create(BotId, On, groupUin);
- var events = await Collection.Business.SendEvent(muteBotEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(muteBotEvent);
return events.Count != 0 && ((GroupSetBotEvent)events[0]).ResultCode == 0;
}
- public async Task SetGroupBotHD(uint BotId, uint groupUin, string? data_1, string? data_2, CancellationToken cancellationToken)
+ public async Task SetGroupBotHD(uint BotId, uint groupUin, string? data_1, string? data_2)
{
var muteBotEvent = GroupSetBothdEvent.Create(BotId, groupUin, data_1, data_2);
- var events = await Collection.Business.SendEvent(muteBotEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(muteBotEvent);
return events.Count != 0 && ((GroupSetBothdEvent)events[0]).ResultCode == 0;
}
- public async Task RenameGroupMember(uint groupUin, uint targetUin, string targetName, CancellationToken cancellationToken)
+ public async Task RenameGroupMember(uint groupUin, uint targetUin, string targetName)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin);
if (uid == null) return false;
var renameGroupEvent = RenameMemberEvent.Create(groupUin, uid, targetName);
- var events = await Collection.Business.SendEvent(renameGroupEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(renameGroupEvent);
return events.Count != 0 && ((RenameMemberEvent)events[0]).ResultCode == 0;
}
- public async Task RenameGroup(uint groupUin, string targetName, CancellationToken cancellationToken)
+ public async Task RenameGroup(uint groupUin, string targetName)
{
var renameGroupEvent = GroupRenameEvent.Create(groupUin, targetName);
- var events = await Collection.Business.SendEvent(renameGroupEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(renameGroupEvent);
return events.Count != 0 && ((GroupRenameEvent)events[0]).ResultCode == 0;
}
- public async Task RemarkGroup(uint groupUin, string targetRemark, CancellationToken cancellationToken)
+ public async Task RemarkGroup(uint groupUin, string targetRemark)
{
var renameGroupEvent = GroupRemarkEvent.Create(groupUin, targetRemark);
- var events = await Collection.Business.SendEvent(renameGroupEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(renameGroupEvent);
return events.Count != 0 && ((GroupRemarkEvent)events[0]).ResultCode == 0;
}
- public async Task LeaveGroup(uint groupUin, CancellationToken cancellationToken)
+ public async Task LeaveGroup(uint groupUin)
{
var leaveGroupEvent = GroupLeaveEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(leaveGroupEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(leaveGroupEvent);
return events.Count != 0 && ((GroupLeaveEvent)events[0]).ResultCode == 0;
}
- public async Task FetchGroupFSSpace(uint groupUin, CancellationToken cancellationToken)
+ public async Task FetchGroupFSSpace(uint groupUin)
{
var groupFSSpaceEvent = GroupFSSpaceEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(groupFSSpaceEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSSpaceEvent);
return ((GroupFSSpaceEvent)events[0]).TotalSpace - ((GroupFSSpaceEvent)events[0]).UsedSpace;
}
- public async Task FetchGroupFSCount(uint groupUin, CancellationToken cancellationToken)
+ public async Task FetchGroupFSCount(uint groupUin)
{
var groupFSSpaceEvent = GroupFSCountEvent.Create(groupUin);
- var events = await Collection.Business.SendEvent(groupFSSpaceEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSSpaceEvent);
return ((GroupFSCountEvent)events[0]).FileCount;
}
- public async Task> FetchGroupFSList(uint groupUin, string targetDirectory, CancellationToken cancellationToken)
+ public async Task> FetchGroupFSList(uint groupUin, string targetDirectory)
{
uint startIndex = 0;
var entries = new List();
while (true)
{
var groupFSListEvent = GroupFSListEvent.Create(groupUin, targetDirectory, startIndex, 20);
- var events = await Collection.Business.SendEvent(groupFSListEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSListEvent);
if (events.Count == 0) break;
entries.AddRange(((GroupFSListEvent)events[0]).FileEntries);
if (((GroupFSListEvent)events[0]).IsEnd) break;
@@ -215,67 +215,63 @@ public async Task> FetchGroupFSList(uint groupUin, string targ
return entries;
}
- public async Task FetchGroupFSDownload(uint groupUin, string fileId, CancellationToken cancellationToken)
+ public async Task FetchGroupFSDownload(uint groupUin, string fileId)
{
var groupFSDownloadEvent = GroupFSDownloadEvent.Create(groupUin, fileId);
- var events = await Collection.Business.SendEvent(groupFSDownloadEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSDownloadEvent);
return $"{((GroupFSDownloadEvent)events[0]).FileUrl}{fileId}";
}
- public async Task<(int, string)> GroupFSMove(uint groupUin, string fileId, string parentDirectory, string targetDirectory, CancellationToken cancellationToken)
+ public async Task<(int, string)> GroupFSMove(uint groupUin, string fileId, string parentDirectory, string targetDirectory)
{
var groupFSMoveEvent = GroupFSMoveEvent.Create(groupUin, fileId, parentDirectory, targetDirectory);
- var events = await Collection.Business.SendEvent(groupFSMoveEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSMoveEvent);
int retCode = events.Count > 0 ? ((GroupFSMoveEvent)events[0]).ResultCode : -1;
string retMsg = events.Count > 0 ? ((GroupFSMoveEvent)events[0]).RetMsg : string.Empty;
return (retCode, retMsg);
}
- public async Task<(int, string)> GroupFSDelete(uint groupUin, string fileId, CancellationToken cancellationToken)
+ public async Task<(int, string)> GroupFSDelete(uint groupUin, string fileId)
{
var groupFSDeleteEvent = GroupFSDeleteEvent.Create(groupUin, fileId);
- var events = await Collection.Business.SendEvent(groupFSDeleteEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSDeleteEvent);
int retCode = events.Count > 0 ? ((GroupFSDeleteEvent)events[0]).ResultCode : -1;
string retMsg = events.Count > 0 ? ((GroupFSDeleteEvent)events[0]).RetMsg : string.Empty;
return (retCode, retMsg);
}
- public async Task<(int, string)> GroupFSCreateFolder(uint groupUin, string name, CancellationToken cancellationToken)
+ public async Task<(int, string)> GroupFSCreateFolder(uint groupUin, string name)
{
var groupFSCreateFolderEvent = GroupFSCreateFolderEvent.Create(groupUin, name);
- var events = await Collection.Business.SendEvent(groupFSCreateFolderEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSCreateFolderEvent);
int retCode = events.Count > 0 ? ((GroupFSCreateFolderEvent)events[0]).ResultCode : -1;
string retMsg = events.Count > 0 ? ((GroupFSCreateFolderEvent)events[0]).RetMsg : string.Empty;
return (retCode, retMsg);
}
- public async Task<(int, string)> GroupFSDeleteFolder(uint groupUin, string folderId, CancellationToken cancellationToken)
+ public async Task<(int, string)> GroupFSDeleteFolder(uint groupUin, string folderId)
{
var groupFSDeleteFolderEvent = GroupFSDeleteFolderEvent.Create(groupUin, folderId);
- var events = await Collection.Business.SendEvent(groupFSDeleteFolderEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSDeleteFolderEvent);
int retCode = events.Count > 0 ? ((GroupFSDeleteFolderEvent)events[0]).ResultCode : -1;
string retMsg = events.Count > 0 ? ((GroupFSDeleteFolderEvent)events[0]).RetMsg : string.Empty;
return (retCode, retMsg);
}
- public async Task<(int, string)> GroupFSRenameFolder(uint groupUin, string folderId, string newFolderName, CancellationToken cancellationToken)
+ public async Task<(int, string)> GroupFSRenameFolder(uint groupUin, string folderId, string newFolderName)
{
var groupFSDeleteFolderEvent = GroupFSRenameFolderEvent.Create(groupUin, folderId, newFolderName);
- var events = await Collection.Business.SendEvent(groupFSDeleteFolderEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(groupFSDeleteFolderEvent);
int retCode = events.Count > 0 ? ((GroupFSRenameFolderEvent)events[0]).ResultCode : -1;
string retMsg = events.Count > 0 ? ((GroupFSRenameFolderEvent)events[0]).RetMsg : "";
return (retCode, retMsg);
}
- public Task GroupFSUpload(uint groupUin, FileEntity fileEntity, string targetDirectory, CancellationToken cancellationToken)
+ public Task GroupFSUpload(uint groupUin, FileEntity fileEntity, string targetDirectory)
{
try
{
- return FileUploader.UploadGroup(Collection, MessageBuilder.Group(groupUin).Build(), fileEntity, targetDirectory, cancellationToken);
- }
- catch (TaskCanceledException)
- {
- throw;
+ return FileUploader.UploadGroup(Collection, MessageBuilder.Group(groupUin).Build(), fileEntity, targetDirectory);
}
catch
{
@@ -283,18 +279,14 @@ public Task GroupFSUpload(uint groupUin, FileEntity fileEntity, string tar
}
}
- public async Task UploadFriendFile(uint targetUin, FileEntity fileEntity, CancellationToken cancellationToken)
+ public async Task UploadFriendFile(uint targetUin, FileEntity fileEntity)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(null, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(null, targetUin);
var chain = new MessageChain(targetUin, Collection.Keystore.Uid ?? "", uid ?? "") { fileEntity };
try
{
- return await FileUploader.UploadPrivate(Collection, chain, fileEntity, cancellationToken);
- }
- catch (TaskCanceledException)
- {
- throw;
+ return await FileUploader.UploadPrivate(Collection, chain, fileEntity);
}
catch
{
@@ -302,55 +294,55 @@ public async Task UploadFriendFile(uint targetUin, FileEntity fileEntity,
}
}
- public async Task RecallGroupMessage(uint groupUin, MessageResult result, CancellationToken cancellationToken)
+ public async Task RecallGroupMessage(uint groupUin, MessageResult result)
{
if (result.Sequence == null) return false;
var recallMessageEvent = RecallGroupMessageEvent.Create(groupUin, result.Sequence.Value);
- var events = await Collection.Business.SendEvent(recallMessageEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(recallMessageEvent);
return events.Count != 0 && ((RecallGroupMessageEvent)events[0]).ResultCode == 0;
}
- public async Task RecallGroupMessage(MessageChain chain, CancellationToken cancellationToken)
+ public async Task RecallGroupMessage(MessageChain chain)
{
if (chain.GroupUin == null) return false;
var recallMessageEvent = RecallGroupMessageEvent.Create(chain.GroupUin.Value, chain.Sequence);
- var events = await Collection.Business.SendEvent(recallMessageEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(recallMessageEvent);
return events.Count != 0 && ((RecallGroupMessageEvent)events[0]).ResultCode == 0;
}
- public async Task RecallGroupMessage(uint groupUin, uint sequence, CancellationToken cancellationToken)
+ public async Task RecallGroupMessage(uint groupUin, uint sequence)
{
var recallMessageEvent = RecallGroupMessageEvent.Create(groupUin, sequence);
- var events = await Collection.Business.SendEvent(recallMessageEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(recallMessageEvent);
return events.Count != 0 && ((RecallGroupMessageEvent)events[0]).ResultCode == 0;
}
- public async Task RecallFriendMessage(uint friendUin, MessageResult result, CancellationToken cancellationToken)
+ public async Task RecallFriendMessage(uint friendUin, MessageResult result)
{
if (result.Sequence == null) return false;
- if (await Collection.Business.CachingLogic.ResolveUid(null, friendUin, cancellationToken) is not { } uid) return false;
+ if (await Collection.Business.CachingLogic.ResolveUid(null, friendUin) is not { } uid) return false;
var recallMessageEvent = RecallFriendMessageEvent.Create(uid, result.ClientSequence, result.Sequence ?? 0, (uint)(result.MessageId & uint.MaxValue), result.Timestamp);
- var events = await Collection.Business.SendEvent(recallMessageEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(recallMessageEvent);
return events.Count != 0 && ((RecallFriendMessageEvent)events[0]).ResultCode == 0;
}
- public async Task RecallFriendMessage(MessageChain chain, CancellationToken cancellationToken)
+ public async Task RecallFriendMessage(MessageChain chain)
{
- if (await Collection.Business.CachingLogic.ResolveUid(null, chain.TargetUin, cancellationToken) is not { } uid) return false;
+ if (await Collection.Business.CachingLogic.ResolveUid(null, chain.TargetUin) is not { } uid) return false;
uint timestamp = (uint)new DateTimeOffset(chain.Time).ToUnixTimeSeconds();
var recallMessageEvent = RecallFriendMessageEvent.Create(uid, chain.ClientSequence, chain.Sequence, (uint)(chain.MessageId & uint.MaxValue), timestamp);
- var events = await Collection.Business.SendEvent(recallMessageEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(recallMessageEvent);
return events.Count != 0 && ((RecallFriendMessageEvent)events[0]).ResultCode == 0;
}
- public async Task?> FetchGroupRequests(CancellationToken cancellationToken)
+ public async Task?> FetchGroupRequests()
{
var fetchRequestsEvent = FetchGroupRequestsEvent.Create();
- var events = await Collection.Business.SendEvent(fetchRequestsEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(fetchRequestsEvent);
if (events.Count == 0) return null;
var resolved = events.Cast().SelectMany(e => e.Events).ToList();
@@ -386,15 +378,15 @@ async Task ResolveUid(string? uid)
if (uid == null) return 0;
var fetchUidEvent = FetchUserInfoEvent.Create(uid);
- var e = await Collection.Business.SendEvent(fetchUidEvent, cancellationToken);
+ var e = await Collection.Business.SendEvent(fetchUidEvent);
return e.Count == 0 ? 0 : ((FetchUserInfoEvent)e[0]).UserInfo.Uin;
}
}
- public async Task?> FetchFriendRequests(CancellationToken cancellationToken)
+ public async Task?> FetchFriendRequests()
{
var fetchRequestsEvent = FetchFriendsRequestsEvent.Create();
- var events = await Collection.Business.SendEvent(fetchRequestsEvent, cancellationToken);
+ var events = await Collection.Business.SendEvent(fetchRequestsEvent);
if (events.Count == 0) return null;
var resolved = ((FetchFriendsRequestsEvent)events[0]).Requests;
@@ -412,132 +404,132 @@ async Task ResolveUid(string? uid)
if (uid == null) return 0;
var fetchUidEvent = FetchUserInfoEvent.Create(uid);
- var e = await Collection.Business.SendEvent(fetchUidEvent, cancellationToken);
+ var e = await Collection.Business.SendEvent(fetchUidEvent);
return e.Count == 0 ? 0 : ((FetchUserInfoEvent)e[0]).UserInfo.Uin;
}
}
- public async Task GroupTransfer(uint groupUin, uint targetUin, CancellationToken cancellationToken)
+ public async Task GroupTransfer(uint groupUin, uint targetUin)
{
- string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin, cancellationToken);
+ string? uid = await Collection.Business.CachingLogic.ResolveUid(groupUin, targetUin);
if (uid == null || Collection.Keystore.Uid is not { } source) return false;
var transferEvent = GroupTransferEvent.Create(groupUin, source, uid);
- var results = await Collection.Business.SendEvent(transferEvent, cancellationToken);
+ var results = await Collection.Business.SendEvent(transferEvent);
return results.Count != 0 && results[0].ResultCode == 0;
}
- public async Task