v1
This commit is contained in:
commit
3be3bdbb5d
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# BloatProject
|
||||
|
||||
Syncro de notification mon phone et mon pc + up checker
|
49
client.py
Normal file
49
client.py
Normal file
@ -0,0 +1,49 @@
|
||||
import pyperclip
|
||||
import socketio
|
||||
import os
|
||||
import subprocess
|
||||
# standard Python
|
||||
|
||||
# to put in a conf file
|
||||
ip = 'simailadjalim.fr'
|
||||
port = "9564"
|
||||
hostname = "WarMachine"
|
||||
logfilepath = "./logs.txt"
|
||||
|
||||
"""
|
||||
This script is a daemon that, on event, send and sync the clipboard with a distant one
|
||||
"""
|
||||
|
||||
def dechiffreCePutainDeMessage(message : str) -> str:
|
||||
"""
|
||||
"""
|
||||
|
||||
|
||||
ip = f"http://{ip}:{port}/"
|
||||
print(ip)
|
||||
sio = socketio.Client()
|
||||
sio.connect(ip)
|
||||
print("[Debug] Connected to Server .w.")
|
||||
|
||||
def sendSystemNotification(title:str,content:str):
|
||||
"""
|
||||
Une fonction pour 1. rendre le truc plus secure et
|
||||
eviter que thomas face des rce sur mon pc .w. lmao
|
||||
"""
|
||||
subprocess.run(["notify-send",title,content])
|
||||
|
||||
@sio.event
|
||||
def clip(data):
|
||||
content = data["content"]
|
||||
clipCmd = f'echo {content} | xclip'
|
||||
print(f"[ClipEvent] received data from ")
|
||||
os.system(clipCmd)
|
||||
|
||||
@sio.event
|
||||
def notify(data):
|
||||
title, content = data["title"], data["content"]
|
||||
command = f'notify-send "{title}" "{content}"'
|
||||
print(command)
|
||||
os.system(command)
|
||||
|
||||
sio.wait()
|
38
serveur.py
Normal file
38
serveur.py
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/python
|
||||
from flask import Flask, request, render_template, json, jsonify
|
||||
import flask_socketio
|
||||
# base socket
|
||||
|
||||
app = Flask(__name__)
|
||||
socketio = flask_socketio.SocketIO(app)
|
||||
|
||||
|
||||
@app.route("/notify", methods=['POST'])
|
||||
def notify():
|
||||
"""
|
||||
Le but de cet app se resume a cette fonction, elle recoit une requette http et renvoie via le websocket
|
||||
le contenu de la requette a tout les client.
|
||||
"""
|
||||
data = {}
|
||||
data["ip"] = request.remote_addr
|
||||
print(request.remote_addr)
|
||||
data['title'] = request.form['title']
|
||||
data['content'] = request.form['content']
|
||||
print(f"""[Debug] Sending to all clients notification event""")
|
||||
socketio.emit("notify", data, broadcast=True)
|
||||
return "true" , 200
|
||||
|
||||
@app.route("/clip", methods=['POST'])
|
||||
def clip():
|
||||
"""
|
||||
pareil qu'en haut mais pour le clipboard .w.
|
||||
"""
|
||||
data = {}
|
||||
data["ip"] = request.remote_addr
|
||||
data['content'] = request.form['content']
|
||||
print(f"""[Debug] Sending to all clients clipboard event""")
|
||||
socketio.emit("clip", data, broadcast=True)
|
||||
return "true" , 200
|
||||
|
||||
if __name__ == '__main__':
|
||||
socketio.run(app, host="0.0.0.0", port = 9564)
|
Loading…
Reference in New Issue
Block a user