3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-06 10:37:19 +00:00
This commit is contained in:
rubyowo 2025-06-29 14:50:16 +01:00 committed by GitHub
commit f363ab31bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 47 additions and 2 deletions

View file

@ -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; return data;
} }

View file

@ -1,4 +1,4 @@
import { EmbedType, Snowflake, StickerFormatType, StickerType } from "discord.js"; import { EmbedType, Snowflake, StickerFormatType, StickerType, PollQuestionMedia } from "discord.js";
import { Column, Entity, PrimaryColumn } from "typeorm"; import { Column, Entity, PrimaryColumn } from "typeorm";
export interface ISavedMessageAttachmentData { export interface ISavedMessageAttachmentData {
@ -65,6 +65,14 @@ export interface ISavedMessageStickerData {
type: StickerType | null; type: StickerType | null;
} }
export interface ISavedMessagePollData {
question: PollQuestionMedia;
answers: {
id: number;
text: string | null;
}[];
}
export interface ISavedMessageData { export interface ISavedMessageData {
attachments?: ISavedMessageAttachmentData[]; attachments?: ISavedMessageAttachmentData[];
author: { author: {
@ -74,6 +82,7 @@ export interface ISavedMessageData {
content: string; content: string;
embeds?: ISavedMessageEmbedData[]; embeds?: ISavedMessageEmbedData[];
stickers?: ISavedMessageStickerData[]; stickers?: ISavedMessageStickerData[];
poll?: ISavedMessagePollData;
timestamp: number; timestamp: number;
} }

View file

@ -30,5 +30,11 @@ export function getTextMatchPartialSummary(
return `visible name: ${visibleName}`; return `visible name: ${visibleName}`;
} else if (type === "customstatus") { } else if (type === "customstatus") {
return `custom status: ${context.member!.presence?.activities.find((a) => a.type === ActivityType.Custom)?.name}`; 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)}`;
} }
} }

View file

@ -12,9 +12,10 @@ type TextTriggerWithMultipleMatchTypes = {
match_usernames: boolean; match_usernames: boolean;
match_nicknames: boolean; match_nicknames: boolean;
match_custom_status: 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]; type YieldedContent = [MatchableTextType, string];
@ -59,4 +60,8 @@ export async function* matchMultipleTextTypesOnMessage(
break; break;
} }
} }
if (trigger.match_polls && msg.data.poll) {
yield ["poll", JSON.stringify(msg.data.poll)];
}
} }

View file

@ -24,6 +24,7 @@ const configSchema = z.strictObject({
match_usernames: z.boolean().default(false), match_usernames: z.boolean().default(false),
match_nicknames: z.boolean().default(false), match_nicknames: z.boolean().default(false),
match_custom_status: z.boolean().default(false), match_custom_status: z.boolean().default(false),
match_polls: z.boolean().default(false),
}); });
export const MatchInvitesTrigger = automodTrigger<MatchResultType>()({ export const MatchInvitesTrigger = automodTrigger<MatchResultType>()({

View file

@ -47,6 +47,7 @@ const configSchema = z.strictObject({
match_usernames: z.boolean().default(false), match_usernames: z.boolean().default(false),
match_nicknames: z.boolean().default(false), match_nicknames: z.boolean().default(false),
match_custom_status: z.boolean().default(false), match_custom_status: z.boolean().default(false),
match_polls: z.boolean().default(false),
}); });
export const MatchLinksTrigger = automodTrigger<MatchResultType>()({ export const MatchLinksTrigger = automodTrigger<MatchResultType>()({

View file

@ -24,6 +24,7 @@ const configSchema = z.strictObject({
match_usernames: z.boolean().default(false), match_usernames: z.boolean().default(false),
match_nicknames: z.boolean().default(false), match_nicknames: z.boolean().default(false),
match_custom_status: z.boolean().default(false), match_custom_status: z.boolean().default(false),
match_polls: z.boolean().default(false),
}); });
const regexCache = new WeakMap<any, RegExp[]>(); const regexCache = new WeakMap<any, RegExp[]>();

View file

@ -28,6 +28,7 @@ const configSchema = z.strictObject({
match_usernames: z.boolean().default(false), match_usernames: z.boolean().default(false),
match_nicknames: z.boolean().default(false), match_nicknames: z.boolean().default(false),
match_custom_status: z.boolean().default(false), match_custom_status: z.boolean().default(false),
match_polls: z.boolean().default(false),
}); });
export const MatchWordsTrigger = automodTrigger<MatchResultType>()({ export const MatchWordsTrigger = automodTrigger<MatchResultType>()({

View file

@ -1337,6 +1337,17 @@ export function messageSummary(msg: SavedMessage) {
"\n"; "\n";
} }
if (msg.data.poll) {
const { poll } = msg.data;
result +=
"Poll: ```" +
escapeCodeBlock(
`Question: ${poll.question.text}
Answers: ${poll.answers.map((answer) => `${answer.text}`).join(" | ")}`
) +
"```";
}
return result; return result;
} }