Allow spaces in signal name

This commit is contained in:
Mark Veidemanis 2022-12-06 19:59:10 +00:00
parent 3b3faecdf1
commit 6a549f3fd7
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 9 additions and 3 deletions

View File

@ -89,9 +89,15 @@ class HookAPI(APIView):
return HttpResponseBadRequest("Hook does not exist.") return HttpResponseBadRequest("Hook does not exist.")
# Try getting the signal # Try getting the signal
# AUCAD 3M StochExit: C$2419.64 at OANDA # AUCAD 3M Stoch Exit: C$2419.64 at OANDA
message_first_half = hook_resp.message.split(":")[0] # >>> a.split(":")[0:]
signal_name = message_first_half.split(" ")[-1] # ['AUCAD 3M Stoch Exit', ' C$2419.64 at OANDA']
# >>> a.split(":")[0].split(" ")[2:]
# ['Stoch', 'Exit']
# >>> " ".join(a.split(":")[0].split(" ")[2:])
# 'Stoch Exit'
signal_name = " ".join(hook_resp.message.split(":")[0].split(" ")[2:])
try: try:
signal = Signal.objects.get(signal=signal_name) signal = Signal.objects.get(signal=signal_name)
except Signal.DoesNotExist: except Signal.DoesNotExist: