From 6d185593b351a9c229af10d8d35e413039a516a7 Mon Sep 17 00:00:00 2001 From: Matt Arnold Date: Tue, 22 Feb 2022 14:32:06 -0500 Subject: Add fun stuff to the sample, and error handling at protocol --- IRC.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'IRC.py') diff --git a/IRC.py b/IRC.py index a67e65d..90ef1fa 100644 --- a/IRC.py +++ b/IRC.py @@ -92,14 +92,17 @@ class IRCBot: self.send_cmd(usermsg) nickmsg = irctokens.build("NICK", [botnick]) self.send_cmd(nickmsg) + def get_response(self): # Get the response resp = self.irc.recv(4096).decode("UTF-8") msg = parsemsg(resp) nwmsg = irctokens.tokenise(resp) - + printred(nwmsg.command) if nwmsg.command == "001": self.on_welcome(nwmsg.params) + if nwmsg.command == "ERROR": + raise IRCError(str(nwmsg.params[0])) if nwmsg.command == 'PING': print('Sending pong') self.irc.send( -- cgit 1.4.1-2-gfad0