From 8cdc67ba522e4cdfb563dce7662b70735c8065eb Mon Sep 17 00:00:00 2001 From: Michael Woolweaver Date: Mon, 15 Apr 2019 22:40:04 -0500 Subject: [PATCH] Update pihole_tweeter.py --- pihole_tweeter.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/pihole_tweeter.py b/pihole_tweeter.py index 6d235cf..31fadb7 100644 --- a/pihole_tweeter.py +++ b/pihole_tweeter.py @@ -28,12 +28,7 @@ if not (api_path, consumer_key, consumer_key, consumer_secret, access_token, acc print('2 Please check your config.ini.') sys.exit(1) - -def comma_value(num): - """Helper function for thousand separators""" - return "{:,}".format(int(num)).replace(',', '.') - - + def get_api(): auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) @@ -65,12 +60,12 @@ def get_pihole_data(): def construct_tweet(data): - today = datetime.today().strftime("%d.%m.%Y") - tweet = 'Pi-Hole-Statistik für den {date}:\n'.format(date=today) - tweet += 'Blockierte Werbung: ' + str(comma_value(data['ads_blocked_today'])) - tweet += ' (' + str(round(data['ads_percentage_today'], 2)).replace('.', ',') + ' %)\n' - tweet += 'DNS-Abfragen: ' + str(comma_value(data['dns_queries_today'])) + '\n' - tweet += 'Domains auf der Blacklist: ' + str(comma_value(data['domains_being_blocked'])) + today = datetime.today().strftime("%m.%d.%Y") + tweet = 'Pi-hole statistics for {date}:\n'.format(date=today) + tweet += 'Total Ads Blocked: ' + (data['ads_blocked_today']) + tweet += ' (' + (data['ads_percentage_today'] + ' %)\n' + tweet += 'Total DNS Queries: ' + (data['dns_queries_today']) + '\n' + tweet += 'Domains on Blacklist: ' + (data['domains_being_blocked']) return tweet