Wrapped the ###MAIN### block in a function that only runs if the file is called.

It's good practice to put "main" stuff in a function, and have that function be called conditionally depending on if the file is called or referenced. If you don't do this, and other files try to import functions from this one to use on their own (like `from bot import matches_regex`), that import will actually run the entire main block when they only wanted a copy of the function in bot.py.

See:
http://docs.python.org/2/library/__main__.html
http://effbot.org/pyfaq/tutor-what-is-if-name-main-for.htm
http://www.artima.com/weblogs/viewpost.jsp?thread=4829

The diff looks more messy than it is; except for a few lines, everything is just tabbed over once.