Class Dialogue

java.lang.Object
privbot.hooks.Dialogue

public final class Dialogue extends Object
Dialogue state inspection and interaction.

All detection is fully dynamic — no hardcoded widget group IDs. Every method uses an inspector-style traversal over client.getWidgetRoots(), scanning visible widgets by text, name, and actions. This works across OSRS, RSPS, and any RuneLite-based client regardless of widget layout differences.

Usage:


 if (ctx.dialogue.isOpen()) {
     if (ctx.dialogue.contains("Give me a task")) {
         ctx.dialogue.select("Give me a task");
     } else if (ctx.dialogue.canContinue()) {
         ctx.dialogue.clickContinue();
     }
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A dialogue read: the root widget id it came from, plus the stitched, normalised text.
  • Method Summary

    Modifier and Type
    Method
    Description
    The on-screen text group that most reads like a dialogue message, or null.
    boolean
    Returns true if any visible widget has a "Continue" action — the universal signal for a click-through dialogue.
    boolean
    Clicks the first visible widget with a "Continue" action.
    boolean
    Elorin's dialogue close action is Escape (the installed client API explicitly selects it).
    boolean
    Returns true if any visible widget's text, name, or actions contain the given string.
    Returns all visible option strings by finding widgets whose children contain multiple selectable text entries (the option/multi-choice pattern).
    Returns the text content from the first visible widget found by searching all widget roots for non-empty text that isn't a common UI label.
    boolean
     
    boolean
    Guard Continue while a native entry prompt owns the chatbox.
    boolean
    Returns true if a dialogue is open.
    boolean
    A choice surface, distinct from NPC speech with a Continue prompt.
    Whether a "Continue" surface is shown, or UNREADABLE when the read could not be made (canContinue() answers false for that).
    Whether an enter-amount / enter-text prompt owns the chatbox, or UNREADABLE when that cannot be read.
    Whether a dialogue is open, or UNREADABLE when the read could not be made.
    void
    Logs the on-screen dialogue if there is one, for callers that want the log WITHOUT asking a question about dialogue state.
    EVERY on-screen text group that reads like a dialogue message, best-scoring first.
    boolean
    select(String optionText)
    Selects a dialogue option by preferring an exact text match first, then falling back to case-insensitive contains matching.
    boolean
    Same as selectPacked(int) but resolves group.child[index]... paths when packed ids are ambiguous (e.g.
    boolean
    selectContains(String optionText)
    Selects a dialogue option by case-insensitive contains matching only.
    boolean
    selectExact(String optionText)
    Selects a dialogue option by exact normalized text match only.
    boolean
    selectOption(int oneBasedIndex)
    Selects a choice by its 1-based index: 1 is the first choice the menu offers.
    boolean
    selectPacked(int packedWidgetId)
    Activates a widget by inspector packed id (group << 16 | child).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • close

      public boolean close()
      Elorin's dialogue close action is Escape (the installed client API explicitly selects it). This sends a bounded press/release to the game's listener-bearing canvas; acceptance still requires the caller to observe the dialogue closing. Other profiles remain unsupported.
    • isEnterInputOpen

      public boolean isEnterInputOpen()
      Guard Continue while a native entry prompt owns the chatbox. The installed Elorin predicate is input mode 1 or 2, or messagePromptRaised (client-names cD/cG -> native yg/YK). The existing profile-backed amount reader exposes these facts without guessing fields. An unavailable read blocks Continue; regular API clients use the full input widget (162:42).
    • isOpen

      public boolean isOpen()
      Returns true if a dialogue is open. On RuneLite-API/RSPS clients (Orion etc.) the chatbox dialogue widget 162:559 is the authoritative signal. On Impact the widget table is FLAT (ids 0..60000, not group<<16|child), so the packed 162:559 lookup never resolves — so we fall back to the dynamic signals that work over the real widget tree: an NPC/message dialogue text line in a known group, or a visible "Continue" / "Click here to continue" widget found by tree-walk (findContinueWidget()). That walk uses client.getWidgetRoots(), which is populated on Impact, so DIALOG_OPEN (and conditions gated on it) now fire on Impact as on Orion.
    • isActualDialog

      public boolean isActualDialog()
      Returns:
      whether an NPC/player chat-head dialogue (groups 231/219) is visible; false when unreadable
    • contains

      public boolean contains(String text)
      Returns true if any visible widget's text, name, or actions contain the given string. Walks every widget root.
    • getText

      public String getText()
      Returns the text content from the first visible widget found by searching all widget roots for non-empty text that isn't a common UI label.

      Prefers widgets that also have a sibling/child with "Continue" nearby, as that's the strongest signal for dialogue text. Returns null if no dialogue text is found.

    • getOptions

      public List<String> getOptions()
      Returns all visible option strings by finding widgets whose children contain multiple selectable text entries (the option/multi-choice pattern). Scans all widget roots dynamically. Returns an empty list if no option dialog is detected.
    • isViewingOptions

      public boolean isViewingOptions()
      A choice surface, distinct from NPC speech with a Continue prompt.
    • canContinue

      public boolean canContinue()
      Returns true if any visible widget has a "Continue" action — the universal signal for a click-through dialogue. Scans all widget roots dynamically.
    • clickContinue

      public boolean clickContinue()
      Clicks the first visible widget with a "Continue" action. Returns true if a continue widget was found and clicked.
    • select

      public boolean select(String optionText)
      Selects a dialogue option by preferring an exact text match first, then falling back to case-insensitive contains matching. Returns true if the option was found and clicked.
    • selectExact

      public boolean selectExact(String optionText)
      Selects a dialogue option by exact normalized text match only. Returns true if the option was found and clicked.
    • selectContains

      public boolean selectContains(String optionText)
      Selects a dialogue option by case-insensitive contains matching only. Returns true if the option was found and clicked.
    • selectPacked

      public boolean selectPacked(int packedWidgetId)
      Activates a widget by inspector packed id (group << 16 | child). When the widget has a parent, uses the same MenuAction.WIDGET_CONTINUE shape as text option selection; otherwise invokes the first non-blank component action, or a bare continue on the widget.
    • selectByInspectorPath

      public boolean selectByInspectorPath(String path)
      Same as selectPacked(int) but resolves group.child[index]... paths when packed ids are ambiguous (e.g. 820.49[44] — see Widgets.getByInspectorPath(java.lang.String)).
    • selectOption

      public boolean selectOption(int oneBasedIndex)
      Selects a choice by its 1-based index: 1 is the first choice the menu offers. The menu's title line ("Select an Option", or a question such as "Select Gauntlet type:") is never counted, so selectOption(n) clicks getOptions().get(n - 1). Prefer select(String) when the option's text is known: the text does not move when a server reorders its menu. Returns true if the option was clicked.
    • pollDialogueLog

      public void pollDialogueLog()
      Logs the on-screen dialogue if there is one, for callers that want the log WITHOUT asking a question about dialogue state.

      Exists because the logger below is only reached from isOpen() and contains(String) — so despite reading as "always-on", it only ever fired when a plugin happened to poll dialogue. On a server where nothing polls it, it produced nothing at all. The event bridge calls this once per tick so the log is genuinely always-on.

    • bestProseGroup

      public Dialogue.DialogueText bestProseGroup()
      The on-screen text group that most reads like a dialogue message, or null.

      Public because the AntiBan handler needs the SAME read the logger prints — a bot check the log can see but the solver cannot is worse than useless. One implementation, two consumers.

    • proseGroups

      public List<Dialogue.DialogueText> proseGroups()
      EVERY on-screen text group that reads like a dialogue message, best-scoring first.

      Exists because "which group is best" is the wrong question for a consumer hunting for one SPECIFIC message. On Elorin a group's text stays readable after its interface closes (the same lie isHidden tells), so the login welcome at root 4900 stays a strong candidate for the rest of the session and can outscore the dialogue that is really on screen.

      A consumer looking for a particular message must therefore iterate this and test each candidate, not test only the winner.

    • observedOpen

      public Observed<Boolean> observedOpen()
      Whether a dialogue is open, or UNREADABLE when the read could not be made. isOpen() answers false for that (its read is dropped when the game thread does not answer in time).

      Where the client says which interface its chat area shows (Elorin), this answers from that outright; the other servers answer from the widget heuristics isOpen() uses. Neither answers "open" from chat history text (see contains(String)).

      Returns:
      TRUE / FALSE, or UNREADABLE
    • observedCanContinue

      public Observed<Boolean> observedCanContinue()
      Whether a "Continue" surface is shown, or UNREADABLE when the read could not be made (canContinue() answers false for that).
      Returns:
      TRUE / FALSE, or UNREADABLE
    • observedEnterInputOpen

      public Observed<Boolean> observedEnterInputOpen()
      Whether an enter-amount / enter-text prompt owns the chatbox, or UNREADABLE when that cannot be read. Keys typed while a prompt is open go into it; keys typed while none is open may go to public chat.
      Returns:
      TRUE / FALSE, or UNREADABLE