1
0
Fork 0
forked from swee/MeowNex

Update sweebot.py

This commit is contained in:
Swee 2024-10-12 16:11:43 -07:00
parent ec633a07a3
commit e23c9d31af

View file

@ -10,7 +10,7 @@ from random import choice, randint as random
import traceback import traceback
import threading import threading
from pathlib import Path from pathlib import Path
from requests import get from requests import get, exceptions as rex
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
headers = { headers = {
'User-Agent': 'SweeBot IRC ' + __version__ 'User-Agent': 'SweeBot IRC ' + __version__
@ -576,12 +576,15 @@ while True:
try: try:
for i in command: for i in command:
if i[:8] == "https://": if i[:8] == "https://":
e = get(i, headers=headers, timeout=10) try:
if e.ok: e = get(i, headers=headers, timeout=10)
soup = BeautifulSoup(e.text, 'html.parser') if e.ok:
multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel) soup = BeautifulSoup(e.text, 'html.parser')
else: multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel)
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", 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://": elif i[:7] == "http://":
e = get(i, headers=headers, timeout=10) e = get(i, headers=headers, timeout=10)
if e.ok: if e.ok: