diff --git a/PyBugReporter/_version.py b/PyBugReporter/_version.py index d706e92..11ffb38 100644 --- a/PyBugReporter/_version.py +++ b/PyBugReporter/_version.py @@ -1 +1 @@ -__version__ = '1.0.13' \ No newline at end of file +__version__ = '1.0.13b0.dev1' \ No newline at end of file diff --git a/PyBugReporter/src/BugReporter.py b/PyBugReporter/src/BugReporter.py index 2fa5391..206b359 100644 --- a/PyBugReporter/src/BugReporter.py +++ b/PyBugReporter/src/BugReporter.py @@ -264,7 +264,7 @@ async def _sendBugReport_async(self, repoName: str, errorTitle: str, errorMessag # Send to Discord if applicable if self.handlers[repoName].useDiscord: discordBot = DiscordBot(self.handlers[repoName].botToken, self.handlers[repoName].channelId) - await discordBot.send_message(shortErrorMessage, issueExists) + await discordBot.send_message(shortErrorMessage, issueExists, errorTitle) if (not issueExists): result = await client.execute_async(query=createIssue, variables=variables, headers=headers) @@ -481,7 +481,7 @@ async def manualBugReportAsync(cls, repoName: str, errorTitle: str, errorMessage # Send to Discord if applicable if cls.handlers[repoName].useDiscord: discordBot = DiscordBot(cls.handlers[repoName].botToken, cls.handlers[repoName].channelId) - await discordBot.send_message(f"## {repoName}: {errorTitle}\n{errorMessage}", issueExists) + await discordBot.send_message(f"## {repoName}: {errorTitle}\n{errorMessage}", issueExists, errorTitle) if (issueExists == False): result = await client.execute_async(query=createIssue, variables=variables, headers=headers) diff --git a/PyBugReporter/src/DiscordBot.py b/PyBugReporter/src/DiscordBot.py index f424f28..414c175 100644 --- a/PyBugReporter/src/DiscordBot.py +++ b/PyBugReporter/src/DiscordBot.py @@ -27,6 +27,7 @@ def __init__(self, token: str, channelId: str | int) -> None: self.channelId = int(channelId) self._message = None self._alreadySent = False + self._title = None self._doneFuture = None intents = discord.Intents(emojis = True, @@ -36,16 +37,18 @@ def __init__(self, token: str, channelId: str | int) -> None: guilds = True) super().__init__(intents=intents) - async def send_message(self, message, alreadySent = False): + async def send_message(self, message, alreadySent = False, title = None): """ Sends a message to the specified channel by setting the variables and starting the bot, then turning it off when finished. Args: message (str): The message to send. alreadySent (bool): Whether the message has already been sent. + title (str): The stable error title used to find the original message when reacting. """ self._message = message self._alreadySent = alreadySent + self._title = title self._doneFuture = asyncio.get_running_loop().create_future() print("Starting bot...") # Start the bot as a background task @@ -64,7 +67,7 @@ async def on_ready(self): print(f"Sent message to channel {self.channelId}") elif channel and self._alreadySent: async for message in channel.history(limit=HISTORY_LIMIT): - if message.content == self._message: + if self._title and self._title in message.content: await message.add_reaction(EMOJI) break else: