Update sweebridge.py

This commit is contained in:
Nova Cat 2025-01-01 16:58:53 -08:00
parent e8f6181dbc
commit ade4a3a92b

View file

@ -1,5 +1,5 @@
# Modules for the system, these should be pre-installed with Python. # Modules for the system, these should be pre-installed with Python.
import json, os, sys, traceback, time, threading, requests, socket, subprocess import json, os, sys, traceback, time, threading, requests, socket, subprocess, nio, asyncio
from sys import argv from sys import argv
# Modules for platforms # Modules for platforms
import guilded, discord import guilded, discord
@ -212,6 +212,9 @@ def ircsession(platform:str, sock:bot_irc):
time.sleep(2) time.sleep(2)
sys.exit() sys.exit()
elif "QUIT" in text: elif "QUIT" in text:
for key, value in userlist.items():
if nick in value:
target = targets[platform][key]
if guilded_enable: hook(gilwebhook, json={"content": nick + " Has quit for reason \"" + " ".join(text.split(" ")[2:])[1:] + "\"", "username": "SweeBridge IRC", "avatar_url": "https://git.swee.codes/swee/SweeBridge/raw/branch/main/logos/sweebridge-" + platform + ".png"}) if guilded_enable: hook(gilwebhook, json={"content": nick + " Has quit for reason \"" + " ".join(text.split(" ")[2:])[1:] + "\"", "username": "SweeBridge IRC", "avatar_url": "https://git.swee.codes/swee/SweeBridge/raw/branch/main/logos/sweebridge-" + platform + ".png"})
if discord_enable: hook(discwebhook, json={"content": nick + " Has quit for reason \"" + " ".join(text.split(" ")[2:])[1:] + "\"", "username": "SweeBridge IRC", "avatar_url": "https://git.swee.codes/swee/SweeBridge/raw/branch/main/logos/sweebridge-" + platform + ".png"}) if discord_enable: hook(discwebhook, json={"content": nick + " Has quit for reason \"" + " ".join(text.split(" ")[2:])[1:] + "\"", "username": "SweeBridge IRC", "avatar_url": "https://git.swee.codes/swee/SweeBridge/raw/branch/main/logos/sweebridge-" + platform + ".png"})
update(channel_irc, sock) update(channel_irc, sock)
@ -526,6 +529,22 @@ intents.members = True
client2 = MyClient(intents=intents) client2 = MyClient(intents=intents)
guild = threading.Thread(target=client.run, args=[os.getenv("GuildedToken")], daemon=True) guild = threading.Thread(target=client.run, args=[os.getenv("GuildedToken")], daemon=True)
disc = threading.Thread(target=client2.run, args=[os.getenv("DiscordToken")], daemon=True) disc = threading.Thread(target=client2.run, args=[os.getenv("DiscordToken")], daemon=True)
async def matrixSession():
Mtrix = nio.AsyncClient(os.getenv("MatrixHomeserver"), os.getenv("MatrixUsername"))
Mtrix.access_token = os.getenv("MatrixToken")
Mtrix.user_id = os.getenv("MatrixUsername")
while True:
try:
await Mtrix.load_store()
sync = await Mtrix.sync(30000)
finally:
Mtrix.close()
def runMatrix()
asyncio.run(matrixSession())
matrix = threading.Thread(target=runMatrix)
matrix.start()
irc1.start() irc1.start()
guild.start() guild.start()
disc.start() disc.start()