Fix proxying with < prefix catching on emojis and channels
This commit is contained in:
parent
77402e0d58
commit
00fdcf32c2
@ -1,5 +1,6 @@
|
|||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -133,7 +134,6 @@ async def proxy_message(conn, member, trigger_message, inner):
|
|||||||
# Delete the original message
|
# Delete the original message
|
||||||
await client.delete_message(trigger_message)
|
await client.delete_message(trigger_message)
|
||||||
|
|
||||||
|
|
||||||
async def handle_proxying(conn, message):
|
async def handle_proxying(conn, message):
|
||||||
# Can't proxy in DMs, webhook creation will explode
|
# Can't proxy in DMs, webhook creation will explode
|
||||||
if message.channel.is_private:
|
if message.channel.is_private:
|
||||||
@ -148,7 +148,6 @@ async def handle_proxying(conn, message):
|
|||||||
bool(x["prefix"])) + int(bool(x["suffix"])), reverse=True)
|
bool(x["prefix"])) + int(bool(x["suffix"])), reverse=True)
|
||||||
|
|
||||||
msg = message.content
|
msg = message.content
|
||||||
msg_clean = message.clean_content
|
|
||||||
for member in members:
|
for member in members:
|
||||||
# If no proxy details are configured, skip
|
# If no proxy details are configured, skip
|
||||||
if not member["prefix"] and not member["suffix"]:
|
if not member["prefix"] and not member["suffix"]:
|
||||||
@ -158,9 +157,13 @@ async def handle_proxying(conn, message):
|
|||||||
prefix = member["prefix"] or ""
|
prefix = member["prefix"] or ""
|
||||||
suffix = member["suffix"] or ""
|
suffix = member["suffix"] or ""
|
||||||
|
|
||||||
|
# Avoid matching a prefix of "<" on a mention
|
||||||
|
if prefix == "<":
|
||||||
|
if re.match(r"^<(?:@|@!|#|@&|:\w+:|a:\w+:)\d+>", msg):
|
||||||
|
continue
|
||||||
|
|
||||||
# If we have a match, proxy the message
|
# If we have a match, proxy the message
|
||||||
# Match on the cleaned message to prevent a prefix of "<" catching on a mention
|
if msg.startswith(prefix) and msg.endswith(suffix):
|
||||||
if msg_clean.startswith(prefix) and msg_clean.endswith(suffix):
|
|
||||||
# Extract the actual message contents sans tags
|
# Extract the actual message contents sans tags
|
||||||
if suffix:
|
if suffix:
|
||||||
inner_message = msg[len(prefix):-len(suffix)].strip()
|
inner_message = msg[len(prefix):-len(suffix)].strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user