This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
186 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Flandre.Core.Extensions; | ||
|
||
/// <summary> | ||
/// <see cref="FlandreApp" /> 的扩展方法 | ||
/// </summary> | ||
public static class AppExtensions | ||
{ | ||
/// <summary> | ||
/// 设置群组代理 Bot(主 Bot) | ||
/// </summary> | ||
/// <param name="app">FlandreApp 实例</param> | ||
/// <param name="platform">平台</param> | ||
/// <param name="guildId">群组 ID</param> | ||
/// <param name="botId">Bot.SelfId</param> | ||
public static void SetGuildAssignee(this FlandreApp app, string platform, string guildId, string botId) | ||
{ | ||
app.GuildAssignees.AddOrUpdate($"{platform}:{guildId}", botId, (_, _) => botId); | ||
} | ||
|
||
/// <summary> | ||
/// 检查群组是否已被代理(已设置主 bot) | ||
/// </summary> | ||
/// <param name="app">FlandreApp 实例</param> | ||
/// <param name="platform">平台</param> | ||
/// <param name="botId">Bot.SelfId</param> | ||
public static bool IsGuildAssigned(this FlandreApp app, string platform, string botId) | ||
{ | ||
return app.GuildAssignees.ContainsKey($"{platform}:{botId}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Flandre.Core.Messaging; | ||
|
||
namespace Flandre.Core.Extensions; | ||
|
||
/// <summary> | ||
/// 上下文扩展方法 | ||
/// </summary> | ||
public static class ContextExtensions | ||
{ | ||
/// <summary> | ||
/// 将 Bot 设置为群组主 Bot | ||
/// </summary> | ||
/// <param name="ctx">消息上下文</param> | ||
public static void SetBotAsGuildAssignee(this MessageContext ctx) | ||
{ | ||
if (ctx.GuildId is null) return; | ||
ctx.App.SetGuildAssignee(ctx.Platform, ctx.GuildId, ctx.SelfId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.