reset
This commit is contained in:
parent
6bed8dd8b2
commit
88590c126e
@ -29,6 +29,11 @@ if not (api_path, consumer_key, consumer_key, consumer_secret, access_token, acc
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def comma_value(num):
|
||||||
|
"""Helper function for thousand separators"""
|
||||||
|
return "{:,}".format(int(num)).replace(',', '.')
|
||||||
|
|
||||||
|
|
||||||
def get_api():
|
def get_api():
|
||||||
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
||||||
auth.set_access_token(access_token, access_token_secret)
|
auth.set_access_token(access_token, access_token_secret)
|
||||||
@ -60,12 +65,12 @@ def get_pihole_data():
|
|||||||
|
|
||||||
|
|
||||||
def construct_tweet(data):
|
def construct_tweet(data):
|
||||||
today = datetime.today().strftime("%m.%d.%Y")
|
today = datetime.today().strftime("%d.%m.%Y")
|
||||||
tweet = 'Pi-hole Stats for {date}:\n'.format(date=today)
|
tweet = 'Pi-Hole-Statistik für den {date}:\n'.format(date=today)
|
||||||
tweet += 'Total Ads Blocked: ' + str(['ads_blocked_today'])
|
tweet += 'Blockierte Werbung: ' + str(comma_value(data['ads_blocked_today']))
|
||||||
tweet += ' (' + str(['ads_percentage_today']) + ' %)\n'
|
tweet += ' (' + str(round(data['ads_percentage_today'], 2)).replace('.', ',') + ' %)\n'
|
||||||
tweet += 'Total DNS Queries: ' + str(['dns_queries_today']) + '\n'
|
tweet += 'DNS-Abfragen: ' + str(comma_value(data['dns_queries_today'])) + '\n'
|
||||||
tweet += 'Domains on Blacklist: ' + str(['domains_being_blocked'])
|
tweet += 'Domains auf der Blacklist: ' + str(comma_value(data['domains_being_blocked']))
|
||||||
return tweet
|
return tweet
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user