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

Commit 51e93ac

Browse files
committed
Merge branch '0.1.2'
2 parents f96e079 + c553420 commit 51e93ac

12 files changed

+300
-225
lines changed

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"configurations": [
77
{
88
"name": "Streamlabs Rcon Integration",
9+
"preLaunchTask": "Build Debug Files",
910
"type": "python",
1011
"request": "launch",
1112
"program": "${workspaceFolder}/Source/Streamlabs Rcon Integration.py"

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"python.pythonPath": "D:\\Applications\\Python37-32\\python.exe"
2+
"python.defaultInterpreterPath": "D:\\Applications\\Python37-32\\python.exe"
33
}

.vscode/tasks.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Build Debug Files",
8+
"type": "shell",
9+
"command": "Copy-Item 'Source\\eventDefinitions.json'",
10+
"problemMatcher": [],
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
}
15+
}
16+
]
17+
}

Profiles/Factorio - Advanced Usage Example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"filteredActions": [
2020
{
2121
"condition": "[ALL]",
22-
"manipulator": "'[gifter_display_name]'",
22+
"manipulator": "'[gifter]'",
2323
"action": "[ACTION_SubscriptionBy]"
2424
}
2525
]

Profiles/Factorio - Print Most Fancy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{
4242
"condition": "[VALUE] >= 5",
4343
"manipulator": "",
44-
"action": "Thanks [gifter_display_name] for subscribing [display_name]"
44+
"action": "Thanks [gifter] for subscribing [display_name]"
4545
},
4646
{
4747
"condition": "[VALUE] < 5",

Source/Streamlabs Rcon Integration.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class State():
1818
def __init__(self):
19-
self.version = "0.1.1"
19+
self.version = "0.1.2"
2020
self.config = Config(self)
2121
self.logging = Logging(self)
2222
self.config.LogMissingSettings()
@@ -212,11 +212,9 @@ def OnTestEventButtonHandler(self):
212212
if testEventPayloadCount <= 0:
213213
raise ValueError()
214214
except:
215-
self.RecordActivity(
216-
self.translations.GetTranslation("TestEvent PayloadCountNotInt") + str(testEventPayloadCount))
215+
self.RecordActivity(self.translations.GetTranslation("TestEvent PayloadCountNotInt") + str(testEventPayloadCount))
217216
return
218-
testEventArray = self.testEventUtils.GenerateTestEventArray(
219-
testEventPlatform, testEventType, testEventValue, testEventQuantity, testEventPayloadCount)
217+
testEventArray = self.testEventUtils.GenerateTestEventArray(testEventPlatform, testEventType, testEventValue, testEventQuantity, testEventPayloadCount)
220218
if len(testEventArray) > 0:
221219
for testEvent in testEventArray:
222220
self.OnStreamlabsEventHandler(testEvent)
@@ -249,11 +247,11 @@ def Run(self):
249247
state.Run()
250248
except Exception as ex:
251249
try:
252-
self.streamlabs.Disconnect()
250+
state.streamlabs.Disconnect()
253251
except:
254252
pass
255253
try:
256-
self.logging.RecordException(
254+
state.logging.RecordException(
257255
ex, "Application Critical Error - Application has been stopped")
258256
except:
259257
pass

Source/StreamlabsEvent.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, state, platformString, typeString, payload):
2121
self.ignored = False
2222
self.rawMessage = payload
2323

24-
if "_id" in self.rawMessage:
24+
if "_id" in self.rawMessage.keys():
2525
self.id = self.rawMessage["_id"]
2626

2727
if self.type == "donation" and self.platform == "":
@@ -92,7 +92,7 @@ def ShouldIgnoreEvent(self):
9292
if self.state.profiles.currentProfile.options.twitchMysterSubGiftMode == "receiver" and self.type == "subMysteryGift":
9393
return True
9494
elif self.state.profiles.currentProfile.options.twitchMysterSubGiftMode == "donator" and self.type == "subscriptionGift":
95-
gifterName = self.rawMessage["gifter_display_name"]
95+
gifterName = self.rawMessage["gifter"]
9696
if gifterName in self.state.mysterySubGifts and self.state.mysterySubGifts[gifterName] > 0:
9797
self.state.mysterySubGifts[gifterName] -= 1
9898
return True
@@ -105,16 +105,25 @@ def ShouldIgnoreEvent(self):
105105
def PopulateNormalisedData(self):
106106
if (self.handlerName == "streamlabs-donation"):
107107
self.valueType = "money"
108-
self.value = self.state.currency.GetNormalisedValue(
109-
self.rawMessage["currency"], float(self.rawMessage["amount"]))
108+
if "currency" in self.rawMessage.keys():
109+
currency = self.rawMessage["currency"]
110+
else:
111+
currency = "USD"
112+
self.value = self.state.currency.GetNormalisedValue(currency, float(self.rawMessage["amount"]))
110113
elif (self.handlerName == "patreon-pledge"):
111114
self.valueType = "money"
112-
self.value = self.state.currency.GetNormalisedValue(
113-
self.rawMessage["currency"], float(self.rawMessage["amount"]))
115+
if "currency" in self.rawMessage.keys():
116+
currency = self.rawMessage["currency"]
117+
else:
118+
currency = "USD"
119+
self.value = self.state.currency.GetNormalisedValue(currency, float(self.rawMessage["amount"]))
114120
elif (self.handlerName == "youtube_account-superchat"):
115121
self.valueType = "money"
116-
self.value = self.state.currency.GetNormalisedValue(
117-
self.rawMessage["currency"], float(self.rawMessage["amount"])/1000000)
122+
if "currency" in self.rawMessage.keys():
123+
currency = self.rawMessage["currency"]
124+
else:
125+
currency = "USD"
126+
self.value = self.state.currency.GetNormalisedValue(currency, float(self.rawMessage["amount"])/1000000)
118127
elif (self.handlerName == "twitch_account-bits"):
119128
self.valueType = "money"
120129
self.value = round(float(self.rawMessage["amount"]) / 100, 2)
@@ -125,8 +134,7 @@ def PopulateNormalisedData(self):
125134
if subValue != None:
126135
self.value = subValue
127136
else:
128-
self.state.RecordActivity(
129-
self.state.translations.GetTranslation("StreamlabsEvent UnrecognisedTwitchSubscriptionType") + subPlan)
137+
self.state.RecordActivity(self.state.translations.GetTranslation("StreamlabsEvent UnrecognisedTwitchSubscriptionType") + subPlan)
130138
return False
131139
elif (self.handlerName == "twitch_account-subMysteryGift"):
132140
self.bestName = self.rawMessage["gifter_display_name"]
@@ -137,8 +145,7 @@ def PopulateNormalisedData(self):
137145
if subValue != None:
138146
self.value = subValue * amount
139147
else:
140-
self.state.RecordActivity(
141-
self.state.translations.GetTranslation("StreamlabsEvent UnrecognisedTwitchSubscriptionType") + subPlan)
148+
self.state.RecordActivity(self.state.translations.GetTranslation("StreamlabsEvent UnrecognisedTwitchSubscriptionType") + subPlan)
142149
return False
143150
self.state.mysterySubGifts[self.bestName] = amount
144151
elif (self.handlerName == "youtube_account-subscription"):
@@ -244,8 +251,7 @@ def IsBadEventAttritubeUsed(eventType, string, calcValueAllowed):
244251
def IsScriptValid(scriptString):
245252
if scriptString in ["", "[ALL]", "[NOTHING]"]:
246253
return ""
247-
instances = StreamlabsEventUtils.FindAttributeTagsInString(
248-
scriptString)
254+
instances = StreamlabsEventUtils.FindAttributeTagsInString(scriptString)
249255
testScriptString = scriptString
250256
for instance in instances:
251257
testScriptString = testScriptString.replace(instance, str(1))
@@ -280,8 +286,7 @@ def GetTwitchSubscriptionValue(subPlan):
280286
@staticmethod
281287
def GenerateEventPerPayload(state, data):
282288
if "message" not in data:
283-
state.RecordActivity(
284-
state.translations.GetTranslation("StreamlabsEvent MissingEventPayloadCount"))
289+
state.RecordActivity(state.translations.GetTranslation("StreamlabsEvent MissingEventPayloadCount"))
285290
return None
286291
events = []
287292
if "for" in data:
@@ -294,10 +299,8 @@ def GenerateEventPerPayload(state, data):
294299
typeString = ""
295300
# twitch alerts only have a dictionary as message and not an array of dictionaries like all other scenarios
296301
if isinstance(data["message"], dict):
297-
events.append(StreamlabsEvent(
298-
state, platformString, typeString, data["message"]))
302+
events.append(StreamlabsEvent(state, platformString, typeString, data["message"]))
299303
else:
300304
for payload in data["message"]:
301-
events.append(StreamlabsEvent(
302-
state, platformString, typeString, payload))
305+
events.append(StreamlabsEvent(state, platformString, typeString, payload))
303306
return events

0 commit comments

Comments
 (0)