mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-20 13:04:23 +02:00
Add TwitchAlerts plugin
This commit is contained in:
11
lnbits/extensions/TwitchAlerts/README.md
Normal file
11
lnbits/extensions/TwitchAlerts/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
<h1>Example Extension</h1>
|
||||
<h2>*tagline*</h2>
|
||||
This is an TwitchAlerts extension to help you organise and build you own.
|
||||
|
||||
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>
|
12
lnbits/extensions/TwitchAlerts/__init__.py
Normal file
12
lnbits/extensions/TwitchAlerts/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from quart import Blueprint
|
||||
from lnbits.db import Database
|
||||
|
||||
db = Database("ext_TwitchAlerts")
|
||||
|
||||
TwitchAlerts_ext: Blueprint = Blueprint(
|
||||
"TwitchAlerts", __name__, static_folder="static", template_folder="templates"
|
||||
)
|
||||
|
||||
|
||||
from .views_api import * # noqa
|
||||
from .views import * # noqa
|
6
lnbits/extensions/TwitchAlerts/config.json
Normal file
6
lnbits/extensions/TwitchAlerts/config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "Build your own!",
|
||||
"short_description": "Join us, make an extension",
|
||||
"icon": "info",
|
||||
"contributors": ["github_username"]
|
||||
}
|
11
lnbits/extensions/TwitchAlerts/migrations.py
Normal file
11
lnbits/extensions/TwitchAlerts/migrations.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# async def m001_initial(db):
|
||||
|
||||
# await db.execute(
|
||||
# """
|
||||
# CREATE TABLE IF NOT EXISTS TwitchAlerts (
|
||||
# id TEXT PRIMARY KEY,
|
||||
# wallet TEXT NOT NULL,
|
||||
# time TIMESTAMP NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||
# );
|
||||
# """
|
||||
# )
|
11
lnbits/extensions/TwitchAlerts/models.py
Normal file
11
lnbits/extensions/TwitchAlerts/models.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# from sqlite3 import Row
|
||||
# from typing import NamedTuple
|
||||
|
||||
|
||||
# class Example(NamedTuple):
|
||||
# id: str
|
||||
# wallet: str
|
||||
#
|
||||
# @classmethod
|
||||
# def from_row(cls, row: Row) -> "Example":
|
||||
# return cls(**dict(row))
|
57
lnbits/extensions/TwitchAlerts/templates/example/index.html
Normal file
57
lnbits/extensions/TwitchAlerts/templates/example/index.html
Normal file
@@ -0,0 +1,57 @@
|
||||
{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
|
||||
%} {% block page %}
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h5 class="text-subtitle1 q-mt-none q-mb-md">Frameworks used by LNbits</h5>
|
||||
<q-list>
|
||||
<q-item
|
||||
v-for="tool in tools"
|
||||
:key="tool.name"
|
||||
tag="a"
|
||||
:href="tool.url"
|
||||
target="_blank"
|
||||
>
|
||||
{% raw %}
|
||||
<!-- with raw Flask won't try to interpret the Vue moustaches -->
|
||||
<q-item-section>
|
||||
<q-item-label>{{ tool.name }}</q-item-label>
|
||||
<q-item-label caption>{{ tool.language }}</q-item-label>
|
||||
</q-item-section>
|
||||
{% endraw %}
|
||||
</q-item>
|
||||
</q-list>
|
||||
<q-separator class="q-my-lg"></q-separator>
|
||||
<p>
|
||||
A magical "g" is always available, with info about the user, wallets and
|
||||
extensions:
|
||||
</p>
|
||||
<code class="text-caption">{% raw %}{{ g }}{% endraw %}</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#vue',
|
||||
mixins: [windowMixin],
|
||||
data: function () {
|
||||
return {
|
||||
tools: []
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
var self = this
|
||||
|
||||
// axios is available for making requests
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: '/TwitchAlerts/api/v1/tools',
|
||||
headers: {
|
||||
'X-TwitchAlerts-header': 'not-used'
|
||||
}
|
||||
}).then(function (response) {
|
||||
self.tools = response.data
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
12
lnbits/extensions/TwitchAlerts/views.py
Normal file
12
lnbits/extensions/TwitchAlerts/views.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from quart import g, render_template
|
||||
|
||||
from lnbits.decorators import check_user_exists, validate_uuids
|
||||
|
||||
from . import TwitchAlerts_ext
|
||||
|
||||
|
||||
@TwitchAlerts_ext.route("/")
|
||||
@validate_uuids(["usr"], required=True)
|
||||
@check_user_exists()
|
||||
async def index():
|
||||
return await render_template("TwitchAlerts/index.html", user=g.user)
|
40
lnbits/extensions/TwitchAlerts/views_api.py
Normal file
40
lnbits/extensions/TwitchAlerts/views_api.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# views_api.py is for you API endpoints that could be hit by another service
|
||||
|
||||
# add your dependencies here
|
||||
|
||||
# import json
|
||||
# import httpx
|
||||
# (use httpx just like requests, except instead of response.ok there's only the
|
||||
# response.is_error that is its inverse)
|
||||
|
||||
from quart import jsonify
|
||||
from http import HTTPStatus
|
||||
|
||||
from . import TwitchAlerts_ext
|
||||
|
||||
|
||||
# add your endpoints here
|
||||
|
||||
|
||||
@TwitchAlerts_ext.route("/api/v1/tools", methods=["GET"])
|
||||
async def api_TwitchAlerts():
|
||||
"""Try to add descriptions for others."""
|
||||
tools = [
|
||||
{
|
||||
"name": "Quart",
|
||||
"url": "https://pgjones.gitlab.io/quart/",
|
||||
"language": "Python",
|
||||
},
|
||||
{
|
||||
"name": "Vue.js",
|
||||
"url": "https://vuejs.org/",
|
||||
"language": "JavaScript",
|
||||
},
|
||||
{
|
||||
"name": "Quasar Framework",
|
||||
"url": "https://quasar.dev/",
|
||||
"language": "JavaScript",
|
||||
},
|
||||
]
|
||||
|
||||
return jsonify(tools), HTTPStatus.OK
|
Reference in New Issue
Block a user