Update sweebridge.py

This commit is contained in:
Nova Cat 2025-01-08 14:23:05 -08:00
parent 8686bfcafe
commit 4975e2d3bc

View file

@ -86,29 +86,33 @@ def parse_content(text:str, platform:int, target:str):
# platform will be the value of the incoming platform, not any outgoing ones.
e = [text]
if platform == 1 and "discord" in config[target]: # Parse IRC -> Discord
members = {}
for i in client2.get_guild(config[target]["discord"]["guild"]).members:
try:
if not i.bot:
members[i.display_name.lower()] = i.id
except:
print(traceback.format_exc())
parsed = text.split("d@") # Split by the prefix for discord mention (d@)
temp = []
for i in parsed:
j = i.split(" ")
print(j)
broken = False
for k in range(0,len(j)+1):
possibleUser = " ".join(j[:k]).lower()
if possibleUser in members:
temp.append("<@" + str(members[possibleUser]) + "> ")
temp.append(" ".join(j[k:]))
broken = True
break
if not broken:
temp.append(i) # Aknowledge the typo ;3
e.append("".join(temp))
try:
members = {}
for i in client2.get_guild(config[target]["discord"]["guild"]).members:
try:
if not i.bot:
members[i.display_name.lower()] = i.id
except:
print(traceback.format_exc())
parsed = text.split("d@") # Split by the prefix for discord mention (d@)
temp = []
for i in parsed:
j = i.split(" ")
print(j)
broken = False
for k in range(0,len(j)+1):
possibleUser = " ".join(j[:k]).lower()
if possibleUser in members:
temp.append("<@" + str(members[possibleUser]) + "> ")
temp.append(" ".join(j[k:]))
broken = True
break
if not broken:
temp.append(i) # Aknowledge the typo ;3
e.append("".join(temp))
except:
# Just append the text, don't interrupt the parse.
e.append(text)
else:
e.append(text)
if platform != 3 and "guilded" in config[target]: # Parse IRC -> Guilded:
@ -136,7 +140,7 @@ def ircsession(platform:str, sock:bot_irc):
try:
if text != "":
print([text])
content = ":".join(text.split(":")[2:])
content = ":".join(" ".join(text.split(" ")[1:]).split(":")[1:])
chan = text.split(" ")[2]
nick = text.split(" ")[0][1:].split("!")[0]
except: