This repository was archived by the owner on Mar 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
39 lines (29 loc) · 1.36 KB
/
tools.py
File metadata and controls
39 lines (29 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import functools
import operator
from discord_webhook import DiscordWebhook, DiscordEmbed
import os
from dotenv import load_dotenv
discord_webhook = os.getenv('DISCORD_WEBHOOK_GENERAL')
def convertTuple(tup):
str = functools.reduce(operator.add, (tup))
return str
def post_to_discord(prev_minutes, current_hours, tc_fname, tc_lname, tc_cid, tc_hours):
# create embed object for webhook
embed = DiscordEmbed(title='Weekly Statistics',
description='Statustics for the week of {}.{}.{}'.format(today.year, today.month, today.day), color=242424)
# set image
embed.set_thumbnail(
url='https://image.prntscr.com/image/mTFpZeXOR8_lGUTO8gVg-Q.png')
current_hours = round(current_hours / 60 / 60, 1)
embed.add_embed_field(name='This Weeks Hours',
value='{}'.format(current_hours))
embed.add_embed_field(name='Last Weeks Hours',
value='{}'.format(prev_minutes))
embed2 = DiscordEmbed(title='This weeks top controller:',
description='{0} {1} - CID: {2} with {3} hours! Congratulations!'.format(tc_fname, tc_lname, tc_cid, tc_hours), color=242424)
# Post fun stuff to Discord
webhook = DiscordWebhook(url=discord_webhook)
# add embed object to webhook
webhook.add_embed(embed)
webhook.add_embed(embed2)
webhook.execute()