Skip to content

Commit

Permalink
Fix info commands not working
Browse files Browse the repository at this point in the history
  • Loading branch information
noam09 committed Dec 1, 2017
1 parent c22bf69 commit bad72ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
__plugin_name__ = "Telegramer"
__author__ = "Noam"
__author_email__ = "[email protected]"
__version__ = "1.1.7.1"
__version__ = "1.1.7.2"
__url__ = "https://github.com/noam09"
__license__ = "GPLv3"
__description__ = "Control Deluge using Telegram"
Expand Down
31 changes: 19 additions & 12 deletions telegramer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,27 @@ def update(self):


def telegram_send(self, message, to=None, parse_mode=None):
if 1:#str(update.message.chat.id) in self.whitelist:
if 1: #str(update.message.chat.id) in self.whitelist:
if self.bot:
log.debug(prelog() + 'Send message')
if not to:
to = self.config['telegram_user']
else:
log.debug(prelog() + 'send_message, to set')
if not isinstance(to, (list,)):
log.debug(prelog() + 'Convert to to list')
to = [to]
log.debug(prelog() + "[to] " + str(to))
for usr in to:
log.debug(prelog() + "to: " + usr)
if parse_mode:
self.bot.send_message(usr, message,
parse_mode='Markdown')
else:
self.bot.send_message(usr, message)
# Every outgoing message filtered here
if str(usr) in self.whitelist or str(usr) in self.notifylist:
log.debug(prelog() + "to: " + str(usr))
if parse_mode:
msg = self.bot.send_message(usr, message,
parse_mode='Markdown')
else:
msg = self.bot.send_message(usr, message)
log.debug(prelog() + 'return')
return


Expand Down Expand Up @@ -342,39 +346,42 @@ def cancel(self, bot, update):


def cmd_help(self, bot, update):
log.debug(prelog() + "Entered cmd_help")
if str(update.message.chat.id) in self.whitelist:
log.debug(prelog() + str(update.message.chat.id) + " in whitelist")
help_msg = ['/add - Add a new torrent',
'/list - List all torrents',
'/down - List downloading torrents',
'/up - List uploading torrents',
'/paused - List paused torrents',
'/cancel - Cancels the current operation',
'/help - Show this help message']
self.telegram_send('\n'.join(help_msg), to=update.message.chat.id, parse_mode='Markdown')
log.debug(prelog() + "telegram_send to " + str([update.message.chat.id]))
self.telegram_send('\n'.join(help_msg), to=[update.message.chat.id], parse_mode='Markdown')


def cmd_list(self, bot, update):
if str(update.message.chat.id) in self.whitelist:
#log.error(self.list_torrents())
self.telegram_send(self.list_torrents(), to=update.message.chat.id, parse_mode='Markdown')
self.telegram_send(self.list_torrents(), to=[update.message.chat.id], parse_mode='Markdown')


def cmd_down(self, bot, update):
if str(update.message.chat.id) in self.whitelist:
self.telegram_send(self.list_torrents(lambda t: t.get_status(('state',))['state'] == 'Downloading'),
to=update.message.chat.id, parse_mode='Markdown')
to=[update.message.chat.id], parse_mode='Markdown')


def cmd_up(self, bot, update):
if str(update.message.chat.id) in self.whitelist:
self.telegram_send(self.list_torrents(lambda t: t.get_status(('state',))['state'] == 'Seeding'),
to=update.message.chat.id, parse_mode='Markdown')
to=[update.message.chat.id], parse_mode='Markdown')


def cmd_paused(self, bot, update):
if str(update.message.chat.id) in self.whitelist:
self.telegram_send(self.list_torrents(lambda t: t.get_status(('state',))['state'] in ('Paused', 'Queued')),
to=update.message.chat.id, parse_mode='Markdown')
to=[update.message.chat.id], parse_mode='Markdown')


def add(self, bot, update):
Expand Down

0 comments on commit bad72ae

Please sign in to comment.