Update sweebridge.py
This commit is contained in:
parent
8686bfcafe
commit
4975e2d3bc
1 changed files with 28 additions and 24 deletions
|
@ -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.
|
# platform will be the value of the incoming platform, not any outgoing ones.
|
||||||
e = [text]
|
e = [text]
|
||||||
if platform == 1 and "discord" in config[target]: # Parse IRC -> Discord
|
if platform == 1 and "discord" in config[target]: # Parse IRC -> Discord
|
||||||
members = {}
|
try:
|
||||||
for i in client2.get_guild(config[target]["discord"]["guild"]).members:
|
members = {}
|
||||||
try:
|
for i in client2.get_guild(config[target]["discord"]["guild"]).members:
|
||||||
if not i.bot:
|
try:
|
||||||
members[i.display_name.lower()] = i.id
|
if not i.bot:
|
||||||
except:
|
members[i.display_name.lower()] = i.id
|
||||||
print(traceback.format_exc())
|
except:
|
||||||
parsed = text.split("d@") # Split by the prefix for discord mention (d@)
|
print(traceback.format_exc())
|
||||||
temp = []
|
parsed = text.split("d@") # Split by the prefix for discord mention (d@)
|
||||||
for i in parsed:
|
temp = []
|
||||||
j = i.split(" ")
|
for i in parsed:
|
||||||
print(j)
|
j = i.split(" ")
|
||||||
broken = False
|
print(j)
|
||||||
for k in range(0,len(j)+1):
|
broken = False
|
||||||
possibleUser = " ".join(j[:k]).lower()
|
for k in range(0,len(j)+1):
|
||||||
if possibleUser in members:
|
possibleUser = " ".join(j[:k]).lower()
|
||||||
temp.append("<@" + str(members[possibleUser]) + "> ")
|
if possibleUser in members:
|
||||||
temp.append(" ".join(j[k:]))
|
temp.append("<@" + str(members[possibleUser]) + "> ")
|
||||||
broken = True
|
temp.append(" ".join(j[k:]))
|
||||||
break
|
broken = True
|
||||||
if not broken:
|
break
|
||||||
temp.append(i) # Aknowledge the typo ;3
|
if not broken:
|
||||||
e.append("".join(temp))
|
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:
|
else:
|
||||||
e.append(text)
|
e.append(text)
|
||||||
if platform != 3 and "guilded" in config[target]: # Parse IRC -> Guilded:
|
if platform != 3 and "guilded" in config[target]: # Parse IRC -> Guilded:
|
||||||
|
@ -136,7 +140,7 @@ def ircsession(platform:str, sock:bot_irc):
|
||||||
try:
|
try:
|
||||||
if text != "":
|
if text != "":
|
||||||
print([text])
|
print([text])
|
||||||
content = ":".join(text.split(":")[2:])
|
content = ":".join(" ".join(text.split(" ")[1:]).split(":")[1:])
|
||||||
chan = text.split(" ")[2]
|
chan = text.split(" ")[2]
|
||||||
nick = text.split(" ")[0][1:].split("!")[0]
|
nick = text.split(" ")[0][1:].split("!")[0]
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue