account for azure rate limiting
diff --git a/src/plugins/scanners/ponymail-tone.py b/src/plugins/scanners/ponymail-tone.py
index a056f7f..c027a84 100644
--- a/src/plugins/scanners/ponymail-tone.py
+++ b/src/plugins/scanners/ponymail-tone.py
@@ -115,6 +115,9 @@
mood = plugins.utils.tone.watsonTone(KibbleBit, body)
elif 'azure' in KibbleBit.config:
mood = plugins.utils.tone.azureTone(KibbleBit, body)
+ if mood == False:
+ KibbleBit.pprint("Hit Azure rate limit, not trying further emails for now.")
+ break
eml['mood'] = mood
hm = [0,'unknown']
for m, s in mood.items():
diff --git a/src/plugins/utils/tone.py b/src/plugins/utils/tone.py
index 0ba3ca9..d9741e0 100644
--- a/src/plugins/utils/tone.py
+++ b/src/plugins/utils/tone.py
@@ -111,5 +111,11 @@
mood['neutral'] = max(0, 1 - (abs(val - 0.5) * 2)) # Between 25% and 75% use double the distance to middle.
else:
KibbleBit.pprint("Failed to analyze email body.")
+ # Depending on price tier, Azure will return a 429 if you go too fast.
+ # If we see a statusCode return, let's just stop for now.
+ # Later scans can pick up the slack.
+ if 'statusCode' in jsout:
+ KibbleBit.pprint("Possible rate limiting in place, stopping for now.")
+ return False
return mood
\ No newline at end of file