Update sweebot.py

This commit is contained in:
Swee 2024-10-12 15:50:22 -07:00
parent 72b7bc1627
commit 13bf8db116

View file

@ -12,6 +12,10 @@ import threading
from pathlib import Path from pathlib import Path
from requests import get from requests import get
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
headers = {
'User-Agent': 'SweeBot IRC ' + __version__,
'From': 'bot@swee.codes'
}
class config: class config:
def __init__(self): def __init__(self):
self.conn = sqlite3.connect(environ["SBconfig"]) self.conn = sqlite3.connect(environ["SBconfig"])
@ -573,14 +577,14 @@ while True:
try: try:
for i in command: for i in command:
if i[:8] == "https://": if i[:8] == "https://":
e = get(i) e = get(i, headers=headers)
if e.ok: if e.ok:
soup = BeautifulSoup(e.text, 'html.parser') soup = BeautifulSoup(e.text, 'html.parser')
multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel) multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel)
else: else:
multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel) multiline("(" + nick + ") [HTTP " + str(e.status_code) + "]", channel)
elif i[:7] == "http://": elif i[:7] == "http://":
e = get(i) e = get(i, headers=headers)
if e.ok: if e.ok:
soup = BeautifulSoup(e.text, 'html.parser') soup = BeautifulSoup(e.text, 'html.parser')
multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel) multiline("(" + nick + ") " + soup.title.string if soup.title.string != None else "[No title provided]", channel)