@@ -126,6 +126,30 @@ func effortModeLabel(isBrainMode bool) string {
126126 return "normal"
127127}
128128
129+ // startsWithNonBotMention checks if the message text starts with a user mention that is not the bot
130+ func startsWithNonBotMention (text , botUserID string ) bool {
131+ if botUserID == "" {
132+ return false
133+ }
134+ text = strings .TrimSpace (text )
135+ if ! strings .HasPrefix (text , "<@" ) {
136+ return false
137+ }
138+ // Extract user ID from mention pattern <@USERID> or <@USERID|username>
139+ endIdx := strings .Index (text , ">" )
140+ if endIdx == - 1 {
141+ return false
142+ }
143+ mentionPart := text [2 :endIdx ] // Skip "<@"
144+ // Check if it has username part (format: USERID|username)
145+ pipeIdx := strings .Index (mentionPart , "|" )
146+ if pipeIdx != - 1 {
147+ mentionPart = mentionPart [:pipeIdx ]
148+ }
149+ // Check if this mention is NOT the bot
150+ return mentionPart != botUserID
151+ }
152+
129153// ProcessMessage processes a single Slack message
130154func (p * Processor ) ProcessMessage (
131155 ctx context.Context ,
@@ -147,6 +171,32 @@ func (p *Processor) ProcessMessage(
147171 "is_channel" , isChannel ,
148172 )
149173
174+ // Skip processing if in a thread and message starts with another user being mentioned
175+ if ev .ThreadTimeStamp != "" && startsWithNonBotMention (ev .Text , p .slackClient .BotUserID ()) {
176+ p .log .Info ("skipping message in thread that starts with non-bot mention" ,
177+ "channel" , ev .Channel ,
178+ "user" , ev .User ,
179+ "message_ts" , ev .TimeStamp ,
180+ "thread_ts" , ev .ThreadTimeStamp ,
181+ "text_preview" , TruncateString (ev .Text , 100 ),
182+ )
183+ MessagesIgnoredTotal .WithLabelValues ("thread_non_bot_mention" ).Inc ()
184+ return
185+ }
186+
187+ // Skip processing if message contains :mute: emoji
188+ if strings .Contains (ev .Text , ":mute:" ) {
189+ p .log .Info ("skipping message with :mute: emoji" ,
190+ "channel" , ev .Channel ,
191+ "user" , ev .User ,
192+ "message_ts" , ev .TimeStamp ,
193+ "thread_ts" , ev .ThreadTimeStamp ,
194+ "text_preview" , TruncateString (ev .Text , 100 ),
195+ )
196+ MessagesIgnoredTotal .WithLabelValues ("mute_emoji" ).Inc ()
197+ return
198+ }
199+
150200 txt := strings .TrimSpace (ev .Text )
151201
152202 // Remove bot mention from text for cleaner processing
0 commit comments