Skip to content

Commit

Permalink
Merge pull request #41 from toshka/master
Browse files Browse the repository at this point in the history
Single message for /list command [RUS]
  • Loading branch information
idlesign committed Apr 5, 2019
2 parents 9a1f88e + d06817d commit d3aae34
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions torrt/bots/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,16 @@ def command_add_torrent(self, bot, update):

def command_list_torrents(self, bot, update):
"""Command to list all monitored torrents"""
torrents = []
for i, trnt in enumerate(get_registered_torrents().values(), 1):
if trnt.get('url'):
update.message.reply_text('{}. {} \n{}'.format(i, trnt['name'], trnt['url']))
torrents.append('{}. {}\n{}'.format(i, trnt['name'], trnt['url']))
else:
update.message.reply_text('{}. {}'.format(i, trnt['name']))
torrents.append('{}. {}'.format(i, trnt['name']))
if torrents:
update.message.reply_text('\n\n'.join(torrents))
else:
update.message.reply_text('No torrents yet.')

def command_remove_torrents(self, bot, update):
"""Command to remove torrent"""
Expand Down

0 comments on commit d3aae34

Please sign in to comment.