3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-11 20:52:42 +01:00

clientbot: warn when an outgoing message is blocked

Closes #497.
This commit is contained in:
James Lu 2017-09-02 21:46:09 -07:00
parent 0136ac9e41
commit 5112fcd7d1

View File

@ -1036,5 +1036,26 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
self.quit(source, args[0])
return {'text': args[0]}
def handle_404(self, source, command, args):
"""
Handles ERR_CANNOTSENDTOCHAN and other similar numerics.
"""
# <- :some.server 404 james #test :Cannot send to channel
if len(args) >= 2 and self.is_channel(args[1]):
channel = args[1]
f = log.warning
# Don't sent the warning multiple times to prevent flood if the target
# is a log chan.
if hasattr(self.channels[channel], '_clientbot_cannot_send_warned'):
f = log.debug
f('(%s) Failed to send message to %s: %s', self.name, channel, args[-1])
self.channels[channel]._clientbot_cannot_send_warned = True
# 408: ERR_NOCOLORSONCHAN on Bahamut, ERR_NOCTRLSONCHAN on Hybrid
handle_408 = handle_404
# 492: ERR_NOCTCP on Hybrid
handle_492 = handle_404
Class = ClientbotWrapperProtocol