mirror of
https://github.com/auricom/home-cluster.git
synced 2025-09-17 18:24:14 +02:00
🔥 archive ankr github-pushover
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
addresses:
|
||||
- address: "0xd14a28667d263efda2033ceb3b466399723c9c9c"
|
||||
memo: "@Defi_Maestro"
|
||||
- address: "0xc880e1befe692db8b1c71357130f25630239e6fc"
|
||||
memo: "@Defi_Maestro2"
|
@@ -1,100 +0,0 @@
|
||||
import requests
|
||||
import psycopg2
|
||||
import yaml
|
||||
import os
|
||||
import json
|
||||
|
||||
# Load configuration
|
||||
with open("config.yaml", "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
# Pushover credentials
|
||||
PUSHOVER_API_URL = "https://api.pushover.net/1/messages.json"
|
||||
PUSHOVER_API_TOKEN = os.environ["PUSHOVER_API_TOKEN"]
|
||||
PUSHOVER_USER_KEY = os.environ["PUSHOVER_USER_KEY"]
|
||||
|
||||
# PostgreSQL connection
|
||||
connection = psycopg2.connect(
|
||||
dbname=os.environ["POSTGRES_DB"],
|
||||
user=os.environ["POSTGRES_USER"],
|
||||
password=os.environ["POSTGRES_PASS"],
|
||||
host=os.environ["POSTGRES_HOST"],
|
||||
port=os.environ.get("POSTGRES_PORT", "5432"),
|
||||
)
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Create the database structure
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS ankr_queries_transactions (
|
||||
id SERIAL PRIMARY KEY,
|
||||
address VARCHAR NOT NULL,
|
||||
tx_hash VARCHAR NOT NULL,
|
||||
blockchain VARCHAR NOT NULL,
|
||||
timestamp VARCHAR NOT NULL
|
||||
);
|
||||
""")
|
||||
connection.commit()
|
||||
|
||||
|
||||
# Send notification using Pushover
|
||||
def send_pushover_notification(title, message):
|
||||
payload = {
|
||||
'token': PUSHOVER_API_TOKEN,
|
||||
'user': PUSHOVER_USER_KEY,
|
||||
'html': 1,
|
||||
'title': title,
|
||||
'message': message
|
||||
}
|
||||
response = requests.post(PUSHOVER_API_URL, data=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
# Process new transactions
|
||||
def process_new_transactions(address, memo):
|
||||
|
||||
url = "https://rpc.ankr.com/multichain/?ankr_getTransactionsByAddress"
|
||||
headers = {"Content-Type": "application/json"}
|
||||
payload = {
|
||||
"id": 1,
|
||||
"jsonrpc": "2.0",
|
||||
"method": "ankr_getTransactionsByAddress",
|
||||
"params": {
|
||||
"address": f"{address}",
|
||||
"descOrder": True
|
||||
}
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
||||
if response.status_code != 200:
|
||||
print(f"Failed to fetch transactions: {response.text}")
|
||||
return
|
||||
|
||||
for tx in response.json()["result"]["transactions"]:
|
||||
tx_hash = tx['hash']
|
||||
timestamp = tx['timestamp']
|
||||
blockchain = tx['blockchain']
|
||||
|
||||
cursor.execute("""
|
||||
SELECT COUNT(*) FROM ankr_queries_transactions WHERE address=%s AND tx_hash=%s AND blockchain=%s;
|
||||
""", (address, tx_hash, blockchain))
|
||||
exists = cursor.fetchone()[0]
|
||||
|
||||
if not exists:
|
||||
cursor.execute("""
|
||||
INSERT INTO ankr_queries_transactions (address, tx_hash, blockchain, timestamp)
|
||||
VALUES (%s, %s, %s, %s);
|
||||
""", (address, tx_hash, blockchain, timestamp))
|
||||
connection.commit()
|
||||
|
||||
send_pushover_notification(
|
||||
f"New Transaction: {memo}",
|
||||
f"Transaction Hash: <a href=\"http://www.debank.com/profile/{address}/history\">{tx_hash}</a><br>Blockchain: {blockchain}<br>Timestamp: {timestamp}"
|
||||
)
|
||||
|
||||
# Main function
|
||||
def main():
|
||||
for entry in config["addresses"]:
|
||||
address = entry["address"]
|
||||
memo = entry["memo"]
|
||||
process_new_transactions(address, memo)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -1,69 +0,0 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/helmrelease-helm-v2beta1.json
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: &app pushover-notifier-ankr-queries
|
||||
namespace: default
|
||||
spec:
|
||||
interval: 30m
|
||||
chart:
|
||||
spec:
|
||||
chart: app-template
|
||||
version: 1.5.1
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: bjw-s
|
||||
namespace: flux-system
|
||||
maxHistory: 2
|
||||
install:
|
||||
createNamespace: true
|
||||
remediation:
|
||||
retries: 3
|
||||
upgrade:
|
||||
cleanupOnFail: true
|
||||
remediation:
|
||||
retries: 3
|
||||
uninstall:
|
||||
keepHistory: false
|
||||
values:
|
||||
controller:
|
||||
type: cronjob
|
||||
cronjob:
|
||||
concurrencyPolicy: Forbid
|
||||
schedule: "*/30 * * * *"
|
||||
01-init-db:
|
||||
image: ghcr.io/auricom/postgres-init:15.4
|
||||
imagePullPolicy: IfNotPresent
|
||||
envFrom: &envFrom
|
||||
- secretRef:
|
||||
name: pushover-notifier-secret
|
||||
image:
|
||||
repository: ghcr.io/auricom/python
|
||||
tag: 1.0.0@sha256:d22581793a6803cabcb283ec1f224fe2bdd98efb5d837ad14c52b8d99c0d8c1e
|
||||
command:
|
||||
- python3
|
||||
- /app/script.py
|
||||
service:
|
||||
main:
|
||||
enabled: false
|
||||
envFrom: *envFrom
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 250Mi
|
||||
limits:
|
||||
memory: 250Mi
|
||||
persistence:
|
||||
config:
|
||||
enabled: true
|
||||
type: configMap
|
||||
name: pushover-notifier-ankr-queries-configmap
|
||||
mountPath: /app/config.yaml
|
||||
subPath: config.yaml
|
||||
script:
|
||||
enabled: true
|
||||
type: configMap
|
||||
name: pushover-notifier-ankr-queries-configmap
|
||||
mountPath: /app/script.py
|
||||
subPath: script.py
|
@@ -1,14 +0,0 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/kustomization.json
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: default
|
||||
resources:
|
||||
- ./helmrelease.yaml
|
||||
configMapGenerator:
|
||||
- name: pushover-notifier-ankr-queries-configmap
|
||||
files:
|
||||
- ./config/config.yaml
|
||||
- ./config/script.py
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
@@ -1,33 +0,0 @@
|
||||
# yamllint disable
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: pushover-notifier-ankr-queries-secret
|
||||
namespace: default
|
||||
type: Opaque
|
||||
stringData:
|
||||
POSTGRES_DB: ENC[AES256_GCM,data:QTTAnp99RU4DhC3mn9IUaTw=,iv:VP6oHP3N9mG9TboqQ9jbIUlK+CoVqxWXFIus692bw/I=,tag:Y0CAs3yH4OM+rZlmqYJTfg==,type:str]
|
||||
POSTGRES_USER: ENC[AES256_GCM,data:wtl7bwSp2EMTwUsA8MzhTXQ=,iv:RccrE8s7XNtNwF2z59BD36GEPmbEw6n6xPVPuS+/6oE=,tag:2xaXDK1cR3KXkljdQtHVNQ==,type:str]
|
||||
POSTGRES_PASS: ENC[AES256_GCM,data:HifiMzAawK0mls6hrE58j2c23lc=,iv:O59tbU+JN4LAfuhLo+4y+AJx7ZrTPWPxPX9QtGLFvYQ=,tag:xtdaVNj6D0Wr/Ven+p8tJg==,type:str]
|
||||
PUSHOVER_API_TOKEN: ENC[AES256_GCM,data:waPntuH+JjGBr2t9I4U9D/llZC9KW/QyyMUu3EHH,iv:NU6/tbrYRoUSME5ecachU0LDNsz7W31DkEw1S8fSIqw=,tag:YbmZbOOn81+kkGb4Sf2Q2w==,type:str]
|
||||
PUSHOVER_USER_KEY: ENC[AES256_GCM,data:zgoGVo8k7xjuT0+W5AyAkGtJpmTkplW3wmAWqZrY,iv:8ZYZT1I7EOK2mfvjSY+4RfRHQeczYmxihfDHcjRpUSI=,tag:Vkq+ny1eVmAOHmBiAutuNg==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
age:
|
||||
- recipient: age1hhurqwmfvl9m3vh3hk8urulfzcdsrep2ax2neazqt435yhpamu3qj20asg
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBJaU16anJNV2pBZmxPR3h2
|
||||
bWREUnpjcTFvd05ZQ2E4VVBDdm1FL2k4WEYwCkdQSStTNWtpdjNkUW51WS9MekdC
|
||||
VkpTUUFjSjY2a1JMOUtqOVh5M0JRR2sKLS0tIDRmcWpJSEVvaUp4U1lsaTZYZGNw
|
||||
OGVKWU0zNUZJSFh4aFJxQWFsYm1VeFkKaDeI/hl7z0Qh8t5W39Kxu9ert1dt4xo+
|
||||
LX+MjpVqxiZNcfwROD4bkWeQSN+VsxoGOOyj4L15BlggNnlg+L7Hww==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2023-03-18T15:36:57Z"
|
||||
mac: ENC[AES256_GCM,data:L1q6+ngZzlrpCreFyBaOCik7v3JoTrNJekv2gxsIynaMQuFTtHVGx8/+m2UvEmt3Upc8tbN6N3JYIxoske91EI2mEuv3DEJPBmHcWtuQ/eXyd5E0kowqobasdnTJHGSo7ym2I0BsbYM4v4ZJj83Zm9fUigjRP874N/QCbs829/A=,iv:xO/iVXiWzbATJNUvyOLkQMt++rK837n+iygS9aWBKrE=,tag:eLMaq/VvvKM65JRNlxtEng==,type:str]
|
||||
pgp: []
|
||||
encrypted_regex: ^(data|stringData)$
|
||||
version: 3.7.3
|
@@ -4,6 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: default
|
||||
resources:
|
||||
- ./ankr-queries
|
||||
- ./externalsecret.yaml
|
||||
- ./github-releases
|
||||
|
Reference in New Issue
Block a user