-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClipBoardPoster.py
More file actions
47 lines (41 loc) · 1.45 KB
/
ClipBoardPoster.py
File metadata and controls
47 lines (41 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
import pyperclip
import time
import threading
import queue
zkill = 'https://zkillboard.com/post/'
killmail_esi = 'https://esi.evetech.net/v1/killmails/'
post_queue = queue.Queue()
def monitor_clipboard():
recent_value = pyperclip.paste()
while True:
clipboard = pyperclip.paste()
if clipboard != recent_value:
recent_value = clipboard
if clipboard.startswith(killmail_esi):
print(f'New killmail Detected: {clipboard}')
post_queue.put(clipboard)
time.sleep(0.1)
def process_queue():
while True:
clipboard = post_queue.get()
try:
print(f'POST: {clipboard}')
response = requests.post(zkill, data={'killmailurl': clipboard})
if response.status_code == 200:
print('POST succeeded: DONE')
else:
print(f'POST failed with status {response.status_code}')
except requests.exceptions.RequestException as e:
print(f'Error posting killmail: {e}')
finally:
post_queue.task_done()
def main():
clipboard_thread = threading.Thread(target=monitor_clipboard, daemon=True)
clipboard_thread.start()
processing_thread = threading.Thread(target=process_queue, daemon=True)
processing_thread.start()
clipboard_thread.join()
processing_thread.join()
if __name__ == '__main__':
main()