Fsoky 4 years ago
parent
commit
c6ff5593b9
  1. BIN
      PyPI files/dist/donationalerts-api-1.0.3.tar.gz
  2. BIN
      PyPI files/dist/donationalerts-api-1.0.4.tar.gz
  3. BIN
      PyPI files/dist/donationalerts-api-1.0.5.tar.gz
  4. BIN
      PyPI files/dist/donationalerts-api-1.0.6.tar.gz
  5. BIN
      PyPI files/dist/donationalerts-api-1.0.7.tar.gz
  6. BIN
      PyPI files/dist/donationalerts_api-1.0.3-py3-none-any.whl
  7. BIN
      PyPI files/dist/donationalerts_api-1.0.4-py3-none-any.whl
  8. BIN
      PyPI files/dist/donationalerts_api-1.0.5-py3-none-any.whl
  9. BIN
      PyPI files/dist/donationalerts_api-1.0.6-py3-none-any.whl
  10. BIN
      PyPI files/dist/donationalerts_api-1.0.7-py3-none-any.whl
  11. 15
      PyPI files/pyproject.toml
  12. 4
      README.md
  13. 10
      donationalerts_api/asyncio_api.py
  14. 9
      donationalerts_api/donationalerts_api.py
  15. 7
      donationalerts_api/utils.py

BIN
PyPI files/dist/donationalerts-api-1.0.3.tar.gz

Binary file not shown.

BIN
PyPI files/dist/donationalerts-api-1.0.4.tar.gz

Binary file not shown.

BIN
PyPI files/dist/donationalerts-api-1.0.5.tar.gz

Binary file not shown.

BIN
PyPI files/dist/donationalerts-api-1.0.6.tar.gz

Binary file not shown.

BIN
PyPI files/dist/donationalerts-api-1.0.7.tar.gz

Binary file not shown.

BIN
PyPI files/dist/donationalerts_api-1.0.3-py3-none-any.whl

Binary file not shown.

BIN
PyPI files/dist/donationalerts_api-1.0.4-py3-none-any.whl

Binary file not shown.

BIN
PyPI files/dist/donationalerts_api-1.0.5-py3-none-any.whl

Binary file not shown.

BIN
PyPI files/dist/donationalerts_api-1.0.6-py3-none-any.whl

Binary file not shown.

BIN
PyPI files/dist/donationalerts_api-1.0.7-py3-none-any.whl

Binary file not shown.

15
PyPI files/pyproject.toml

@ -1,15 +0,0 @@
[tool.poetry]
name = "donationalerts-api"
version = "1.0.7"
description = "https://github.com/Fsoky/Donation-Alerts-API-Python"
readme = "README.md"
authors = ["Fsoky Community <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

4
README.md

@ -112,7 +112,7 @@ from donationalerts_api.asyncio_api import Alert
alert = Alert("token")
@alert.event
@alert.event()
async def handler(event):
print(f"{event.username} пожертвовал {event.amount_formatted} {event.currency} | {event.message}")
""" Вывод:
@ -122,4 +122,4 @@ async def handler(event):
Как вы поняли, чтобы работать с асинхронном, нужно импортировать классы из пакета `asyncio_api`.
__Обзор новой версии от автора:__ *скоро...*
__Обзор новой версии от автора:__ *скоро...*

10
donationalerts_api/asyncio_api.py

@ -1,4 +1,5 @@
import json
from datetime import datetime
import asyncio
import socketio
@ -84,14 +85,15 @@ class DonationAlertsApi:
async with aiohttp.ClientSession() as session:
async with session.get(f"{DEFAULT_API_LINK}alerts/donations", headers=headers) as response:
print(response)
objs = await response.json()
donations = Donations(objects=objs["data"])
donations = Donations(objects=objs)
for obj in objs["data"]:
donation_object = DonationsData(
obj["amount"],
obj["amount_in_user_currency"],
obj["created_at"],
datetime.strptime(obj["created_at"], "%Y-%m-%d %H:%M:%S"),
obj["currency"],
obj["id"],
obj["is_shown"],
@ -230,7 +232,7 @@ class Centrifugo:
return CentrifugoResponse(
obj["amount"],
obj["amount_in_user_currency"],
obj["created_at"],
datetime.strptime(obj["created_at"], "%Y-%m-%d %H:%M:%S"),
obj["currency"],
obj["id"],
obj["is_shown"],
@ -281,7 +283,7 @@ class Alert:
data["currency"],
data["message"],
data["header"],
data["date_created"],
datetime.strptime(data["date_created"], "%Y-%m-%d %H:%M:%S"),
data["emotes"],
data["ap_id"],
data["_is_test_alert"],

9
donationalerts_api/donationalerts_api.py

@ -1,5 +1,6 @@
import json
import requests
from datetime import datetime
from websocket import create_connection
import socketio
@ -84,13 +85,13 @@ class DonationAlertsApi:
}
objs = requests.get(f"{DEFAULT_API_LINK}alerts/donations", headers=headers).json()
donations = Donations(objects=objs["data"])
donations = Donations(objects=objs)
for obj in objs["data"]:
donation_object = DonationsData(
obj["amount"],
obj["amount_in_user_currency"],
obj["created_at"],
datetime.strptime(obj["created_at"], "%Y-%m-%d %H:%M:%S"),
obj["currency"],
obj["id"],
obj["is_shown"],
@ -221,7 +222,7 @@ class Centrifugo:
return CentrifugoResponse(
obj["amount"],
obj["amount_in_user_currency"],
obj["created_at"],
datetime.strptime(obj["created_at"], "%Y-%m-%d %H:%M:%S"),
obj["currency"],
obj["id"],
obj["is_shown"],
@ -271,7 +272,7 @@ class Alert:
data["currency"],
data["message"],
data["header"],
data["date_created"],
datetime.strptime(data["date_created"], "%Y-%m-%d %H:%M:%S"),
data["emotes"],
data["ap_id"],
data["_is_test_alert"],

7
donationalerts_api/utils.py

@ -1,4 +1,5 @@
from dataclasses import dataclass
from typing import Any
@dataclass
@ -17,7 +18,7 @@ class Event:
currency: str
message: str
header: str
date_created: str
date_created: Any
emotes: str
ap_id: str
_is_test_alert: bool
@ -38,7 +39,7 @@ class DonationsData:
amount: int
amount_in_user_currency: float
created_at: str
created_at: Any
currency: str
id: int
is_shown: int
@ -79,7 +80,7 @@ class CentrifugoResponse:
amount: int
amount_in_user_currency: float
created_at: str
created_at: Any
currency: str
id: int
is_shown: int

Loading…
Cancel
Save