This commit is contained in:
parent
697a6d67fb
commit
a0ef352973
1 changed files with 34 additions and 0 deletions
34
sweebot.py
34
sweebot.py
|
@ -16,6 +16,7 @@ from bs4 import BeautifulSoup
|
||||||
from googleapiclient.discovery import build
|
from googleapiclient.discovery import build
|
||||||
from characterai import pycai
|
from characterai import pycai
|
||||||
import uuid
|
import uuid
|
||||||
|
import ssl
|
||||||
CAItoken = environ["CAItoken"]
|
CAItoken = environ["CAItoken"]
|
||||||
CAImodel = environ["CAIchara"]
|
CAImodel = environ["CAIchara"]
|
||||||
try:
|
try:
|
||||||
|
@ -846,6 +847,39 @@ while True:
|
||||||
multiline("(" + nick + ") [Request error: " + str(ex.message) + "]", channel)
|
multiline("(" + nick + ") [Request error: " + str(ex.message) + "]", channel)
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
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:
|
elif "JOIN" in text and "#nixsanctuary" in text:
|
||||||
nick = text.split(":")[1].split("!")[0]
|
nick = text.split(":")[1].split("!")[0]
|
||||||
if not "Meow" in nick:
|
if not "Meow" in nick:
|
||||||
|
|
Loading…
Add table
Reference in a new issue