Progether/IRC-Bot — pull request #38 by indivisible-irl (2013-11-22 07:47:57+00:00)
Title: Fixed command regex bug, added new debug options, improved settings handling

- fixed bug where regex would allow matches on repeating 'bot_command' prefixes

eg: if `bot_command = !`, then `regex.isCommand()` would return True in the case of `!testcmd` but also `!!!testcmd`

The undesired match would filter down to `split = regexCommandSplitCommand` which would fail and return None which would in turn raise an exception on `split.group()'

So I've tweaked the regex to only match on a single occurrence of the `bot_command` followed immediately by a non zero number of 'word characters' `\w === [A-Za-z0-9_]`

- added some dev settings

I've added two settings to the settings.py/settings.txt.

(Also renamed the `bot_command` variable to `command_prefix` as more descriptive)

`logAllToConsole` will toggle whether or not to print every received message from the server to the console. Use for development and debugging only. Should be set to `False` for any live/production/release bot.

`respondToNotFound` determines if the bot should reply to the user if they use a correct command call (eg `!!test`) but the requested command is not found/registered with the bot. Should also be disabled for live bots to help keep them "in the background" as much as possible. If multiple bots get deployed to the same channel it would cause a lot of spam from bots that don't implement a method that one does (assuming the `command_prefix` is the same)

- Tweaked settings.py and ConfigParser

Added new options and regrouped the settings more logically.

Settings lines can now take comments on the same line. Only the first "word" following the "=" is assigned to the setting `value = line.strip().split("=")[1].split()[0].strip()`

Improved error handling and logging of attempts to read/create settings.txt.
Bot will exit if fails to get settings from file or string.