escape text in find scanner
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import discord
|
import discord
|
||||||
import re
|
|
||||||
|
|
||||||
# Custom libs
|
# Custom libs
|
||||||
|
|
||||||
@@ -13,6 +12,7 @@ from utils import (
|
|||||||
plural,
|
plural,
|
||||||
precise,
|
precise,
|
||||||
mention,
|
mention,
|
||||||
|
escape_text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +64,9 @@ class FindScanner(Scanner):
|
|||||||
res += [
|
res += [
|
||||||
self.matches[match].to_string(
|
self.matches[match].to_string(
|
||||||
matches.index(match),
|
matches.index(match),
|
||||||
f"`{match}`",
|
f'"{escape_text(match)}"'
|
||||||
|
if not match.startswith("<:")
|
||||||
|
else escape_text(match),
|
||||||
total_usage=self.msg_count,
|
total_usage=self.msg_count,
|
||||||
ranking=False,
|
ranking=False,
|
||||||
transform=lambda id: f" by {mention(id)}",
|
transform=lambda id: f" by {mention(id)}",
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,3 @@
|
|||||||
from calendar import month
|
|
||||||
from typing import Callable, List, Dict, Union, Optional, Any
|
from typing import Callable, List, Dict, Union, Optional, Any
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
@@ -81,6 +80,10 @@ def message_link(message: discord.Message) -> str:
|
|||||||
return f"https://discord.com/channels/{message.channel.guild.id}/{message.channel.id}/{message.id}"
|
return f"https://discord.com/channels/{message.channel.guild.id}/{message.channel.id}/{message.id}"
|
||||||
|
|
||||||
|
|
||||||
|
def escape_text(text: str) -> str:
|
||||||
|
return discord.utils.escape_markdown(discord.utils.escape_mentions(text))
|
||||||
|
|
||||||
|
|
||||||
class FakeMessage:
|
class FakeMessage:
|
||||||
def __init__(self, id: int):
|
def __init__(self, id: int):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|||||||
Reference in New Issue
Block a user