KoLMafia and PircBot?

OxyTheMoron

New member
Greetings,

I'm trying to marry PircBot and KoLMafia with somewhat mixed success. Our clan hangs out on IRC, and I'd like to be able to have PircBot respond to commands in the channel (such as !buff Ode, for example) and then react to the calling player, as well as respond with error messages if something goes wrong.

I have called .initialize() and .attemptLogin() on the KoLmafiaCLI object (the DEFAULT_SHELL field for the latter) and logged in as the buffbot and things are OK. I can successfully buff the user in the channel. I can also send items to the caller this way.

However, if the bot is low on MP, or the user specifies an invalid buff, etc... how do I use the KoLmafiaCLI class/object (or any other item in the codebase) to determine that something has gone wrong and report back?

I can share code files (be forewarned, they are ugly...) if needed.

Thanks!
Oxy
 

jasonharper

Developer
KoLmafia.permitsContinue() will tell you if the most recent command succeeded or failed.

Determining the cause of the failure is a bit more tricky, since there's no current mechanism for delivering status messages to anything other that mafia's own GUI components. Modifying KoLmafia.updateDisplay() would be the easy answer. If you'd prefer not to modify the source, try this: create a subclass of GenericPanel that overrides setStatusMessage(String), and create one instance of that class.
 

OxyTheMoron

New member
Thanks for your reply, jasonharper.

I'm leaning toward the former method myself. The only downside there is that I'd need to re-patch/rebuild whenever a new Mafia is released, but that shouldn't be a big deal.

For the latter method, do you mean GenericPanelFrame? And will that method work even if I'm using KoLmafiaCLI?

Thanks!
Oxy
 

jasonharper

Developer
No, GenericPanel - it's in swingui/panel, one level down from where you found GenericPanelFrame. GUI objects are allowed to exist, and all methods for getting/setting state are fully functional, even if no GUI is running.
 
Top