[core] Some minor fixes to make PEP8 happier

It kinda makes stuff more readable, unlike some other PEP8 warnings
[core] don't fire loop protection if last message was more than 5 minutes ago

Many people complained that loop protection was too strict, as it considered
same message repeated after several hours as "loop". This change makes loop
protection less strict by checking the last message time stamp. If last message
was sent more than 5 minutes ago, it won't treat the situation as a loop.

I also cleaned the loop protection code, and added more comments to explain this
slightly cryptic portion of our bot's core.