Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21

Thread: Update faxbots?

  1. #11
    Senior Member
    Join Date
    Oct 2017
    Posts
    301

    Default

    Works every time for me. As stated above, it cannot work if you do not have a chat window open, either in KoLmafia or in the browser.
    Originally Posted by Veracity View Post
    In this case the bug is that it waits for 60 seconds and then timing out.
    Instead it should immediately print to the CLI an error message that says "chat window not open, you must enter chat to use faxbot feature"

  2. #12
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,415

    Default

    Tell me how we can detect if you have the chat window open in the Relay Browser.
    I'm all ears.

  3. #13
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    825

    Default

    Tell me how we can detect if you have the chat window open in the Relay Browser.
    I'm all ears.
    Originally Posted by Veracity View Post
    Could mafia issue some innocuous command like "/channels" and see is if it quickly gets a response? And, if not, assume the browser chat is closed and open the mafia chat?

    I don't know what all is possible with JAVA but with Javascript you could cycle through the frames and look for a location of "mchat.php" (and maybe those older chat scripts which I don't remember the names of anymore). Or maybe, just look for chatlaunch.php, and if found, assume it is closed.

    Not that I care...but it sounds like an interesting problem to solve!

  4. #14
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,415

    Default

    I was hoping for a solution based on KoLmafia's internal state which would not require a server hit.

    KoLmafia's ChatManager is open if you have the GUI Chat Frame open - or if the Relay Browser is open and chat requests/responses come from the browser. In both of those cases, we have a ChatPoller running to listen for asynchronous chat stuff coming from KoL.

    You can close the chat frame in the browser and, as I understand it, KoLmafia can't tell, since it's done via Javascript in the browser itself.

    Additionally, I believe (having not looked at the code in years), when you issue a Chat command in the GUI, it also opens the ChatManager if necessary, but doesn't start a ChatPoller. Some commands return right away and we get the results. Others essentially redirect into a different Request - things like "/eat" or "/equip".

    The ideal solution - which I couldn't figure out years ago when I added FaxBot support - would know exactly when we have a ChatPoller running to examine the chat responses coming asynchronously from KoL and detect when the FaxBot says "here it is" or "nopers".

    I am probably the only remaining "expert" on KoLmafia's chat support, since I am the one who integrated KoLmafia's chat support with mchat, many years ago, but since I don't chat, I haven't been motivated to keep that knowledge up to date - or to dive deep enough to fully come up with a solution for this particular issue.

    I will look at any proffered patches, but am unlikely to spend time working on it in my own time; simply making sure the chat window is open when I ask for a fax is good enough for my needs.

  5. #15

    Default

    Obviously you're much more familiar with this than I am but would it be possible to have a piece of JS running in the main window that watches the chatpane frame to see when it's title changes (or some other factor) and then hit something like "https://127.0.0.1:60080/KoLmafia/submitCommand?cmd=relay_chat open&pwd" (or "relay_chat closed" of course). I'd be happy to write it up if you think it sounds sensible.

  6. #16
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,813

    Default

    The regular requests to newchatmessages.php are not a good enough indicator?
    (assuming that "new" chat is the only chat good enough for our purposes)

  7. #17
    Senior Member
    Join Date
    Oct 2014
    Posts
    172

    Default

    Unless this stuff if going to open a chat window and handle your chats for you (which is not ideal as that can wipe PMs), I am not sure how this solves the issue. The 60 second timeout might be considered a "hack" but it works (it could be faster sure, but the faxbot itself can be delayed so you can't really do much about it), you ultimately still need a timeout.

    If Mafia could detect that the chat window was open and rejected the fax request until it was open, that breaks implementations that don't or can't open a chat window (they'll have to revert to visit_url and timers).

    I'm not going to say I wasn't initially frustrated the first time I encountered this and was like "why do I need chat open? why can't it do it for me?". But it makes sense and as currently implemented, it still makes the request regardless of chat opened status - this is the important part.

  8. #18
    Senior Member
    Join Date
    Oct 2017
    Posts
    301

    Default

    If I am not mistaken, should it not be possible to have mafia aware of that initial time where you manually click the button to enter chat in the first place (after all, something must be launching the current existing code)? If it is, then one could make deductions on the current status.

    A. If the player, after logging in to mafia, never clicked to enter chat, then chat has to be closed
    B. If the player, after opening a new relay window via the button on mafia that does that has not entered chat, then the chat has to be closed
    C. If the player has at some point in the past, during the current session, clicked on the button to enter chat, then the chat status is unknown, but likely to be open. unless the player closed the relay browser and is playing purely in mafia without a browser, or something else happened to log them out of chat but not mafia. Or the chat login failed after the button was clicked.

    Basically set bool to false on login, and to true on launching chat. If bool is on true, then chat status is unknown, but probably open. If bool is false, then chat is certain to be closed.
    Last edited by taltamir; 09-23-2018 at 01:25 AM.

  9. #19
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    4,146

    Default

    Whatever happens it will be tested with a character with access to a fax but had not visited the Altar of Literacy :-)

  10. #20
    Senior Member
    Join Date
    Oct 2014
    Posts
    172

    Default

    If I am not mistaken, should it not be possible to have mafia aware of that initial time where you manually click the button to enter chat in the first place (after all, something must be launching the current existing code)? If it is, then one could make deductions on the current status.

    A. If the player, after logging in to mafia, never clicked to enter chat, then chat has to be closed
    B. If the player, after opening a new relay window via the button on mafia that does that has not entered chat, then the chat has to be closed
    C. If the player has at some point in the past, during the current session, clicked on the button to enter chat, then the chat status is unknown, but likely to be open. unless the player closed the relay browser and is playing purely in mafia without a browser, or something else happened to log them out of chat but not mafia. Or the chat login failed after the button was clicked.

    Basically set bool to false on login, and to true on launching chat. If bool is on true, then chat status is unknown, but probably open. If bool is false, then chat is certain to be closed.
    Originally Posted by taltamir View Post
    I have accounts where I can guarantee that it will be false according to this paradigm and some of them run in places where I can't open chat (no GUI, headless). I'd really like if this doesn't break that things already work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •