forked from swee/MeowNex
link parse
This commit is contained in:
parent
3dd7afc3b3
commit
d4b8322f35
1 changed files with 20 additions and 0 deletions
20
sweebot.py
20
sweebot.py
|
@ -10,6 +10,8 @@ from random import choice, randint as random
|
|||
import traceback
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from requests import get
|
||||
from bs4 import BeautifulSoup
|
||||
class config:
|
||||
def __init__(self):
|
||||
self.conn = sqlite3.connect(environ["SBconfig"])
|
||||
|
@ -564,6 +566,24 @@ while True:
|
|||
elif ":3c" in command:
|
||||
if not sbconfig.cflagexist(channel, "-colonthree"):
|
||||
multiline(choice(threes), channel)
|
||||
else:
|
||||
# try to parse and find a link
|
||||
if sbconfig.cflagexist(channel, "+links"):
|
||||
for i in command:
|
||||
if i[:7] == "https://":
|
||||
e = get(i)
|
||||
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)
|
||||
elif i[:6] == "http://":
|
||||
e = get(i)
|
||||
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)
|
||||
elif "JOIN" in text and "#nixsanctuary" in text:
|
||||
nick = text.split(":")[1].split("!")[0]
|
||||
if not "swee" in nick:
|
||||
|
|
Loading…
Reference in a new issue