Skip to content

Commit

Permalink
FIX: Issue with discord webhooks because of empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
d-Rickyy-b committed Oct 6, 2019
1 parent 1786bf4 commit 7d9ee0d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pastepwn/actions/discordaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ def perform(self, paste, analyzer_name=None):
url = 'https://discordapp.com/api/channels/{0}/messages'.format(self.channel_id)
r.headers = {'Authorization': 'Bot {}'.format(self.token)}

res = json.loads(r.post(url, {"content": text}))
res = r.post(url, {"content": text})
if res == "":
# If the response is empty, skip further execution
return

if res.get('code') == 40001 and self.webhook is None and not self.identified:
res = json.loads(res)

if res.get('code') == 40001 and self.bot_available and self.webhook is None and not self.identified:

This comment has been minimized.

Copy link
@Zeroji

Zeroji Oct 9, 2019

Contributor

If self.bot_available is False and self.webhook is None, __init__ will fail to execute as you indicated in 1786bf4:
raise NotImplementedError

Therefore self.bot_availabe and self.webhook is None is redundant, however I don't know if your policy goes towards being as cautious as possible or writing conditions of minimal complexity. Just thought I'd point that out :)

This comment has been minimized.

Copy link
@d-Rickyy-b

d-Rickyy-b Oct 9, 2019

Author Owner

I was being extra cautious ^^ - might remove in a future commit.

# Unauthorized access, bot token hasn't been identified to Discord Gateway
self.logger.info('Accessing Discord Gateway to initialize token')
self.initialize_gateway()
Expand Down

0 comments on commit 7d9ee0d

Please sign in to comment.