fix(behaviors): prevent rabbit hole from activating on non-feed screens and add tap post username context gate
This commit is contained in:
@@ -34,6 +34,16 @@ class RabbitHolePlugin(BehaviorPlugin):
|
||||
if res_score < 0.8:
|
||||
return False
|
||||
|
||||
screen_type = ctx.shared_state.get("current_screen_type")
|
||||
if not screen_type and ctx.context_xml:
|
||||
from GramAddict.core.perception.screen_identity import ScreenIdentity
|
||||
screen_type = ScreenIdentity(getattr(ctx, "username", "")).identify(ctx.context_xml).get("screen_type")
|
||||
|
||||
from GramAddict.core.perception.screen_identity import ScreenType
|
||||
valid_screens = [ScreenType.HOME_FEED, ScreenType.EXPLORE_GRID, ScreenType.REELS_FEED]
|
||||
if screen_type not in valid_screens:
|
||||
return False
|
||||
|
||||
config = self.get_config(ctx)
|
||||
percentage = float(config.get("percentage", 15))
|
||||
return random.random() < (percentage / 100.0)
|
||||
|
||||
@@ -67,6 +67,14 @@ ALLOWED_SCREENS: Dict[str, FrozenSet[ScreenType]] = {
|
||||
ScreenType.STORY_VIEW, # toolbar_reshare_button exists on stories
|
||||
}
|
||||
),
|
||||
"tap post username": frozenset(
|
||||
{
|
||||
ScreenType.HOME_FEED,
|
||||
ScreenType.POST_DETAIL,
|
||||
ScreenType.REELS_FEED,
|
||||
ScreenType.EXPLORE_GRID,
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
# Intent keywords that trigger the categorical ban check
|
||||
|
||||
Reference in New Issue
Block a user