Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
v0.1.6 (fixed twitchy email notifications)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihilok committed Mar 2, 2021
1 parent af203fb commit 7efad8d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ https://codereview.stackexchange.com/questions/254272/dynamic-dns-ip-checker-cha
- Consistent exit codes
- Clear logs after 100 lines (keep the last 10 lines)
- Try/except for permissions (instead of if/else)
- Other bugfixes/refactoring
- Other bugfixes/refactoring

0.1.6 (02/03/2020)
------------------
- Fixed twitchy email notification bug
Binary file removed dist/domains-api-0.1.5.2.tar.gz
Binary file not shown.
Binary file added dist/domains-api-0.1.6.tar.gz
Binary file not shown.
12 changes: 8 additions & 4 deletions domains_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def send_notification(self, ip=None, msg_type='success', error=None, outbox_msg=
msg = EmailMessage()
msg['From'] = self.gmail_address
msg['To'] = self.gmail_address
if ip and msg_type == 'success' and self.notifications not in {'n', 'e'}:
if ip and msg_type == 'success' and self.notifications != 'e':
msg.set_content(f'IP for {self.domain} has changed! New IP: {ip}')
msg['Subject'] = 'IP CHANGED!'
elif msg_type == 'error' and self.notifications != 'n':
elif msg_type == 'error':
msg.set_content(f"Error with {self.domain}'s IPChanger: ({error})!")
msg['Subject'] = 'IPCHANGER ERROR!'
elif outbox_msg:
Expand Down Expand Up @@ -130,12 +130,13 @@ def __init__(self, argv=None):
try:
if self.user.previous_ip == self.current_ip:
log_msg = 'Current IP: %s (no change)' % self.user.previous_ip
fh.log(log_msg, 'debug')
else:
self.user.previous_ip = self.current_ip
fh.save_user(self.user)
self.domains_api_call()
log_msg = 'Newly recorded IP: %s' % self.user.previous_ip
fh.log(log_msg, 'info')
fh.log(log_msg, 'info')
except AttributeError:
setattr(self.user, 'previous_ip', self.current_ip)
fh.save_user(self.user)
Expand Down Expand Up @@ -174,8 +175,10 @@ def domains_api_call(self):

# Successful request:
_response = response.split(' ')
if 'good' in _response or 'nochg' in _response:
if 'good' in _response:
self.user.send_notification(self.current_ip)
elif 'nochg' in _response:
return

# Unsuccessful requests:
elif response in {'nohost', 'notfqdn'}:
Expand All @@ -198,6 +201,7 @@ def domains_api_call(self):
fh.delete_user()
fh.log('API authentication failed, user profile deleted', 'warning')
sys.exit(1)

# Local connection related errors
except (ConnectionError, ReqConError) as e:
log_msg = 'Connection Error: %s' % e
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='domains-api',
version='0.1.5.2',
version='0.1.6',
description='Auto-updates your dynamic dns rules on Google Domains (domains.google.com)',
long_description=open('README.md').read() + '\n\n' + open('CHANGELOG.txt').read(),
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 7efad8d

Please sign in to comment.