Skip to content
Merged

Dev #84

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PyBugReporter/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.13'
__version__ = '1.0.13b0.dev1'
4 changes: 2 additions & 2 deletions PyBugReporter/src/BugReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions PyBugReporter/src/DiscordBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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:
Expand Down
Loading