From 4975e2d3bcee0b683d252805ca4f456d6cb05fad Mon Sep 17 00:00:00 2001 From: swee Date: Wed, 8 Jan 2025 14:23:05 -0800 Subject: [PATCH] Update sweebridge.py --- sweebridge.py | 52 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/sweebridge.py b/sweebridge.py index d649c87..dfb6631 100644 --- a/sweebridge.py +++ b/sweebridge.py @@ -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: