| @@ -0,0 +1,28 @@ | |||||
| from datetime import date | |||||
| from config import information | |||||
| from fetch_today_date import get_date | |||||
| date_dest = information['date'] | |||||
| def calcul(date, d_date): | |||||
| delta = d_date - date | |||||
| if 0 > delta.days : | |||||
| result = delta.days * (-1) | |||||
| else : | |||||
| result = delta.days | |||||
| return result | |||||
| def main(): | |||||
| print("Test du programme pour calculer le nombre de jour") | |||||
| today = get_date(date.today()) | |||||
| dest = get_date(date_dest) | |||||
| print(calcul(today, dest)) | |||||
| if __name__ == '__main__': | |||||
| main() | |||||
| @@ -0,0 +1,5 @@ | |||||
| from datetime import date | |||||
| information = { | |||||
| 'date' : '2021-02-18', | |||||
| 'webhook' : 'xxxxx' | |||||
| } | |||||
| @@ -0,0 +1,28 @@ | |||||
| import requests | |||||
| from config import information | |||||
| import json | |||||
| def webhook(message): | |||||
| url = information['webhook'] | |||||
| data = {} | |||||
| #for all params, see https://discordapp.com/developers/docs/resources/webhook#execute-webhook | |||||
| data["content"] = "temps avant la sortie de FC6" | |||||
| #leave this out if you dont want an embed | |||||
| data["embeds"] = [] | |||||
| embed = {} | |||||
| #for all params, see https://discordapp.com/developers/docs/resources/channel#embed-object | |||||
| embed["description"] = message | |||||
| embed["title"] = "FARCRY6 DAYCOUNTER" | |||||
| data["embeds"].append(embed) | |||||
| result = requests.post(url, data=json.dumps(data), headers={"Content-Type": "application/json"}) | |||||
| def main(): | |||||
| print("test message") | |||||
| webhook("test message") | |||||
| if __name__ == '__main__': | |||||
| main() | |||||
| @@ -0,0 +1,9 @@ | |||||
| from datetime import date | |||||
| def get_date(data): | |||||
| data = str(data) | |||||
| assert type(data) == str | |||||
| data = data.split('-') | |||||
| info = date(int(data[0]), int(data[1]), int(data[2])) | |||||
| return info | |||||
| @@ -0,0 +1,32 @@ | |||||
| from datetime import date | |||||
| import time | |||||
| from fetch_today_date import get_date | |||||
| from calcul import calcul | |||||
| from config import information | |||||
| from discord import webhook | |||||
| import sys | |||||
| date_dest = information['date'] | |||||
| def main(): | |||||
| while 1 : | |||||
| print("FarCry 6 daycounter") | |||||
| today = date.today() | |||||
| dest = get_date(date_dest) | |||||
| temps = calcul(today, dest) | |||||
| if temps == 0 : | |||||
| print("Mon role est maintenant terminé... je peux partir en paix..") | |||||
| webhook(u" FARCRY sort aujourd'hui ! Bandes de puuuutes. ") | |||||
| sys.exit(0) | |||||
| else : | |||||
| message = "Il reste " + str(temps) + " jours, avant la mort de la vie sociale d'adrien" | |||||
| webhook(message) | |||||
| time.sleep(86400) | |||||
| if __name__ == '__main__': | |||||
| try : | |||||
| main() | |||||
| except KeyboardInterrupt : | |||||
| print("Fermeture du programme...") | |||||