Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from mart-w/testing
Browse files Browse the repository at this point in the history
Minor update v0.2.1
  • Loading branch information
mart-w authored Oct 17, 2017
2 parents 20db526 + c78742b commit 9146572
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ ParrotBot also uses the modules `asyncio`, `datetime`, `json`, `re`, and
installation. You also need a Discord bot user and its API token
(see https://discordapp.com/developers for further information on that).

If you have all that, just clone this repository and create a file called
`token.txt` in the repository’s root folder containing nothing but the API
token. Then you’re ready to go! Insert your bot’s client ID into this URL:
If you have all that, just clone this repository. Then you’re ready to go!
Insert your bot’s client ID into this URL:

https://discordapp.com/oauth2/authorize?client_id=YOUR_ID_HERE&scope=bot

Expand Down
21 changes: 14 additions & 7 deletions parrotbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,26 @@ async def quote_message(self, quote):
Try to find the quoted message and post an according embed message.
Try to find the quoted message by passing quote to
self.search_message_by_quote(). If a fitting message was found,
construct an according discord.Embed object and post it to the channel
the quote originates from, then delete the original quoting message if
allowed. If no fitting message was found, do nothing.
self.search_message_by_quote(). If a fitting message was found and the
bot is allowed to send messages in the channel, construct an according
discord.Embed object and post it to the channel the quote originates
from, then delete the original quoting message if allowed. If no fitting
message was found, don't do anything.
Parameters
----------
quote : discord.Message
Message that could contain a quote from another message.
"""
quoted_message = await self.search_message_by_quote(quote)
quoted_message = await self.search_message_by_quote(quote)#

if quoted_message:
# Find own member object on the server.
bot_member = quote.server.get_member(self.user.id)

# Check if the bot is allowed to send messages in that channel.
bot_may_send = quote.channel.permissions_for(bot_member).send_messages

if quoted_message and bot_may_send:
quote_embed = await self.create_quote_embed(
quote.author,
quoted_message
Expand Down Expand Up @@ -368,7 +375,7 @@ async def on_message(self, message):
# (Re)write configuration file if it didn't exist or missed keys.
if configfile_needs_update:
with open("config.json", "w") as configfile:
json.dump(config, configfile)
json.dump(config, configfile, indent=2)
print("Configuration file updated.")

# Initialise client object with the loaded configuration.
Expand Down

0 comments on commit 9146572

Please sign in to comment.