glados.request module

class glados.request.GladosRequest(route_type: glados.route_type.RouteType, route: str = None, slack_verify: glados.request.SlackVerification = None, bot_name: str = None, json: Union[str, dict] = None, **kwargs)[source]

Bases: object

GLaDOS Request Object. This holds all the data required to process the request.

Parameters
  • route_type (RouteType) – what type of route is this

  • route (str) – what is the route to be called

  • slack_verify (SlackVerification) – slack data used for verifying the request came from Slack

  • bot_name (str) – The name of the bot to send the request to. This is used for select RouteTypes

  • json – the json paylod of the request

  • kwargs

Examples

>>> request = GladosRequest(RouteType.SendMessage, "send_mock", json={"message":"my message"})
>>> print(request.json.message)
my message
>>> try:
...    print(request.json.other_param)
... except AttributeError:
...     print("ERROR")
ERROR
property route

the actual route

If the route automatically prefixed the route with the bot name, it will return the route with the prefix

class glados.request.SlackVerification(data: str, timestamp: str = None, signature: str = None)[source]

Bases: object

An object to hold slack verification data

Parameters
  • data (str) – raw request body. This is used to verify the message is from slack.

  • timestamp (str) – The X-Slack-Request-Timestamp from the headers of the request. This is used to verify the message is from slack.

  • signature (str) – The X-Slack-Signature from the headers of the request. This is used to verify the message is from slack.

property json