forked from rDrama/rDrama
kofi integration (testing on devrama)
parent
eb50e7a791
commit
e69827e6e0
|
@ -25,3 +25,4 @@ from .lottery import *
|
||||||
from .casino_game import *
|
from .casino_game import *
|
||||||
from .hats import *
|
from .hats import *
|
||||||
from .marsey import *
|
from .marsey import *
|
||||||
|
from .transactions import *
|
|
@ -0,0 +1,17 @@
|
||||||
|
from files.helpers.const import KOFI_TOKEN
|
||||||
|
|
||||||
|
if KOFI_TOKEN:
|
||||||
|
from sqlalchemy import *
|
||||||
|
from files.__main__ import Base
|
||||||
|
|
||||||
|
class Transaction(Base):
|
||||||
|
|
||||||
|
__tablename__ = "kofi"
|
||||||
|
id = Column(String, primary_key=True)
|
||||||
|
created_utc = Column(Integer)
|
||||||
|
type = Column(String)
|
||||||
|
amount = Column(Integer)
|
||||||
|
email = Column(String)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<Transaction(id={self.id})>"
|
|
@ -1047,6 +1047,7 @@ DISCORD_AUTH = environ.get("DISCORD_AUTH",'').strip()
|
||||||
GIPHY_KEY = environ.get('GIPHY_KEY').strip()
|
GIPHY_KEY = environ.get('GIPHY_KEY').strip()
|
||||||
MASTER_KEY = environ.get("MASTER_KEY")
|
MASTER_KEY = environ.get("MASTER_KEY")
|
||||||
FP = environ.get("FP")
|
FP = environ.get("FP")
|
||||||
|
KOFI_TOKEN = environ.get("KOFI_TOKEN")
|
||||||
|
|
||||||
tiers={
|
tiers={
|
||||||
"(Paypig)": 1,
|
"(Paypig)": 1,
|
||||||
|
|
|
@ -2,7 +2,8 @@ import qrcode
|
||||||
import io
|
import io
|
||||||
import time
|
import time
|
||||||
import math
|
import math
|
||||||
from files.classes.views import ViewerRelationship
|
from files.classes.views import *
|
||||||
|
from files.classes.transactions import *
|
||||||
from files.helpers.alerts import *
|
from files.helpers.alerts import *
|
||||||
from files.helpers.sanitize import *
|
from files.helpers.sanitize import *
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
|
@ -1382,24 +1383,25 @@ def bid_list(v, bid):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/blockers/<uid>")
|
@app.post("/kofi")
|
||||||
@auth_required
|
def kofi():
|
||||||
def blockers_list(v, uid):
|
verification_token = request.values.get('verification_token')
|
||||||
|
if verification_token != KOFI_TOKEN: abort(400)
|
||||||
|
|
||||||
try: uid = int(uid)
|
id = request.values.get('kofi_transaction_id')
|
||||||
except: abort(400)
|
created_utc = time.mktime(time.strptime(request.values.get('timestamp'), "%Y-%m-%dT%H:%M:%SZ"))
|
||||||
|
type = request.values.get('type')
|
||||||
|
amount = int(request.values.get('amount'))
|
||||||
|
email = request.values.get('email')
|
||||||
|
|
||||||
try: page = int(request.values.get("page", 1))
|
transaction = Transaction(
|
||||||
except: page = 1
|
id=id,
|
||||||
|
created_utc=created_utc,
|
||||||
users = g.db.query(User).join(User.blocking).filter(UserBlock.target_id==uid).offset(25 * (page - 1)).limit(26).all()
|
type=type,
|
||||||
|
amount=amount,
|
||||||
next_exists = (len(users) > 25)
|
email=email
|
||||||
users = users[:25]
|
|
||||||
|
|
||||||
return render_template("user_cards.html",
|
|
||||||
v=v,
|
|
||||||
users=users,
|
|
||||||
next_exists=next_exists,
|
|
||||||
page=page,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
g.db.add(transaction)
|
||||||
|
|
||||||
|
return ''
|
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE TABLE public.transactions (
|
||||||
|
id integer PRIMARY KEY,
|
||||||
|
created_utc integer NOT NULL,
|
||||||
|
type character varying(12) NOT NULL,
|
||||||
|
amount integer NOT NULL,
|
||||||
|
email character varying(255) NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX transactions_email_idx ON public.transactions USING btree (email);
|
Loading…
Reference in New Issue