Skip to content

Commit

Permalink
Resolves #37
Browse files Browse the repository at this point in the history
Bot replies will not trigger mentions.
  • Loading branch information
Silari authored and Silari committed Apr 12, 2021
1 parent b6232ca commit 7e1e3ab
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 47 deletions.
46 changes: 23 additions & 23 deletions basecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ async def handler(self, command, message):
# Ensure the mentioned channel is in this guild, or else we don't accept it.
if message.channel_mentions[0].guild != message.guild:
await message.reply("I could not find " + message.channel_mentions[0].name +
" in this server.")
" in this server.", mention_author=False)
return
# Set the mentioned channel as the announcement channel
channelid = message.channel_mentions[0].id
Expand All @@ -1399,7 +1399,7 @@ async def handler(self, command, message):
if not channel.permissions_for(channel.guild.me).send_messages:
msg += "\nI **do not** have permission to send messages in that channel! Announcements will fail " \
"until permission is granted. "
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
elif command[0] == 'stop':
# Stop announcing - we set an override option named Stop to true
Expand All @@ -1410,7 +1410,7 @@ async def handler(self, command, message):
# Set the override. Announce checks for this before announcing
mydata['COver'][message.guild.id]['Stop'] = True
msg = "Ok, I will stop announcing on this server."
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
elif command[0] == 'resume':
# Unset the Stop override - nothing else needed.
Expand All @@ -1423,7 +1423,7 @@ async def handler(self, command, message):
msg = "I will resume announcements to " + channel.mention + "."
else:
msg = "No announcement channel has been set, please set one with listen."
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
elif command[0] == 'option': # Moved to function
await self.option(command, message)
Expand Down Expand Up @@ -1451,20 +1451,20 @@ async def handler(self, command, message):
if len(command) == 1: # No stream given
msg += "\nYou must specify a stream name to show the detailed record for."
if msg:
await message.reply(msg)
await message.reply(msg, mention_author=False)
else:
try:
await self.detailannounce(command[1], message.guild.id)
except ChannelNotSet:
await message.reply(
"You must specify an announcement channel via the channel command before calling "
"detailannounce")
"detailannounce", mention_author=False)
return
else:
msg = "Unknown command: " + command[0] + ". Please follow the module name with a command, then with" \
" any parameters for the command. The available commands are: " + \
", ".join(self.commandlist.keys()) + "."
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
else: # No extra command given, or command was help. Unknown command is handled above now.
# This is your help area, which should give your users an idea how to use
Expand All @@ -1491,7 +1491,7 @@ async def handler(self, command, message):
msg += "\nThe adult options CAN NOT 100% shield your users from adult content. Forgetful " \
"streamers, API errors, bugs in the module, and old adult previews cached by the " \
"streaming site/discord/etc. may allow adult content through."
await message.reply(msg)
await message.reply(msg, mention_author=False)
# The general help goes here - it should list commands or some site that
# has a list of them
else:
Expand Down Expand Up @@ -1519,7 +1519,7 @@ async def handler(self, command, message):
msg += "\n**The last attempt to update the API failed!** The API may be down. This will cause " \
"certain commands to not work properly. Announcements will resume normally once the API " \
"is connectable."
await message.reply(msg)
await message.reply(msg, mention_author=False)
return

async def add(self, command, message):
Expand All @@ -1543,7 +1543,7 @@ async def add(self, command, message):
if message.channel_mentions: # Channel mention, so make an override
if message.channel_mentions[0].guild != message.guild:
await message.reply("I could not find " + message.channel_mentions[0].name +
" in this server.")
" in this server.", mention_author=False)
return
if 'COver' not in mydata: # We need to make the section
mydata['COver'] = {} # New dict
Expand Down Expand Up @@ -1628,7 +1628,7 @@ async def add(self, command, message):
channel = await self.resolvechannel(message.guild.id)
if not channel:
msg += "\nYou must set an announcement channel via the channel command before announcements will work!"
await message.reply(msg)
await message.reply(msg, mention_author=False)
return

async def list(self, command, message):
Expand Down Expand Up @@ -1686,7 +1686,7 @@ async def list(self, command, message):
msg += "\n**Last " + str(self.lastupdate.failed) + " attempt(s) to update API failed.**"
if await self.getoption(message.guild.id, 'Stop'):
msg += "\nMessages are currently stopped via the stop command."
await message.reply(msg)
await message.reply(msg, mention_author=False)

async def option(self, command, message):
"""Sets or clears one or more options for the server.
Expand All @@ -1696,7 +1696,7 @@ async def option(self, command, message):
"""
if len(command) == 1:
msg = "No option provided. Please use the help menu for info on how to use the option command."
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
msg = ""
setopt = set()
Expand Down Expand Up @@ -1727,7 +1727,7 @@ async def option(self, command, message):
msg += "Options set: " + ", ".join(setopt) + ". "
if unknown:
msg += "One or more unknown options found. Please check the help menu for available options."
await message.reply(msg)
await message.reply(msg, mention_author=False)

async def streamoption(self, command, message):
"""Sets or clears one or more options for a single watched stream in the server. If no options are given, it
Expand All @@ -1740,7 +1740,7 @@ async def streamoption(self, command, message):
if len(command) < 2:
msg = "Command requires a stream name, or a stream name and option(s). Please use the help menu " \
"for info on how to use the streamoption command. "
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
# If we're not listening to it right now, don't set the override.
# This avoids mismatched capitalization from the user setting the
Expand All @@ -1750,7 +1750,7 @@ async def streamoption(self, command, message):
and record in mydata["Servers"][message.guild.id]["Listens"]):
msg = record + "is not in your list of watched streams. Check spelling and capitalization and " \
"try again. "
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
if len(command) == 2: # No options given, just show current options
msg = "No overrides exist for the given stream; all options will default to the server wide settings."
Expand All @@ -1768,7 +1768,7 @@ async def streamoption(self, command, message):
msg = "The following overrides are set (Option: Setting) :\n" + msg
except KeyError:
pass
await message.reply(msg)
await message.reply(msg, mention_author=False)
return
msg = ""
setopt = set()
Expand Down Expand Up @@ -1814,7 +1814,7 @@ async def streamoption(self, command, message):
msg += "Options set: " + ", ".join(setopt) + ". "
if unknown:
msg += "One or more unknown options found. Please check the help menu for available options."
await message.reply(msg)
await message.reply(msg, mention_author=False)

async def remove(self, command, message):
"""Removes streams from the list of watched streams for a guild.
Expand All @@ -1825,11 +1825,11 @@ async def remove(self, command, message):
mydata = self.mydata
if not (message.guild.id in mydata["Servers"]):
# Haven't created servers info dict yet
await message.reply("No streams are being listened to yet!")
await message.reply("No streams are being listened to yet!", mention_author=False)
return
if not ("Listens" in mydata["Servers"][message.guild.id]):
# No listens added yet
await message.reply("No streams are being listened to yet!")
await message.reply("No streams are being listened to yet!", mention_author=False)
return
added = set()
msg = ""
Expand Down Expand Up @@ -1881,7 +1881,7 @@ async def remove(self, command, message):
msg += "\nThe following streams were not found and could not be removed: " + ", ".join(notfound)
if not msg:
msg += "Unable to remove any streams due to unknown error."
await message.reply(msg)
await message.reply(msg, mention_author=False)

async def announceall(self, command, message):
"""Gives announcements for any online streams missing them. Usually due to the bot being offline when the stream
Expand All @@ -1896,7 +1896,7 @@ async def announceall(self, command, message):
# Iterate over all this servers' listens
if not (message.guild.id in mydata["Servers"] and
"Listens" in mydata["Servers"][message.guild.id]):
await message.reply("Server is not listening to any streams!")
await message.reply("Server is not listening to any streams!", mention_author=False)
return
for item in mydata["Servers"][message.guild.id]["Listens"]: # Iterate over servers watched streams
if item in self.parsed: # Stream is online
Expand All @@ -1918,4 +1918,4 @@ async def announceall(self, command, message):
msg += "\n**The last attempt to update API failed.** The API may be down. This will cause delays " \
"in announcing streams. Streams will be announced/edited/removed as needed when the API " \
"call succeeds. "
await message.reply(msg)
await message.reply(msg, mention_author=False)

0 comments on commit 7e1e3ab

Please sign in to comment.