Donation alerts api python

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

divinity1437/donationalerts_python

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Donationalerts python automatic tool

Donationalerts python is a tool for getting in 24/7 way about new donations, subs and other alerts from Donationalerts

knowledge of linux, python will certainly help, but are by nomeans required.

this guide will be targetted towards ubuntu — other distros may have slightly different setup processes.

download the codebase onto your machine

# clone repository git clone https://github.com/divinity1437/donationalerts_python # enter directory cd donationalerts_python # install dependencies python -m pip install -r requirements.txt

all configuration can be done from the .env file. we provide an example .env.example file which you can use as a base.

# create a configuration file from the sample provided cp .env.example .env # open the configuration file for editing nano .env

congratulations! you just end with setup!

if everything went well, you should be able to start your server up:

# start the server python main.py

Everything is under GPL license. Free-to-use tool.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Читайте также:  Getitem и setitem python

Модуль для Python, который позволит легко работать с Donation Alerts API

TheLovii/Donation-Alerts-API-Python

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Donation Alerts API Python

Модуль для Python, который позволит легко работать с Donation Alerts API

pip install donationalerts-api -U

В этом примере мы логинимся в нашем приложении с определенными правами, получаем access_token, после в пременной user мы получаем JSON-объект, в котором содержится информация, в переменной donations тоже хранится информация, только уже другая. И теперь возвращаем нашу переменную user

DonationAlertsAPI — основной класс для работы с DA API, на вход принимает client_id, client_secret, redirect_uri, scopes
Scopes — позволит вам передать ряд прав в удобном формате, все права можете посмотреть в оф. документации, также имеет атрибут ALL_SCOPES для передачи всех прав сразу (Scopes.ALL_SCOPES)

from flask import Flask, redirect, request from donationalerts_api import DonationAlertsAPI from donationalerts_api.modules import Scopes app = Flask(__name__) api = DonationAlertsAPI("client id", "client secret", "http://127.0.0.1:5000/login", [Scopes.USER_SHOW, Scopes.DONATION_INDEX]) @app.route("/", methods=["get"]) def index(): return redirect(api.login()) # Log in your application @app.route("/login", methods=["get"]) def login(): code = request.args.get("code") # Получить нужный код для access token access_token = api.get_access_token(code) user = api.user(access_token) donations = api.donations_list(access_token) # Получить список донатов return user.objects # Возвращает JSON object if __name__ == "__main__": app.run(debug=True)

💖 Получение донатов в реальном времени без Oauth2

Здесь мы легко можем получить донат в реальном времени, для этого всего лишь нужно токен и пару строчек кода. Токен вы можете скопировать в Основных настройках. Теперь при новом донате, вы получите JSON-объект, который можете использовать уже сами.

ТОКЕН

from donationalerts_api import Alert alert = Alert("token") @alert.event() def new_donation(event): """ Пример обращения event.username - получает никнейм донатера event.objects - вернуть JSON object """ print(event) # Выведет все доступные атрибуты, к которым можно обратиться

Все примеры вы можете посмотреть в папке Examples
Donation Alerts API Python — небольшой обзор — в ролике, автор рассказывает о первой версии, возможно кому-то будет интересно
Donation Alerts API Python — получение событий в реальном времени — небольшая история обновлений и демонстрация новых возможностей

Читайте также:  Html access local file

Asyncio Donation Alerts API

Новое обновление 1.0.9 beta

Наконец-то можно использовать модуль асинхронно. Все очень просто, методы не поменялись, остается только дописывать await, пример ниже.

Работа с центрифугой (донаты в реальном времени Oauth2)

from flask import Flask, redirect, request # pip install flask[async] from donationalerts_api.asyncio_api import DonationAlertsAPI, Centrifugo from donationalerts_api.modules import Scopes, Channels app = Flask(__name__) api = DonationAlertsAPI("client id", "client secret", "http://127.0.0.1:5000/login", [Scopes.USER_SHOW, Scopes.DONATION_SUBSCRIBE]) @app.route("/", methods=["get"]) def index(): return redirect(api.login()) @app.route("/login", methods=["get"]) async def login(): code = request.args.get("code") access_token = await api.get_access_token(code) user = await api.user(access_token) fugo = Centrifugo(user.socket_connection_token, access_token, user.id) event = await fugo.subscribe(Channels.NEW_DONATION_ALERTS) # В новой версии .connect не нужен. return event.objects # Возвращает JSON object (в практически каждом методе есть objects) if __name__ == "__main__": app.run(debug=True)

Донаты в реальном времени без Oauth2

from donationalerts_api.asyncio_api import Alert alert = Alert("token") @alert.event() async def handler(event): print(f"event.username> пожертвовал event.amount_formatted> event.currency> | event.message>") """ Вывод: Fsoky пожертвовал 9999.0 RUB | Тут его сообщение. """

Как вы поняли, чтобы работать с асинхронном, нужно импортировать классы из пакета asyncio_api .

About

Модуль для Python, который позволит легко работать с Donation Alerts API

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

This module for python. With help this module, you can interact with API Donation Alerts

bifenbecker/Donation-Alerts-API-Python

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

This module for python. With help this module, you can interact with API Donation Alerts

pip install donationalerts_api -U 
Class Description
DonationAlertsApi(client_id, client_secret, redirect_uri, scope) Request to API Donation Alerts
Scopes Has attributes for the instruction of scopes (user_show, donation_index, donation_subcribe, custom_alert_store, goal_subcribe, poll_subcribe, all_scopes)
Method Description
login() Returns link for connect to API
get_code() Returns code access application
get_access_token(code) Receive access token for the application (necessarily: transfer argument code which you got by get_code)
get_donations(access_token) Receive information about donate (messages)
get_user(access_token) Receive information about user
send_custom_alert(access_token, external_id, headline, messages, image_url=None, sound_url=None, is_shown=0) Send custom alert
from flask import Flask, redirect from donationalerts_api import DonationAlertsApi, Scopes client = Flask(__name__) api = DonationAlertsApi("9999", "a43f67k9920h01a2wdw", "http://127.0.0.1:5000/login", Scopes.all_scopes) @client.route("/", methods=["get"]) def index(): redirect(api.login()) @client.route("/login", methods=["get"]) def login(): code = api.get_code() access_token = api.get_access_token(code) user = api.get_user(access_token) donations = api.get_donations(access_token) api.send_custom_alert(access_token, 12, "Test headline", "Test something message. ") return user if __name__ == "__main__": client.run(debug=True)

Now you can pass list of scopes:

from donationalerts_api import DonationAlertsApi, Scopes # New class: Scopes scopes = ["oauth-user-show", "oauth-donation-index", "oauth-poll-subcribe"] # Also right variant api = DonationAlertsApi("client id", "client secret", "redirect uri", [Scopes.user_show, Scopes.donation_index]) # Or you can pass all scopes: Scopes.all_scopes

About

This module for python. With help this module, you can interact with API Donation Alerts

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Модуль для работы с Donation Alerts API

Fsoky/DonationAlertsAPI

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

DA API

$ pip install DonationAlertsAPI 
$ git clone https://github.com/Fsoky/DonationAlertsAPI $ cd DonationAlertsAPI $ python setup.py install 
$ pip install git+https://github.com/Fsoky/DonationAlertsAPI 

Создайте свое собственное приложение для работы с DA API

from flask import Flask, redirect, request from donationalerts import DonationAlertsAPI, Scopes app = Flask(__name__) api = DonationAlertsAPI("client id", "client secret", "http://127.0.0.1:5000/login", Scopes.USER_SHOW) @app.route("/", methods=["GET"]) def index(): return redirect(api.login()) @app.route("/login", methods=["GET"]) def login(): code = request.args.get("code") access_token = api.get_access_token(code) user = api.user(access_token) return user.objects if __name__ == "__main__": app.run(debug=True)

Источник

Оцените статью