mobile/mention to fix @invalid-user bug

This commit is contained in:
Klemek
2021-04-21 11:26:37 +02:00
parent 76af4661ed
commit 3100e6fa20
4 changed files with 17 additions and 4 deletions
+3
View File
@@ -58,6 +58,7 @@
* all/everyone - include bots messages * all/everyone - include bots messages
* fast: only read cache * fast: only read cache
* fresh: does not read cache * fresh: does not read cache
* mobile/mention: mentions users (fix @invalid-user bug)
(Sample dates: 2020 / 2021-11 / 2021-06-28 / 2020-06-28T23:00 / today / week / 8days / 1y) (Sample dates: 2020 / 2021-11 / 2021-06-28 / 2020-06-28T23:00 / today / week / 8days / 1y)
``` ```
@@ -109,6 +110,8 @@ python3 src/main.py
## Changelog ## Changelog
* **v1.14**
* `mobile/mention` arg to fix mobile bug
* **v1.13** * **v1.13**
* improved scan `%words` * improved scan `%words`
* remove old and unused logs at start and guild leaving * remove old and unused logs at start and guild leaving
+1 -1
View File
@@ -33,7 +33,7 @@ emojis.load_emojis()
bot = Bot( bot = Bot(
"Discord Analyst", "Discord Analyst",
"1.13", "1.14",
alias="%", alias="%",
) )
+12 -3
View File
@@ -79,7 +79,9 @@ class Scanner(ABC):
) )
return return
if ( if (
arg not in self.valid_args + ["me", "here", "fast", "fresh"] arg
not in self.valid_args
+ ["me", "here", "fast", "fresh", "mobile", "mention"]
and (not arg.isdigit() or not self.has_digit_args) and (not arg.isdigit() or not self.has_digit_args)
and arg not in str_channel_mentions and arg not in str_channel_mentions
and arg not in str_mentions and arg not in str_mentions
@@ -119,6 +121,8 @@ class Scanner(ABC):
self.members += [message.author] self.members += [message.author]
self.raw_members += [message.author.id] self.raw_members += [message.author.id]
self.mention_users = "mention" in args or "mobile" in args
if not await self.init(message, *args): if not await self.init(message, *args):
return return
@@ -214,13 +218,18 @@ class Scanner(ABC):
logging.info(f"scan {guild.id} > results in {delta(t0):,}ms") logging.info(f"scan {guild.id} > results in {delta(t0):,}ms")
response = "" response = ""
first = True first = True
allowed_mentions = (
discord.AllowedMentions.all()
if self.mention_users
else discord.AllowedMentions.none()
)
for r in results: for r in results:
if r: if r:
if len(response + "\n" + r) > 2000: if len(response + "\n" + r) > 2000:
await message.channel.send( await message.channel.send(
response, response,
reference=message if first else None, reference=message if first else None,
allowed_mentions=discord.AllowedMentions.none(), allowed_mentions=allowed_mentions,
) )
first = False first = False
response = "" response = ""
@@ -229,7 +238,7 @@ class Scanner(ABC):
await message.channel.send( await message.channel.send(
response, response,
reference=message if first else None, reference=message if first else None,
allowed_mentions=discord.AllowedMentions.none(), allowed_mentions=allowed_mentions,
) )
# Delete custom progress message # Delete custom progress message
await progress.delete() await progress.delete()
+1
View File
@@ -18,6 +18,7 @@ COMMON_HELP_ARGS = [
"<date2> - filter before <date2>", "<date2> - filter before <date2>",
"fast - only read cache", "fast - only read cache",
"fresh - does not read cache (long)", "fresh - does not read cache (long)",
"mobile/mention - mentions users (fix @invalid-user bug)",
] ]