Hive13 / jIRCBot

The Hive13 Chat Bot

Home Page:http://wiki.hive13.org/Hive13_IRC_Bot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

command responses are messed up

cjdavis opened this issue · comments

Seems to give an error and then correctly respond - ex is this after I did a '!tell hodapp foo' in channel:

(2011-04-30 15:07:54) Hive13Bot: Unknown command: tell hodapp the dell on the table has the 4 channel video cap card, try !help.
(2011-04-30 15:07:55) Hive13Bot: I will tell hodapp the next time they talks in channel.
(2011-04-30 15:09:34) cjdavis: !help
(2011-04-30 15:09:35) Hive13Bot: This command stores a message for a user. The next time that user sends a message in the chat room I will send them the messages stored for them. Ex. !tell jimboJones Remember to bring that thing with you.
(2011-04-30 15:09:36) Hive13Bot: This command does not support this functionality.
(2011-04-30 15:09:37) Hive13Bot: To get a list of available commands use '!plugins'. To learn more about a command type '!plugins help'.

Yikes, that is a seriously f'ed up response. This is probably a multi-part issue due to the way different command types are handled.

There are 3 major ways commands are run:

  1. As a completely separate thread that can be stopped & started
  2. In response to direct commands issued in the channel, aka "!time"
  3. Parsing every single line of text that passes through the channel, the "Linkify" command that searches for links and shortens them is a good example of this.

The "!Tell" command is a bit of an oddity because it fits two different categories, the "!tell hodapp It is always your fault" would clearly fit in #2, however in order to actually tell hodapp that message, the bot needs to encounter hodapp talking which requires the command check every message like #3.

Rather than split the command into two separate functions I put both functions into a #3 type command. The issue that arises is that this hackish implementation results in some hackish behavior that I have not found a fix for.

In this case we are getting several problematic responses:

  1. The bot checks its list of known "action" commands for !tell and does not find it, so it says, "Hey, there is no !tell" command.
  2. We then fall down to the line parse commands and we hit the "tell" command there and it correctly responds to the command.

!help has a similar problem, I implemented !help to just tell you to try !plugins for more information, however due to the way I have initially implemented standard plugins and getHelp(), this is a more complex issue.

Lets say you type "!H1List help". The bot checks its list of "direct" commands and finds the "H!List" command, it then calls that objects "onMessage" function w/ the parameter string "help". The parent "onMessage" function realizes that "help" is a standard parameter and directly calls "getHelp()".

The problem arrises w/ "tell" again because it is hackishly implemented. It's "onMessage" function is called w/ the entire contents of the message line rather than just the "parameter part" This means when a user types "!help" in the chat room, the bot uses the "!" to decide it is a command and trims it off, triggers the bot's standard "help" message, it falls through to the "always run line parse" commands which gets sent to the "Tell" commands "onMessage" function as just "help" instead of the expected (for it) "tell help".

The solution here is for me to re-write how "tell" works to be either 2 classes, a "user interface" where you can add tell messages, and a "monitor" that strictly watches all line messages. That should resolve both issues.

wew that was long and circuitous.