mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
fix: partial summary
This commit is contained in:
parent
4252cb5ce0
commit
112bbc5478
5 changed files with 15 additions and 13 deletions
|
@ -121,11 +121,11 @@ export class GuildSavedMessages extends BaseGuildRepository<SavedMessage> {
|
||||||
|
|
||||||
if (msg.poll) {
|
if (msg.poll) {
|
||||||
data.poll = {
|
data.poll = {
|
||||||
|
question: msg.poll.question,
|
||||||
answers: Array.from(msg.poll.answers.values()).map((answer) => ({
|
answers: Array.from(msg.poll.answers.values()).map((answer) => ({
|
||||||
id: answer.id,
|
id: answer.id,
|
||||||
text: answer.text,
|
text: answer.text,
|
||||||
})),
|
})),
|
||||||
question: msg.poll.question,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,13 +65,13 @@ export interface ISavedMessageStickerData {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISavedMessagePollData {
|
export interface ISavedMessagePollData {
|
||||||
|
question: {
|
||||||
|
text: string;
|
||||||
|
};
|
||||||
answers: {
|
answers: {
|
||||||
id: number;
|
id: number;
|
||||||
text: string | null;
|
text: string | null;
|
||||||
}[];
|
}[];
|
||||||
question: {
|
|
||||||
text: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISavedMessageData {
|
export interface ISavedMessageData {
|
||||||
|
|
|
@ -30,5 +30,10 @@ 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)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,7 @@ type TextTriggerWithMultipleMatchTypes = {
|
||||||
match_polls: boolean;
|
match_polls: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MatchableTextType =
|
export type MatchableTextType = "message" | "embed" | "visiblename" | "username" | "nickname" | "customstatus" | "poll";
|
||||||
| "message"
|
|
||||||
| "embed"
|
|
||||||
| "visiblename"
|
|
||||||
| "username"
|
|
||||||
| "nickname"
|
|
||||||
| "customstatus"
|
|
||||||
| "polls";
|
|
||||||
|
|
||||||
type YieldedContent = [MatchableTextType, string];
|
type YieldedContent = [MatchableTextType, string];
|
||||||
|
|
||||||
|
@ -69,6 +62,6 @@ export async function* matchMultipleTextTypesOnMessage(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trigger.match_polls && msg.data.poll) {
|
if (trigger.match_polls && msg.data.poll) {
|
||||||
yield ["polls", JSON.stringify(msg.data.poll)];
|
yield ["poll", JSON.stringify(msg.data.poll)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1326,6 +1326,10 @@ export function messageSummary(msg: SavedMessage) {
|
||||||
"\n";
|
"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.data.poll) {
|
||||||
|
result += "Poll: ```" + escapeCodeBlock(JSON.stringify(msg.data.poll)) + "```";
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue