@@ -205,6 +205,41 @@ def test_message_not_to_bot_discord(self, bot: Bot):
205205 is_to_bot , channel , text , entities = bot .is_msg_to_bot (msg )
206206 assert is_to_bot is False
207207
208+ def test_symphony_similar_bot_names_no_false_match (self , bot_with_symphony : Bot ):
209+ """Test that '@Cubist Bot' does not match when '@Cubist Bot Dev' is tagged in Symphony.
210+
211+ This ensures exact entity matching is used, preventing substring matches
212+ where a bot with a shorter name incorrectly receives messages meant for
213+ a bot with a longer, similar name.
214+ """
215+ # Bot is configured with name "Cubist Bot", but message tags "Cubist Bot Dev"
216+ msg = Message (
217+ user = "John Doe" ,
218+ user_id = "123456789" ,
219+ msg = '<div data-format="PresentationML"><span class="entity" data-entity-id="0">@Cubist Bot Dev</span> /help</div>' ,
220+ channel = "Test Room" ,
221+ tags = ["987654321" ],
222+ backend = "symphony" ,
223+ )
224+ is_to_bot , channel , text , entities = bot_with_symphony .is_msg_to_bot (msg )
225+ # Should NOT match because "@Cubist Bot" != "@Cubist Bot Dev"
226+ assert is_to_bot is False
227+
228+ def test_symphony_exact_bot_name_matches (self , bot_with_symphony : Bot ):
229+ """Test that exact bot name match works correctly in Symphony."""
230+ # Bot is configured with name "Cubist Bot", message also tags "Cubist Bot"
231+ msg = Message (
232+ user = "John Doe" ,
233+ user_id = "123456789" ,
234+ msg = '<div data-format="PresentationML"><span class="entity" data-entity-id="0">@Cubist Bot</span> /help</div>' ,
235+ channel = "Test Room" ,
236+ tags = ["987654321" ],
237+ backend = "symphony" ,
238+ )
239+ is_to_bot , channel , text , entities = bot_with_symphony .is_msg_to_bot (msg )
240+ # Should match because "@Cubist Bot" == "@Cubist Bot"
241+ assert is_to_bot is True
242+
208243
209244class TestBot :
210245 """Tests for Bot command extraction and execution."""
0 commit comments