Rename TwitchAlerts to StreamAlerts

This commit is contained in:
Fitti 2021-08-01 04:54:43 +02:00
parent 85bf0ebb15
commit 7444be8c54
11 changed files with 43 additions and 43 deletions

View file

@ -1,10 +1,10 @@
<h1>Example Extension</h1>
<h2>*tagline*</h2>
The TwitchAlerts extension allows you to integrate Bitcoin Lightning (and on-chain) paymnents in to your existing Streamlabs alerts!
The StreamAlerts extension allows you to integrate Bitcoin Lightning (and on-chain) paymnents in to your existing Streamlabs alerts!
Try to include an image
<img src="https://i.imgur.com/9i4xcQB.png">
<h2>If your extension has API endpoints, include useful ones here</h2>
<code>curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"TwitchAlerts"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"</code>
<code>curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"StreamAlerts"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"</code>

View file

@ -1,10 +1,10 @@
from quart import Blueprint
from lnbits.db import Database
db = Database("ext_twitchalerts")
db = Database("ext_streamalerts")
twitchalerts_ext: Blueprint = Blueprint(
"twitchalerts", __name__, static_folder="static", template_folder="templates"
streamalerts_ext: Blueprint = Blueprint(
"streamalerts", __name__, static_folder="static", template_folder="templates"
)
from .views_api import * # noqa

View file

@ -1,5 +1,5 @@
{
"name": "Twitch Alerts",
"name": "Stream Alerts",
"short_description": "Integrate Bitcoin donations into your stream alerts!",
"icon": "notifications_active",
"contributors": ["Fittiboy"]

View file

@ -17,7 +17,7 @@ from lnbits.core.crud import get_wallet
async def get_service_redirect_uri(request, service_id):
"""Return the service's redirect URI, to be given to the third party API"""
uri_base = request.scheme + "://"
uri_base += request.headers["Host"] + "/twitchalerts/api/v1"
uri_base += request.headers["Host"] + "/streamalerts/api/v1"
redirect_uri = uri_base + f"/authenticate/{service_id}"
return redirect_uri
@ -191,7 +191,7 @@ async def authenticate_service(service_id, code, redirect_uri):
print(response)
token = response["access_token"]
success = await service_add_token(service_id, token)
return f"/twitchalerts/?usr={user}", success
return f"/streamalerts/?usr={user}", success
async def service_add_token(service_id, token):

View file

@ -1,7 +1,7 @@
<q-card>
<q-card-section>
<h4 class="text-subtitle1 q-my-none">
Twitch Alerts: Integrate Bitcoin into your stream alerts!
Stream Alerts: Integrate Bitcoin into your stream alerts!
</h4>
<p>
Accept Bitcoin donations on Twitch, and integrate them into your alerts.

View file

@ -76,7 +76,7 @@
Invoice: function () {
var self = this
axios
.post('/twitchalerts/api/v1/donations', {
.post('/streamalerts/api/v1/donations', {
service: {{ service }},
name: self.donationDialog.data.name,
sats: self.donationDialog.data.sats,

View file

@ -151,11 +151,11 @@
<div class="col-12 col-md-4 col-lg-5 q-gutter-y-md">
<q-card>
<q-card-section>
<h6 class="text-subtitle1 q-my-none">LNbits Twitch Alerts extension</h6>
<h6 class="text-subtitle1 q-my-none">LNbits Stream Alerts extension</h6>
</q-card-section>
<q-card-section class="q-pa-none">
<q-separator></q-separator>
<q-list> {% include "twitchalerts/_api_docs.html" %} </q-list>
<q-list> {% include "streamalerts/_api_docs.html" %} </q-list>
</q-card-section>
</q-card>
</div>
@ -229,14 +229,14 @@
</div>
{% endblock %} {% block scripts %} {{ window_vars(user) }}
<script>
var mapTwitchAlerts = function (obj) {
var mapStreamAlerts = function (obj) {
obj.date = Quasar.utils.date.formatDate(
new Date(obj.time * 1000),
'YYYY-MM-DD HH:mm'
)
obj.fsat = new Intl.NumberFormat(LOCALE).format(obj.amount)
obj.authUrl = ['/twitchalerts/api/v1/getaccess/', obj.id].join('')
obj.displayUrl = ['/twitchalerts/', obj.state].join('')
obj.authUrl = ['/streamalerts/api/v1/getaccess/', obj.id].join('')
obj.displayUrl = ['/streamalerts/', obj.state].join('')
return obj
}
@ -316,12 +316,12 @@
LNbits.api
.request(
'GET',
'/twitchalerts/api/v1/donations',
'/streamalerts/api/v1/donations',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.donations = response.data.map(function (obj) {
return mapTwitchAlerts(obj)
return mapStreamAlerts(obj)
})
})
},
@ -335,7 +335,7 @@
LNbits.api
.request(
'DELETE',
'/twitchalerts/api/v1/donations/' + donationId,
'/streamalerts/api/v1/donations/' + donationId,
_.findWhere(self.g.user.wallets, {id: donations.wallet}).inkey
)
.then(function (response) {
@ -358,12 +358,12 @@
LNbits.api
.request(
'GET',
'/twitchalerts/api/v1/services',
'/streamalerts/api/v1/services',
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.services = response.data.map(function (obj) {
return mapTwitchAlerts(obj)
return mapStreamAlerts(obj)
})
})
},
@ -379,9 +379,9 @@
createService: function (wallet, data) {
var self = this
LNbits.api
.request('POST', '/twitchalerts/api/v1/services', wallet.inkey, data)
.request('POST', '/streamalerts/api/v1/services', wallet.inkey, data)
.then(function (response) {
self.services.push(mapTwitchAlerts(response.data))
self.services.push(mapStreamAlerts(response.data))
self.serviceDialog.show = false
self.serviceDialog.data = {}
})
@ -410,7 +410,7 @@
LNbits.api
.request(
'DELETE',
'/twitchalerts/api/v1/services/' + servicesId,
'/streamalerts/api/v1/services/' + servicesId,
_.findWhere(self.g.user.wallets, {id: services.wallet}).inkey
)
.then(function (response) {

View file

@ -3,24 +3,24 @@ from quart import g, abort, render_template
from lnbits.decorators import check_user_exists, validate_uuids
from http import HTTPStatus
from . import twitchalerts_ext
from . import streamalerts_ext
from .crud import get_service
@twitchalerts_ext.route("/")
@streamalerts_ext.route("/")
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
"""Return the extension's settings page"""
return await render_template("twitchalerts/index.html", user=g.user)
return await render_template("streamalerts/index.html", user=g.user)
@twitchalerts_ext.route("/<state>")
@streamalerts_ext.route("/<state>")
async def donation(state):
"""Return the donation form for the Service corresponding to state"""
service = await get_service(0, by_state=state)
if not service:
abort(HTTPStatus.NOT_FOUND, "Service does not exist.")
return await render_template(
"twitchalerts/display.html", twitchuser=service.twitchuser, service=service.id
"streamalerts/display.html", twitchuser=service.twitchuser, service=service.id
)

View file

@ -5,7 +5,7 @@ from lnbits.decorators import api_validate_post_request, api_check_wallet_key
from lnbits.core.crud import get_wallet, get_user
from lnbits.utils.exchange_rates import btc_price
from . import twitchalerts_ext
from . import streamalerts_ext
from .crud import (
get_charge_details,
get_service_redirect_uri,
@ -25,7 +25,7 @@ from .crud import (
from ..satspay.crud import create_charge, get_charge
@twitchalerts_ext.route("/api/v1/services", methods=["POST"])
@streamalerts_ext.route("/api/v1/services", methods=["POST"])
@api_check_wallet_key("invoice")
@api_validate_post_request(
schema={
@ -43,11 +43,11 @@ async def api_create_service():
wallet = await get_wallet(service.wallet)
user = wallet.user
redirect_url = request.scheme + "://" + request.headers["Host"]
redirect_url += f"/twitchalerts/?usr={user}&created={str(service.id)}"
redirect_url += f"/streamalerts/?usr={user}&created={str(service.id)}"
return redirect(redirect_url)
@twitchalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"])
@streamalerts_ext.route("/api/v1/getaccess/<service_id>", methods=["GET"])
async def api_get_access(service_id):
"""Redirect to Streamlabs' Approve/Decline page for API access for Service
with service_id
@ -70,7 +70,7 @@ async def api_get_access(service_id):
return (jsonify({"message": "Service does not exist!"}), HTTPStatus.BAD_REQUEST)
@twitchalerts_ext.route("/api/v1/authenticate/<service_id>", methods=["GET"])
@streamalerts_ext.route("/api/v1/authenticate/<service_id>", methods=["GET"])
async def api_authenticate_service(service_id):
"""Endpoint visited via redirect during third party API authentication
@ -83,7 +83,7 @@ async def api_authenticate_service(service_id):
if service.state != state:
return (jsonify({"message": "State doesn't match!"}), HTTPStatus.BAD_Request)
redirect_uri = request.scheme + "://" + request.headers["Host"]
redirect_uri += f"/twitchalerts/api/v1/authenticate/{service_id}"
redirect_uri += f"/streamalerts/api/v1/authenticate/{service_id}"
url, success = await authenticate_service(service_id, code, redirect_uri)
if success:
return redirect(url)
@ -94,7 +94,7 @@ async def api_authenticate_service(service_id):
)
@twitchalerts_ext.route("/api/v1/donations", methods=["POST"])
@streamalerts_ext.route("/api/v1/donations", methods=["POST"])
@api_validate_post_request(
schema={
"name": {"type": "string"},
@ -122,7 +122,7 @@ async def api_create_donation():
amount=sats,
completelink=f"https://twitch.tv/{service.twitchuser}",
completelinktext="Back to Stream!",
webhook=webhook_base + "/twitchalerts/api/v1/postdonation",
webhook=webhook_base + "/streamalerts/api/v1/postdonation",
description=description,
**charge_details,
)
@ -139,7 +139,7 @@ async def api_create_donation():
return (jsonify({"redirect_url": f"/satspay/{charge.id}"}), HTTPStatus.OK)
@twitchalerts_ext.route("/api/v1/postdonation", methods=["POST"])
@streamalerts_ext.route("/api/v1/postdonation", methods=["POST"])
@api_validate_post_request(
schema={
"id": {"type": "string", "required": True},
@ -158,7 +158,7 @@ async def api_post_donation():
return (jsonify({"message": "Not a paid charge!"}), HTTPStatus.BAD_REQUEST)
@twitchalerts_ext.route("/api/v1/services", methods=["GET"])
@streamalerts_ext.route("/api/v1/services", methods=["GET"])
@api_check_wallet_key("invoice")
async def api_get_services():
"""Return list of all services assigned to wallet with given invoice key"""
@ -173,7 +173,7 @@ async def api_get_services():
)
@twitchalerts_ext.route("/api/v1/donations", methods=["GET"])
@streamalerts_ext.route("/api/v1/donations", methods=["GET"])
@api_check_wallet_key("invoice")
async def api_get_donations():
"""Return list of all donations assigned to wallet with given invoice
@ -190,7 +190,7 @@ async def api_get_donations():
)
@twitchalerts_ext.route("/api/v1/donations/<donation_id>", methods=["PUT"])
@streamalerts_ext.route("/api/v1/donations/<donation_id>", methods=["PUT"])
@api_check_wallet_key("invoice")
async def api_update_donation(donation_id=None):
"""Update a donation with the data given in the request"""
@ -215,7 +215,7 @@ async def api_update_donation(donation_id=None):
return jsonify(donation._asdict()), HTTPStatus.CREATED
@twitchalerts_ext.route("/api/v1/services/<service_id>", methods=["PUT"])
@streamalerts_ext.route("/api/v1/services/<service_id>", methods=["PUT"])
@api_check_wallet_key("invoice")
async def api_update_service(service_id=None):
"""Update a service with the data given in the request"""
@ -237,7 +237,7 @@ async def api_update_service(service_id=None):
return jsonify(service._asdict()), HTTPStatus.CREATED
@twitchalerts_ext.route("/api/v1/donations/<donation_id>", methods=["DELETE"])
@streamalerts_ext.route("/api/v1/donations/<donation_id>", methods=["DELETE"])
@api_check_wallet_key("invoice")
async def api_delete_donation(donation_id):
"""Delete the donation with the given donation_id"""
@ -254,7 +254,7 @@ async def api_delete_donation(donation_id):
return "", HTTPStatus.NO_CONTENT
@twitchalerts_ext.route("/api/v1/services/<service_id>", methods=["DELETE"])
@streamalerts_ext.route("/api/v1/services/<service_id>", methods=["DELETE"])
@api_check_wallet_key("invoice")
async def api_delete_service(service_id):
"""Delete the service with the given service_id"""