Bug - Fixed chatBot != chatbot

Grotfang

Developer
Is this an intentional change? The preference has been chatbotScript, not chatBotScript for as long as I've been using it.
 

fronobulax

Developer
Staff member
Is this an intentional change? The preference has been chatbotScript, not chatBotScript for as long as I've been using it.

Perhaps I read the code wrong, but what I saw was that the preference set by the rest of mafia code was chatBotScript, so I changed the one place the preference was read so that it read from chatBotScript as well. I chose my solution so that people who used mafia to set and read it got the expected result whereas before people who just used mafia got nothing. I confess I was not thinking of people who managed the preference outside of mafia.

I'm open to suggestions, but looking at the code, I believe that calling the preference chatbotScript was a programmer error.

If resolving this is more than a simple edit for a couple of people, let's discuss how to handle fix it.
 

Veracity

Developer
Staff member
I'm open to suggestions, but looking at the code, I believe that calling the preference chatbotScript was a programmer error
There were three places in the code which used the setting:

- defaults.txt - which defines the setting
- ChatManager.java - which looks up the setting to get the script name
- OptionsFrame.java - which provides the UI to change the setting

All three have to agree. Here is defaults.txt:

Code:
user	chatbotScript
user	chatbotScriptExecuted	false
Before your submit, defaults.txt defined the setting as "chatbotScript", ChatManager used that setting, but OptionsFrame let you manipulate a different setting - just as the OP reported. Which is to say, two of the three usages had "chatbotScript" and one had "chatBotScript".

Your submit changed ChatManager to agree with OptionsFrame so that now both of them disagree with the actual definition of the setting in defaults.txt. So, now two of the three usages use chatBotScript and one has chatbotScript.

I respectfully suggest that the "programmer error" was naming the setting chatBotScript, not the other way around, and the correct fix would have been to change OptionsFrame.java (as implied by the OP here) to agree with the setting defined in defaults.txt and used by ChatManager, rather than changing ChatManager to use the undefined setting that the typo in OptionsFrame uses.
 

Veracity

Developer
Staff member
And the punchline is that section 6.5 on KoLmafia Wiki - the "documentation" - says it is chatbotScript.

Chatbot (chatbotScript)

Will execute whenever a private message is received
Requires a special main declaration which can have an optional third parameter:
void main(string sender, string message)
void main(string sender, string message, string channel)
'sender' is the name of the player who sent the message
'message' is the message that was sent
'channel' is "/clan" for clan messages and the empty string for private messages
Revision 12349 makes it chatbotScript everywhere - so existing Chatbots will continue to execute without changing the setting name - rather than chatbotScript in 2 places and chatBotScript in 1 place (pre-12338), or vice versa (12338).
 

fronobulax

Developer
Staff member
Thank you. I did check defaults.txt which is why I drew the conclusion I did, but it appears that the core problem is my ability to distinguish between an "h" and an "H" on this monitor and these glasses.
 
Top