Update sweebridge.py
This commit is contained in:
parent
e8f6181dbc
commit
ade4a3a92b
1 changed files with 23 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
# 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
|
||||
# Modules for platforms
|
||||
import guilded, discord
|
||||
|
@ -212,9 +212,12 @@ def ircsession(platform:str, sock:bot_irc):
|
|||
time.sleep(2)
|
||||
sys.exit()
|
||||
elif "QUIT" in text:
|
||||
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"})
|
||||
update(channel_irc, sock)
|
||||
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 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)
|
||||
elif "JOIN" in text:
|
||||
channel_irc = text.split(" ")[2]
|
||||
target = targets[platform][channel_irc]
|
||||
|
@ -526,6 +529,22 @@ intents.members = True
|
|||
client2 = MyClient(intents=intents)
|
||||
guild = threading.Thread(target=client.run, args=[os.getenv("GuildedToken")], 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()
|
||||
guild.start()
|
||||
disc.start()
|
||||
|
|
Loading…
Reference in a new issue