Discord.py 当史诗商店的游戏免费时,机器人会发送更新
Discord.py bot send update when a game is free on the epic store
我希望我的 discord 机器人在史诗商店中将游戏列为免费游戏时发送短信。我使用下面的代码来获取游戏的名称,如何在值更新时将其获取到 运行?
编辑:我从 here 中找到了 URL。
import requests
import json
@bot.command(name='free', pass_context=True, aliases=['fr'])
async def free(ctx, message):
try:
ENDPOINT = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=es-ES&country=ES&allowCountries=ES"
URL = "https://www.epicgames.com/store/us-US/product/"
raw_data = requests.get(ENDPOINT)
raw_data = json.loads(raw_data.content)
raw_data = raw_data["data"]["Catalog"]["searchStore"]["elements"] # Cleans the data
processed_data = []
for i in raw_data:
try:
if i["promotions"]["promotionalOffers"]:
game = i["title"]
processed_data.append(game)
except TypeError:
pass
await ctx.message.channel.send("**{}** is now free on the Epic store!".format(processed_data[0]))
except Exception:
pass
我希望我的 discord 机器人在史诗商店中将游戏列为免费游戏时发送短信。我使用下面的代码来获取游戏的名称,如何在值更新时将其获取到 运行?
编辑:我从 here 中找到了 URL。
import requests
import json
@bot.command(name='free', pass_context=True, aliases=['fr'])
async def free(ctx, message):
try:
ENDPOINT = "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=es-ES&country=ES&allowCountries=ES"
URL = "https://www.epicgames.com/store/us-US/product/"
raw_data = requests.get(ENDPOINT)
raw_data = json.loads(raw_data.content)
raw_data = raw_data["data"]["Catalog"]["searchStore"]["elements"] # Cleans the data
processed_data = []
for i in raw_data:
try:
if i["promotions"]["promotionalOffers"]:
game = i["title"]
processed_data.append(game)
except TypeError:
pass
await ctx.message.channel.send("**{}** is now free on the Epic store!".format(processed_data[0]))
except Exception:
pass