@@ -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