From a0ef35297383190e0a82d9b536ec8099a3d34fe9 Mon Sep 17 00:00:00 2001 From: swee Date: Sun, 12 Jan 2025 20:16:22 -0800 Subject: [PATCH] Update sweebot.py --- sweebot.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/sweebot.py b/sweebot.py index 87cd017..cd6241a 100644 --- a/sweebot.py +++ b/sweebot.py @@ -16,6 +16,7 @@ from bs4 import BeautifulSoup from googleapiclient.discovery import build from characterai import pycai import uuid +import ssl CAItoken = environ["CAItoken"] CAImodel = environ["CAIchara"] try: @@ -846,6 +847,39 @@ while True: multiline("(" + nick + ") [Request error: " + str(ex.message) + "]", channel) except: print(traceback.format_exc()) + elif sbconfig.cflagexist(channel, "+links") or sbconfig.cflagexist(channel, "+gemini"): + try: + for i in command: + parse = urlparse(i) + if parse.scheme == "gemini": + gsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + gemsocket = ssl.wrap_socket(gsocket) + gemsocket.connect((parse.hostname, 1965)) + wrappedSocket.send(i + "\r\n") + received = "" + while True: + gemresponse = wrappedSocket.recv(2048) + if gemresponse: + received += gemresponse.decode() + else: + break + received = received.replace("\r", "") + firstline = True + title = False + for i in received.split("\n"): + if firstline: + if i.split(" ")[0][0] != "2" + multiline("(" + nick + f") [{i}]", channel) + break + else: + firstline = False + else: + elif i.split(" ")[0][0] == "#": + title = True + multiline("(" + nick + f") " + i[2:], channel) + break + if not title: + multiline("(" + nick + f") [No title found]", channel) elif "JOIN" in text and "#nixsanctuary" in text: nick = text.split(":")[1].split("!")[0] if not "Meow" in nick: