Core/connection: First attempt at a proper threaded, prioritised queue for connection.write().

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 74fb1b701e8b7d6e8246c4cab4b1c826758d36ac)
(cherry picked from commit e07ba7ca684f8745a0d010b0709ed40531de5cca)
Core/actions: Calculate and use priority based on user status, message length and a custom modifier,

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 26bbea43dabe7f646b8d035dc9cfb7f5e3ef1a5a)
(cherry picked from commit 99efa18775dee46140a255b8d805b00b8e439176)
Core/actions: Add priorities to privmsg, notice, reply, alert, invite and kick

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 65e8c3062d53d05d3838175508f6cc082d422943)
(cherry picked from commit d175299d89b26e51409617cad784495884f05971)
Core/actions: Catch errors in get_pnick during connection.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 8bbccfb99e7ddd2d418801740ef52b7adb6c9b0d)
(cherry picked from commit eb8f6f10a2653e1a3edf34eb17e0514515b50bee)
Core/connection: Clean up thread on disconnect.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit e30bb5c6523b5b95944bba4b8a108ac0107ab994)
(cherry picked from commit ce0163ff44f9a75db6d8c08d12654520b50db149)
Core/connection: Increase the antiflood period for low priority messages.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 2755f11ddf705f39fc7785b0ef0ceeed6d64dfce)
(cherry picked from commit 6c7a0337bc390aadbc2429c3086ffb902eb8ee15)
Core/admintools: New module for adminmsg() function. Broadcasts a message to all (online) admins listed in merlin.cfg.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 08ff412484ad5e9506552c80d6b734a63cf3d2d2)
(cherry picked from commit 0a3118ec7a6745856fede78c780216cb033f4206)
Core/connection: Warn admins on excessive message queue length/delay.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit a4f00b1a839cf19eee3b00dc9291ffc322c29f74)
(cherry picked from commit 2239e7799573e4789541aa010ebe07873c4222f6)
Core/connection: Move warning parameters to merlin.cfg.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit d2d45ae474c5869aa530fd75d4ee3cb1f59211de)
(cherry picked from commit 3e4d5fedf662a43e9a35bfd65152fee1ad30aa39)
Core/admintools: Move imports into the function declaration to enable use in Core/connection.py

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 98367ed7dbef5c981fe6268c389a9a5465a21f60)
(cherry picked from commit e0aed27810264622fef8dafb8381a8dd17833ac5)
Core/actions: Change priority to use is_admin() function.

Signed-off-by: Martin Stone <martin@d7415.co.uk>
(cherry picked from commit 6df5b7f07c58098f9fec2d105b196131506c9ab1)