Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit d364a15

Browse files
committed
new alertPlaying event structure & testing options expanded
some/new? alertPlaying events only have an object message and not an array like all other scenarios expanded testing to include the 2 types of alertPlaying expanded test GUi to allow for Payload Count input to be disabled for when its type doesn't support multiple nested event details need config in root for when I debug test, but don't save it to github
1 parent 09258b6 commit d364a15

File tree

9 files changed

+195
-44
lines changed

9 files changed

+195
-44
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ __pycache__
33
currency data cache.json
44
/Logs
55
eventDefinitions.json
6-
/configs
6+
/configs
7+
/config.json

Source/Gui.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,14 @@ def OnTestEventPlatformChanged(self, *args):
175175
def OnTestEventTypeChanged(self, *args):
176176
amountEnabled = False
177177
quantityEnabled = False
178+
payloadCountEnabled = False
178179
if self.selectedTestEventType.get() != self.translations.GetTranslation("Gui SelectTestEventType"):
179180
amountEnabled = self.state.testEventUtils.GetAttribute(self.selectedTestEventPlatform.get(
180181
), self.selectedTestEventType.get(), "valueInput")
181182
quantityEnabled = self.state.testEventUtils.GetAttribute(self.selectedTestEventPlatform.get(
182183
), self.selectedTestEventType.get(), "quantityInput")
184+
payloadCountEnabled = self.state.testEventUtils.GetAttribute(self.selectedTestEventPlatform.get(
185+
), self.selectedTestEventType.get(), "payloadInput")
183186
if amountEnabled:
184187
self.testEventValueLabel.config(state=TK.NORMAL)
185188
self.testEventValueInput.config(state=TK.NORMAL)
@@ -192,6 +195,10 @@ def OnTestEventTypeChanged(self, *args):
192195
else:
193196
self.testEventQuantityLabel.config(state=TK.DISABLED)
194197
self.testEventQuantityInput.config(state=TK.DISABLED)
195-
self.testEventPayloadCountLabel.config(state=TK.NORMAL)
196-
self.testEventPayloadCountInput.config(state=TK.NORMAL)
198+
if payloadCountEnabled:
199+
self.testEventPayloadCountLabel.config(state=TK.NORMAL)
200+
self.testEventPayloadCountInput.config(state=TK.NORMAL)
201+
else:
202+
self.testEventPayloadCountLabel.config(state=TK.DISABLED)
203+
self.testEventPayloadCountInput.config(state=TK.DISABLED)
197204
self.testEventButton.config(state=TK.NORMAL)

Source/Streamlabs Rcon Integration.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,17 @@ def OnTestEventButtonHandler(self):
202202
self.RecordActivity(
203203
self.translations.GetTranslation("TestEvent QuantityCountNotInt") + str(testEventQuantity))
204204
return
205-
testEventPayloadCount = self.gui.testEventPayloadCount.get()
206-
try:
207-
testEventPayloadCount = int(testEventPayloadCount)
208-
if testEventPayloadCount <= 0:
209-
raise ValueError()
210-
except:
211-
self.RecordActivity(
212-
self.translations.GetTranslation("TestEvent PayloadCountNotInt") + str(testEventPayloadCount))
213-
return
205+
testEventPayloadCount = 1
206+
if TestEventUtils.GetAttribute(testEventPlatform, testEventType, "payloadInput"):
207+
try:
208+
testEventPayloadCount = self.gui.testEventPayloadCount.get()
209+
testEventPayloadCount = int(testEventPayloadCount)
210+
if testEventPayloadCount <= 0:
211+
raise ValueError()
212+
except:
213+
self.RecordActivity(
214+
self.translations.GetTranslation("TestEvent PayloadCountNotInt") + str(testEventPayloadCount))
215+
return
214216
testEventArray = self.testEventUtils.GenerateTestEventArray(
215217
testEventPlatform, testEventType, testEventValue, testEventQuantity, testEventPayloadCount)
216218
if len(testEventArray) > 0:

Source/StreamlabsEvent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,12 @@ def GenerateEventPerPayload(state, data):
292292
typeString = data["type"]
293293
else:
294294
typeString = ""
295-
for payload in data["message"]:
295+
# twitch alerts only have a dictionary as message and not an array of dictionaries like all other scenarios
296+
if isinstance(data["message"], dict):
296297
events.append(StreamlabsEvent(
297-
state, platformString, typeString, payload))
298+
state, platformString, typeString, data["message"]))
299+
else:
300+
for payload in data["message"]:
301+
events.append(StreamlabsEvent(
302+
state, platformString, typeString, payload))
298303
return events

Source/TestEvents.py

Lines changed: 107 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,62 @@ class TestEventUtils:
88
"Streamlabs": {
99
"Donation": {
1010
"valueInput": True,
11-
"quantityInput": False
11+
"quantityInput": False,
12+
"payloadInput": True
13+
},
14+
"Alert (IGNORED)": {
15+
"valueInput": False,
16+
"quantityInput": False,
17+
"payloadInput": True
18+
},
19+
"Alert Non List Message (IGNORED)": {
20+
"valueInput": False,
21+
"quantityInput": False,
22+
"payloadInput": False
1223
}
1324
},
1425
"Patreon": {
1526
"Pledge": {
1627
"valueInput": True,
17-
"quantityInput": False
28+
"quantityInput": False,
29+
"payloadInput": True
1830
}
1931
},
2032
"Twitch": {
2133
"Follow": {
2234
"valueInput": False,
23-
"quantityInput": False
35+
"quantityInput": False,
36+
"payloadInput": True
2437
},
2538
"Subscribe": {
2639
"valueInput": True,
27-
"quantityInput": False
40+
"quantityInput": False,
41+
"payloadInput": True
2842
},
2943
"Give Specific Gift Subscription": {
3044
"valueInput": True,
31-
"quantityInput": False
45+
"quantityInput": False,
46+
"payloadInput": True
3247
},
3348
"Give Random Gift Subscriptions": {
3449
"valueInput": True,
35-
"quantityInput": True
50+
"quantityInput": True,
51+
"payloadInput": True
3652
},
3753
"Bits": {
3854
"valueInput": True,
39-
"quantityInput": False
55+
"quantityInput": False,
56+
"payloadInput": True
4057
},
4158
"Host": {
4259
"valueInput": True,
43-
"quantityInput": False
60+
"quantityInput": False,
61+
"payloadInput": True
4462
},
4563
"Raid": {
4664
"valueInput": True,
47-
"quantityInput": False
65+
"quantityInput": False,
66+
"payloadInput": True
4867
}
4968
},
5069
"Youtube": {
@@ -72,6 +91,7 @@ def GenerateTestEvent(eventPlatform, eventType, value, special, payloadCount):
7291
eventTypeString = ""
7392
eventForString = ""
7493
eventMessageConstructor = None
94+
messageIsTypeList = True
7595

7696
if eventPlatform == "Streamlabs":
7797
eventForString = "streamlabs"
@@ -101,6 +121,74 @@ def EventMessageConstructor(value, special, iterator):
101121
'_id': eventId
102122
}
103123
eventMessageConstructor = EventMessageConstructor
124+
elif eventType == "Alert (IGNORED)":
125+
eventTypeString = "alertPlaying"
126+
messageIsTypeList = True
127+
eventForString = ""
128+
129+
def EventMessageConstructor(value, special, iterator):
130+
iterator += 1
131+
eventId = TestEventUtils.GenerateUuid()
132+
return {
133+
'id': eventId,
134+
'name': 'user' + str(iterator),
135+
'_id': eventId,
136+
'event_id': eventId,
137+
'priority': 10,
138+
'from': 'UsEr' + str(iterator),
139+
'to': '',
140+
'message': 'Test Follow Alert',
141+
'repeat': False,
142+
'isTest': True,
143+
'createdAt': '2020-01-13 05:31:35',
144+
'createdAtTimestamp': 1578893495292,
145+
'platform': 'twitch_account',
146+
'type': 'follow',
147+
'hash': 'follow:StReAmEr:',
148+
'read': False,
149+
'wotcCode': None,
150+
'payload': {
151+
'name': 'UsEr' + str(iterator),
152+
'isTest': True,
153+
'_id': eventId,
154+
'priority': 10
155+
}
156+
}
157+
eventMessageConstructor = EventMessageConstructor
158+
elif eventType == "Alert Non List Message (IGNORED)":
159+
eventTypeString = "alertPlaying"
160+
messageIsTypeList = False
161+
eventForString = ""
162+
163+
def EventMessageConstructor(value, special, iterator):
164+
iterator += 1
165+
eventId = TestEventUtils.GenerateUuid()
166+
return {
167+
'id': eventId,
168+
'name': 'user' + str(iterator),
169+
'_id': eventId,
170+
'event_id': eventId,
171+
'priority': 10,
172+
'from': 'UsEr' + str(iterator),
173+
'to': '',
174+
'message': 'Test Follow Alert',
175+
'repeat': False,
176+
'isTest': True,
177+
'createdAt': '2020-01-13 05:31:35',
178+
'createdAtTimestamp': 1578893495292,
179+
'platform': 'twitch_account',
180+
'type': 'follow',
181+
'hash': 'follow:StReAmEr:',
182+
'read': False,
183+
'wotcCode': None,
184+
'payload': {
185+
'name': 'UsEr' + str(iterator),
186+
'isTest': True,
187+
'_id': eventId,
188+
'priority': 10
189+
}
190+
}
191+
eventMessageConstructor = EventMessageConstructor
104192
elif eventPlatform == "Patreon":
105193
eventForString = "patreon"
106194
if eventType == "Pledge":
@@ -257,17 +345,21 @@ def EventMessageConstructor(value, special, iterator):
257345
}
258346
eventMessageConstructor = EventMessageConstructor
259347

260-
return TestEventUtils._ConstructTestEventDict(eventForString, eventTypeString, eventMessageConstructor, value, special, payloadCount)
348+
return TestEventUtils._ConstructTestEventDict(eventForString, eventTypeString, eventMessageConstructor, value, special, payloadCount, messageIsTypeList)
261349

262350
@staticmethod
263-
def _ConstructTestEventDict(forString, typeString, messageConstructor, value, special, payloadCount):
351+
def _ConstructTestEventDict(forString, typeString, messageConstructor, value, special, payloadCount, messageIsTypeList):
264352
eventDict = {
265353
"for": forString,
266-
"type": typeString,
267-
"message": []
354+
"type": typeString
268355
}
269-
for i in range(payloadCount):
270-
eventDict["message"].append(messageConstructor(value, special, i))
356+
if messageIsTypeList:
357+
eventDict["message"] = []
358+
for i in range(payloadCount):
359+
eventDict["message"].append(
360+
messageConstructor(value, special, i))
361+
else:
362+
eventDict["message"] = messageConstructor(value, special, 1)
271363

272364
return eventDict
273365

Source/Translations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def LoadLocalisedTexts(self, language):
3838
"TestEvent InvalidTestEvent": "Invalid Test Event Selection: ",
3939
"TestEvent ValueNotFloat": "Test Event Value isn't a number: ",
4040
"TestEvent PayloadCountNotInt": "Test Event Payload Count not a positive whole number: ",
41-
"TestEvent QuantityCountNotInt": "Test Event Quantity Count not a positive whole number: "
41+
"TestEvent QuantityCountNotInt": "Test Event Quantity Count not a positive whole number: ",
4242
}
4343

4444
def GetTranslation(self, key):

ToDo.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Bugs / Outstanding
22
===================
33

4+
Support multiple rcon commands as an array in JSON.
45

56

67

@@ -13,6 +14,6 @@ Make so that profile startup errors are shown in a GUI and disable running until
1314
Have seperate Activity and System (status, warning, errors) logs
1415
Have a way to pause logs from updating and then resume to allow scrolling
1516
Support multiple calculated values via exec. Array in exec, to numbered strings in action script.
16-
Support multiple rcon commands as an array in JSON.
1717
Handle paused Factorio server accepting but not reply to RCON command. It will honor the command when the server is unpaused. So different between start test connection and event handling.
1818
Add a more complete test GUI with options to select subscription types, donation currencies, etc.
19+
Look at supporting Twitch PubSub directly so I can get the Channel Points. May also open up othe opportunities: https://github.com/twitchdev/pubsub-samples/tree/1638781c0c096c4be43493a86f2a75401256583b/python

0 commit comments

Comments
 (0)