You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
import aiohttp
|
|
from random import choice
|
|
from steam import SteamID
|
|
|
|
class DiscordAlarm:
|
|
def __init__(self, webhook_url):
|
|
self.url = webhook_url
|
|
|
|
async def alert(self, steamid: SteamID, amount):
|
|
try:
|
|
await self.send(self.prepare_payload(steamid, amount))
|
|
except:
|
|
pass
|
|
|
|
def prepare_payload(self, steamid: SteamID, amount):
|
|
phrare = [
|
|
"Поздравим очередного игрока с покупкой випа!",
|
|
"Очередной игрок приобрел вип.",
|
|
"Ура кто-то украл деньги у мамки и принес их нам!!!",
|
|
"Делать деньги, делать деньги блять вот так..."
|
|
]
|
|
payload = {"embeds":[{"fields":[]}]}
|
|
payload.update({"content":choice(phrare)})
|
|
payload["embeds"][0]["fields"].append({
|
|
"name": "Ссылка на игрока:",
|
|
"value": steamid.community_url,
|
|
"inline": True
|
|
})
|
|
payload["embeds"][0]["fields"].append({
|
|
"name": "Количество дней:",
|
|
"value": "{}".format(round(amount / 60 / 60 / 24)),
|
|
"inline": True
|
|
})
|
|
payload["embeds"][0]["fields"].append({
|
|
"name": "Оплата:",
|
|
"value": "{}".format("Steam"),
|
|
"inline": True
|
|
})
|
|
return payload
|
|
|
|
async def send(self, payload):
|
|
async with aiohttp.ClientSession() as session:
|
|
await session.post(self.url, json = payload)
|