Skip to content

Commit c4a4db5

Browse files
committed
fix: stop rollie from responding once team member takes over
1 parent 52a6f4e commit c4a4db5

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/plugin-discord/src/messages.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,37 @@ export class MessageManager {
144144
const isDirectlyMentioned = this._isMessageForMe(message);
145145
const hasInterest = this._checkInterest(message.channelId);
146146

147+
// In ticket channels, check if a core team member has already responded
148+
// Core team members are identified by having "Core Team" in their server nickname
149+
if (isTicketChannel && !isDirectlyMentioned && 'messages' in message.channel) {
150+
try {
151+
// Fetch recent messages to see if core team has responded
152+
const recentMessages = await (message.channel as TextChannel).messages.fetch({ limit: 20 });
153+
const coreTeamHasResponded = recentMessages.some(msg => {
154+
if (msg.author.bot) return false; // Ignore bot messages
155+
156+
// Check server nickname (this is where "Core Team" appears in Discord)
157+
const nickname = msg.member?.nickname?.toLowerCase() || '';
158+
159+
// Also check username and global name as fallback
160+
const username = msg.author.username?.toLowerCase() || '';
161+
const globalName = msg.author.globalName?.toLowerCase() || '';
162+
163+
return nickname.includes('core team') ||
164+
username.includes('core team') ||
165+
globalName.includes('core team');
166+
});
167+
168+
if (coreTeamHasResponded) {
169+
console.log(`Core team member has responded in ticket ${channelName}, bot backing off`);
170+
return; // Don't respond if core team has taken over, unless directly mentioned
171+
}
172+
} catch (error) {
173+
console.error("Error checking for core team responses:", error);
174+
// Continue if there's an error checking messages
175+
}
176+
}
177+
147178
// Team handling
148179
if (
149180
this.runtime.character.clientConfig?.discord?.isPartOfTeam &&
@@ -398,8 +429,8 @@ If after providing troubleshooting steps, the user indicates:
398429
- They're frustrated or the issue is urgent (e.g., "this isn't working", "I've tried everything", "I need help ASAP")
399430
- The conversation has gone back and forth more than 3 times without resolution
400431
401-
**Then tag a support team member for assistance:**
402-
Include in your response: "<@779036923931000892> or <@384516597475180545> - this ticket may need additional assistance from the team."
432+
**Then tag support team members for assistance:**
433+
Include in your response: "<@779036923931000892> <@384516597475180545> - this ticket may need additional assistance from the team."
403434
404435
**IMPORTANT:**
405436
- Only escalate AFTER you've attempted to help with the standard troubleshooting steps

0 commit comments

Comments
 (0)