-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieAnnouncer.py
124 lines (100 loc) · 5.52 KB
/
MovieAnnouncer.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from PyQt6 import QtWidgets, QtGui, QtCore
import sys
import requests
from dotenv import load_dotenv
import os
# Check the .env file to configure it the way you want. I have set an example usage, but you can customize it completely
load_dotenv()
class MovieBotApp(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle(os.getenv("UI_TITLE"))
self.setGeometry(100, 100, 600, 500)
self.setStyleSheet("background-color: #070e12;")
layout = QtWidgets.QVBoxLayout()
# Title
self.title_label = QtWidgets.QLabel(os.getenv("UI_TITLE"))
self.title_label.setStyleSheet("color: white; font-size: 16px; font-weight: bold; margin-bottom: 20px;")
self.title_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
layout.addWidget(self.title_label)
form_layout = QtWidgets.QFormLayout()
form_layout.setHorizontalSpacing(20)
form_layout.setVerticalSpacing(15)
# FIELD1
self.field1_label = QtWidgets.QLabel(os.getenv("FIELD1_TITLE"))
self.field1_label.setStyleSheet("color: white;")
self.field1_input = QtWidgets.QLineEdit()
self.field1_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.field1_label, self.field1_input)
# INLINE1
self.inline1_label = QtWidgets.QLabel(os.getenv("INLINE1_TITLE"))
self.inline1_label.setStyleSheet("color: white;")
self.inline1_input = QtWidgets.QLineEdit()
self.inline1_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.inline1_label, self.inline1_input)
# INLINE2
self.inline2_label = QtWidgets.QLabel(os.getenv("INLINE2_TITLE"))
self.inline2_label.setStyleSheet("color: white;")
self.inline2_input = QtWidgets.QLineEdit()
self.inline2_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.inline2_label, self.inline2_input)
# FIELD4
self.field4_label = QtWidgets.QLabel(os.getenv("FIELD4_TITLE"))
self.field4_label.setStyleSheet("color: white;")
self.field4_input = QtWidgets.QTextEdit()
self.field4_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.field4_label, self.field4_input)
# FIELD3
self.field3_label = QtWidgets.QLabel(os.getenv("FIELD3_TITLE"))
self.field3_label.setStyleSheet("color: white;")
self.field3_input = QtWidgets.QLineEdit()
self.field3_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.field3_label, self.field3_input)
# IMG
self.main_image_label = QtWidgets.QLabel("Main Image URL")
self.main_image_label.setStyleSheet("color: white;")
self.main_image_input = QtWidgets.QLineEdit()
self.main_image_input.setStyleSheet("background-color: #0c1a20; color: white; border: 1px solid #1e2a30; padding: 5px; border-radius: 5px;")
form_layout.addRow(self.main_image_label, self.main_image_input)
layout.addLayout(form_layout)
self.submit_button = QtWidgets.QPushButton("Send to Discord")
self.submit_button.setStyleSheet(
"background-color: #1e2a30; color: white; border: 1px solid #1e2a30; padding: 10px; margin-top: 20px; border-radius: 5px; cursor: pointer;"
)
self.submit_button.clicked.connect(self.send_to_discord)
layout.addWidget(self.submit_button, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
self.setLayout(layout)
def send_to_discord(self):
webhook_url = os.getenv("WEBHOOK_URL")
title = os.getenv("TITLE1")
additional_content = self.field4_input.toPlainText().strip()
additional_field = {"name": os.getenv("FIELD4_TITLE"), "value": additional_content, "inline": False} if additional_content else None
fields = [
{"name": os.getenv("FIELD1_TITLE"), "value": self.field1_input.text(), "inline": False},
{"name": os.getenv("INLINE1_TITLE"), "value": self.inline1_input.text(), "inline": True},
{"name": os.getenv("INLINE2_TITLE"), "value": self.inline2_input.text(), "inline": True},
{"name": os.getenv("FIELD3_TITLE"), "value": self.field3_input.text(), "inline": False}
]
if additional_field:
fields.append(additional_field)
data = {
"embeds": [
{
"title": title,
"color": 0x10d0e6,
"fields": fields,
"thumbnail": {"url": os.getenv("AUTHOR_IMAGE_URL")},
"image": {"url": self.main_image_input.text()}
}
]
}
response = requests.post(webhook_url, json=data)
if response.status_code == 204:
QtWidgets.QMessageBox.information(self, "Success", "Announcement sent successfully!")
else:
QtWidgets.QMessageBox.critical(self, "Error", f"Failed to send announcement. Status Code: {response.status_code}")
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MovieBotApp()
window.show()
sys.exit(app.exec())