Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • Client Help

How to handle GRID Support notifications automatically in your code

Article 4046883, Status: VALIDATED

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Client Help
  • Sky's The Limit - Cloud9 x JetBrains Hackathon
+ More

Table of Contents

❓ Issue/Question 🖥️ Environment/Context 👌 Resolution/Answer Python example 🗒️Scratch Pad

❓ Issue/Question

  • How can I parse GRID ops channel messages automatically?
  • How do I extract the JSON from a GRID Support notification?
  • Can I handle GRID notifications programmatically instead of reading them?

🖥️ Environment/Context

  • GRID Support notifications in your dedicated ops channel

👌 Resolution/Answer

  1. Take the full message text.
  2. Find the last line that starts with {. The JSON block starts there and runs to the end of the message.
  3. Parse it as JSON.
  4. Branch on grid_event, and use seriesID to match the notification to the series in your system.
  5. Read optional keys only if they are present. Only grid_event, seriesID, match and tournament are always there.

 

Python example 

import json

def parse_grid_notification(text: str) -> dict:
    start = text.rfind("\n{")
    if start == -1:
        raise ValueError("No JSON block found")
    return json.loads(text[start + 1:])

event = parse_grid_notification(message_text)

if event["grid_event"] == "Series_Recreation":
    link_series(event["seriesID"], event.get("new_seriesID"))
elif event["grid_event"] in ("Reschedule", "Reschedule_Unkown_Date"):
    update_schedule(event["seriesID"], event.get("new_date"), event.get("new_time"))
  • link_series and update_schedule stand in for your own functions.
  • Handle grid_event values you don't recognise without failing, so a new notification type can't break your integration.
 
 

🗒️Scratch Pad

For the keys and all grid_event values, see How to read the JSON in GRID Support notifications and How to tell why GRID Support sent a notification (grid_event values).

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How to handle rolling starts in Series Events?
  • Can I get a list of series that are currently live?
  • What are the rate limits for our products?
  • What's the difference between actor-destroyed-target and actor-completed-destroy[target] events in the Series Events API?
  • Why is netWorth on GRID's API different from the net worth (total gold) value on the broadcast? (LoL)
Privacy Policy
Esports Players Privacy Notice
Imprint
Careers
GRID® 2022 | All Rights Reserved
Expand