From e23c9d31af5aa3d2572c0ff8caa97ab059e66fbf Mon Sep 17 00:00:00 2001 From: Swee Date: Sat, 12 Oct 2024 16:11:43 -0700 Subject: [PATCH] Update sweebot.py --- sweebot.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sweebot.py b/sweebot.py index c2ea37d..e1809b4 100644 --- a/sweebot.py +++ b/sweebot.py @@ -10,7 +10,7 @@ from random import choice, randint as random import traceback import threading from pathlib import Path -from requests import get +from requests import get, exceptions as rex from bs4 import BeautifulSoup headers = { 'User-Agent': 'SweeBot IRC ' + __version__ @@ -576,12 +576,15 @@ while True: try: for i in command: if i[:8] == "https://": - e = get(i, headers=headers, timeout=10) - if e.ok: - soup = BeautifulSoup(e.text, 'html.parser') - multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel) - else: - multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel) + try: + e = get(i, headers=headers, timeout=10) + if e.ok: + soup = BeautifulSoup(e.text, 'html.parser') + multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel) + else: + multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel) + except rex.SSLError as ex: + multiline("(" + nick + ") [SSL Error: " + str(ex.__cause__) + "]", channel) elif i[:7] == "http://": e = get(i, headers=headers, timeout=10) if e.ok: