Skip to content

Commit

Permalink
url: Say something on .title command failure
Browse files Browse the repository at this point in the history
Bit weird in its handling of failure when multiple URLs were passed in,
admittedly, but figuring out which URL failed would require a refactor.
  • Loading branch information
dgw committed Sep 17, 2018
1 parent 70438d1 commit 5868cc6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def title_command(bot, trigger):
for title, domain in results[:4]:
bot.reply('[ %s ] - %s' % (title, domain))

# Nice to have different failure messages for one-and-only requested URL
# failed vs. one-of-many failed.
if len(urls) == 1 and not results:
bot.reply('Sorry, fetching that title failed. Make sure the site is working.')
elif len(urls) > len(results):
bot.reply('I couldn\'t get all of the titles, but I fetched what I could!')


@rule('(?u).*(https?://\S+).*')
def title_auto(bot, trigger):
Expand Down

0 comments on commit 5868cc6

Please sign in to comment.