mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 22:55:03 +00:00
Merge 9673678a4e
into eb5fda8d19
This commit is contained in:
commit
45d685ac29
12 changed files with 164 additions and 109 deletions
|
@ -38,7 +38,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"deep-diff": "^1.0.2",
|
||||
"discord.js": "^14.14.1",
|
||||
"discord.js": "^14.15.3",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
|
|
|
@ -119,6 +119,16 @@ export class GuildSavedMessages extends BaseGuildRepository<SavedMessage> {
|
|||
}));
|
||||
}
|
||||
|
||||
if (msg.poll) {
|
||||
data.poll = {
|
||||
question: msg.poll.question,
|
||||
answers: msg.poll.answers.map((answer) => ({
|
||||
id: answer.id,
|
||||
text: answer.text,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,16 @@ export interface ISavedMessageStickerData {
|
|||
type: StickerType | null;
|
||||
}
|
||||
|
||||
export interface ISavedMessagePollData {
|
||||
question: {
|
||||
text: string;
|
||||
};
|
||||
answers: {
|
||||
id: number;
|
||||
text: string | null;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface ISavedMessageData {
|
||||
attachments?: ISavedMessageAttachmentData[];
|
||||
author: {
|
||||
|
@ -74,6 +84,7 @@ export interface ISavedMessageData {
|
|||
content: string;
|
||||
embeds?: ISavedMessageEmbedData[];
|
||||
stickers?: ISavedMessageStickerData[];
|
||||
poll?: ISavedMessagePollData;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,5 +30,10 @@ export function getTextMatchPartialSummary(
|
|||
return `visible name: ${visibleName}`;
|
||||
} else if (type === "customstatus") {
|
||||
return `custom status: ${context.member!.presence?.activities.find((a) => a.type === ActivityType.Custom)?.name}`;
|
||||
} else if (type == "poll") {
|
||||
const message = context.message!;
|
||||
const channel = pluginData.guild.channels.cache.get(message.channel_id as Snowflake);
|
||||
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
|
||||
return `poll in ${channelMention}:\n${messageSummary(message)}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,10 @@ type TextTriggerWithMultipleMatchTypes = {
|
|||
match_usernames: boolean;
|
||||
match_nicknames: boolean;
|
||||
match_custom_status: boolean;
|
||||
match_polls: boolean;
|
||||
};
|
||||
|
||||
export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus";
|
||||
export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus" | "poll";
|
||||
|
||||
type YieldedContent = [MatchableTextType, string];
|
||||
|
||||
|
@ -59,4 +60,8 @@ export async function* matchMultipleTextTypesOnMessage(
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (trigger.match_polls && msg.data.poll) {
|
||||
yield ["poll", JSON.stringify(msg.data.poll)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchInvitesTrigger = automodTrigger<MatchResultType>()({
|
||||
|
|
|
@ -47,6 +47,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchLinksTrigger = automodTrigger<MatchResultType>()({
|
||||
|
|
|
@ -24,6 +24,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
const regexCache = new WeakMap<any, RegExp[]>();
|
||||
|
|
|
@ -27,6 +27,7 @@ const configSchema = z.strictObject({
|
|||
match_usernames: z.boolean().default(false),
|
||||
match_nicknames: z.boolean().default(false),
|
||||
match_custom_status: z.boolean().default(false),
|
||||
match_polls: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const MatchWordsTrigger = automodTrigger<MatchResultType>()({
|
||||
|
|
|
@ -1328,6 +1328,17 @@ export function messageSummary(msg: SavedMessage) {
|
|||
"\n";
|
||||
}
|
||||
|
||||
if (msg.data.poll) {
|
||||
const poll = msg.data.poll;
|
||||
result +=
|
||||
"Poll: ```" +
|
||||
escapeCodeBlock(
|
||||
`Question: ${poll.question.text}
|
||||
Answers: ${poll.answers.map((answer) => `"${answer.text}"`).join(" | ")}`,
|
||||
) +
|
||||
"```";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ export const PERMISSION_NAMES = {
|
|||
BanMembers: "Ban Members",
|
||||
ChangeNickname: "Change Nickname",
|
||||
Connect: "Connect",
|
||||
CreateEvents: "Create Events",
|
||||
CreateGuildExpressions: "Create Expressions",
|
||||
CreateInstantInvite: "Create Invite",
|
||||
CreatePrivateThreads: "Create Private Threads",
|
||||
CreatePublicThreads: "Create Public Threads",
|
||||
|
@ -16,13 +18,16 @@ export const PERMISSION_NAMES = {
|
|||
KickMembers: "Kick Members",
|
||||
ManageChannels: "Manage Channels",
|
||||
ManageEmojisAndStickers: "Manage Emojis and Stickers",
|
||||
ManageEvents: "Manage Events",
|
||||
ManageGuild: "Manage Server",
|
||||
ManageGuildExpressions: "Manage Expressions",
|
||||
ManageMessages: "Manage Messages",
|
||||
ManageNicknames: "Manage Nicknames",
|
||||
ManageRoles: "Manage Roles",
|
||||
ManageThreads: "Manage Threads",
|
||||
ManageWebhooks: "Manage Webhooks",
|
||||
MentionEveryone: `Mention @${EMPTY_CHAR}everyone, @${EMPTY_CHAR}here, and All Roles`,
|
||||
ModerateMembers: "Moderate Members",
|
||||
MoveMembers: "Move Members",
|
||||
MuteMembers: "Mute Members",
|
||||
PrioritySpeaker: "Priority Speaker",
|
||||
|
@ -30,22 +35,20 @@ export const PERMISSION_NAMES = {
|
|||
RequestToSpeak: "Request to Speak",
|
||||
SendMessages: "Send Messages",
|
||||
SendMessagesInThreads: "Send Messages in Threads",
|
||||
SendPolls: "Create Polls",
|
||||
SendTTSMessages: "Send Text-To-Speech Messages",
|
||||
SendVoiceMessages: "Send Voice Messages",
|
||||
Speak: "Speak",
|
||||
UseEmbeddedActivities: "Start Embedded Activities",
|
||||
Stream: "Video",
|
||||
UseApplicationCommands: "Use Application Commands",
|
||||
UseEmbeddedActivities: "Start Embedded Activities",
|
||||
UseExternalEmojis: "Use External Emoji",
|
||||
UseExternalSounds: "Use External Sounds",
|
||||
UseExternalStickers: "Use External Stickers",
|
||||
UseSoundboard: "Use Soundboard",
|
||||
UseVAD: "Use Voice Activity",
|
||||
ViewAuditLog: "View Audit Log",
|
||||
ViewChannel: "View Channels",
|
||||
ViewGuildInsights: "View Guild Insights",
|
||||
ModerateMembers: "Moderate Members",
|
||||
ManageEvents: "Manage Events",
|
||||
ManageGuildExpressions: "Manage Expressions",
|
||||
SendVoiceMessages: "Send Voice Messages",
|
||||
UseExternalSounds: "Use External Sounds",
|
||||
UseSoundboard: "Use Soundboard",
|
||||
ViewCreatorMonetizationAnalytics: "View Creator Monetization Analytics",
|
||||
ViewGuildInsights: "View Guild Insights",
|
||||
} as const satisfies Record<keyof typeof PermissionFlagsBits, string>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue