Skip to content

Commit

Permalink
Merge pull request #30 from noam09/feature/docker-build
Browse files Browse the repository at this point in the history
Enable markdown for all messages, lint, add Dockerfile for builds
  • Loading branch information
noam09 authored Jan 7, 2022
2 parents f4f68e6 + dfa5d1d commit de9405c
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 102 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config2.glade
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:2.7.18-alpine3.11 AS base

RUN mkdir -p /usr/src/app
RUN mkdir -p /output
WORKDIR /usr/src/app

COPY telegramer /usr/src/app/telegramer
COPY setup.py /usr/src/app/setup.py
COPY LICENSE /usr/src/app/LICENSE

RUN python setup.py bdist_egg
8 changes: 8 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

docker build --no-cache -t telegramer.build . \
&& docker run -v $(pwd)/out:/tmp/out --rm -i telegramer.build sh -s << COMMANDS
python setup.py bdist_egg
chown -R $(id -u):$(id -g) dist
cp -ar dist/ /tmp/out/
COMMANDS
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.2.1.7"
__version__ = "1.3.1"
__url__ = "https://github.com/noam09"
__license__ = "GPLv3"
__description__ = "Control Deluge using Telegram"
Expand Down
14 changes: 3 additions & 11 deletions telegramer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,7 @@ def on_torrent_added(self, torrent_id):
message = "{}".format(user_message.replace("TORRENTNAME", torrent_status["name"]))
log.info(prelog() + 'Sending torrent added message to ' +
str(self.notifylist))
# Disable Markdown for custom messages
if custom_message:
return self.telegram_send(message, to=self.notifylist)
else:
return self.telegram_send(message, to=self.notifylist, parse_mode='Markdown')
return self.telegram_send('{}'.format(message), to=self.notifylist, parse_mode='Markdown')
except Exception as e:
log.error(prelog() + 'Error in alert %s' % str(e))

Expand Down Expand Up @@ -1101,12 +1097,8 @@ def on_torrent_finished(self, torrent_id):
message = "{}".format(user_message.replace("TORRENTNAME", torrent_status["name"]))
log.info(prelog() + 'Sending torrent finished message to ' +
str(self.notifylist))
# Disable Markdown for custom messages
if custom_message:
return self.telegram_send(message, to=self.notifylist)
else:
return self.telegram_send(message, to=self.notifylist, parse_mode='Markdown')
except Exception, e:
return self.telegram_send('{}'.format(message), to=self.notifylist, parse_mode='Markdown')
except Exception as e:
log.error(prelog() + 'Error in alert %s' %
str(e) + '\n' + traceback.format_exc())

Expand Down
Loading

0 comments on commit de9405c

Please sign in to comment.