mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-14 20:20:38 +01:00
Premier correction Hexas Indispo
This commit is contained in:
@@ -36,21 +36,24 @@ class DiscordBot(discord.Client):
|
|||||||
async def updateHumbleBundle(self):
|
async def updateHumbleBundle(self):
|
||||||
while not self.is_closed():
|
while not self.is_closed():
|
||||||
if ConfigurationHelper().getValue('humble_bundle_enable') and ConfigurationHelper().getIntValue('humble_bundle_channel') != 0 :
|
if ConfigurationHelper().getValue('humble_bundle_enable') and ConfigurationHelper().getIntValue('humble_bundle_channel') != 0 :
|
||||||
response = requests.get("http://hexas.shionn.org/humble-bundle/json", headers={ "Content-Type": "application/json" })
|
try :
|
||||||
if response.status_code == 200:
|
response = requests.get("http://hexas.shionn.org/humble-bundle/json", headers={ "Content-Type": "application/json" })
|
||||||
bundle = response.json()
|
if response.status_code == 200:
|
||||||
if GameBundle.query.filter_by(id=bundle['id']).first() == None :
|
bundle = response.json()
|
||||||
choice = bundle['choices'][0]
|
if GameBundle.query.filter_by(id=bundle['id']).first() == None :
|
||||||
date = datetime.datetime.fromtimestamp(bundle['endDate']/1000,datetime.UTC).strftime("%d %B %Y")
|
choice = bundle['choices'][0]
|
||||||
message = f"@here **Humble Bundle** propose un pack de jeu [{bundle['name']}]({bundle['url']}) contenant :\n"
|
date = datetime.datetime.fromtimestamp(bundle['endDate']/1000,datetime.UTC).strftime("%d %B %Y")
|
||||||
for game in choice["games"]:
|
message = f"@here **Humble Bundle** propose un pack de jeu [{bundle['name']}]({bundle['url']}) contenant :\n"
|
||||||
message += f"- {game}\n"
|
for game in choice["games"]:
|
||||||
message += f"Pour {choice['price']}€, disponible jusqu'au {date}."
|
message += f"- {game}\n"
|
||||||
await self.get_channel(ConfigurationHelper().getIntValue('humble_bundle_channel')).send(message)
|
message += f"Pour {choice['price']}€, disponible jusqu'au {date}."
|
||||||
db.session.add(GameBundle(id=bundle['id'], name=bundle['name'], json = json.dumps(bundle)))
|
await self.get_channel(ConfigurationHelper().getIntValue('humble_bundle_channel')).send(message)
|
||||||
db.session.commit()
|
db.session.add(GameBundle(id=bundle['id'], name=bundle['name'], json = json.dumps(bundle)))
|
||||||
else:
|
db.session.commit()
|
||||||
logging.error(f"Erreur de connexion {response.status_code}")
|
else:
|
||||||
|
logging.error(f"Erreur de connexion {response.status_code}")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Erreur de connexion {e}")
|
||||||
else:
|
else:
|
||||||
logging.info('Humble bundle est désactivé')
|
logging.info('Humble bundle est désactivé')
|
||||||
# toute les 30 minutes
|
# toute les 30 minutes
|
||||||
|
|||||||
Reference in New Issue
Block a user