How to use the pypresence.response.Response function in pypresence

To help you get started, we’ve selected a few pypresence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qwertyquerty / pypresence / pypresence / activity.py View on Github external
def __init__(self, client: Presence, pid: int = os.getpid(),
                 state: str = None, details: str = None,
                 start: int = None, end: int = None,
                 large_image: str = None, large_text: str = None,
                 small_image: str = None, small_text: str = None,
                 party_id: str = None, party_size: list = None,
                 join: str = None, spectate: str = None,
                 match: str = None, instance: bool = True):

        self.payload = Payload.set_activity(pid, state, details, start, end, large_image, large_text,
                                            small_image, small_text, party_id, party_size, join, spectate,
                                            match, instance, _rn=False)

        self.p_properties = ('pid', 'state', 'details', 'start', 'end', 'large_image', 'large_text', 'small_image', 'small_text', 'party_id', 'party_size', 'join', 'spectate', 'match', 'instance')
        self.response = Response.from_dict(self.payload.data)

        if not isinstance(client, Presence):
            raise NotImplementedError
        self.client = client
github qwertyquerty / pypresence / pypresence / baseclient.py View on Github external
async def read_output(self):
        try:
            data = await self.sock_reader.read(1024)
        except BrokenPipeError:
            raise InvalidID
        status_code, length = struct.unpack('
github qwertyquerty / pypresence / pypresence / response.py View on Github external
def from_dict(cls, from_dict: dict, status_code=None):

        if not isinstance(from_dict, dict):
            raise ValueError("Expected type 'dict' got type '{}' ".format(type(from_dict)))

        for key, value in from_dict.items():
            if isinstance(value, dict):
                value = Response.from_dict(value)
            setattr(cls, key, value)

        cls._dict = from_dict

        return cls(list(from_dict.keys()), status_code)
github qwertyquerty / pypresence / pypresence / response.py View on Github external
def set_prop(self, name, value):
        for n in self.properties:
            if n == name:
                setattr(self,name,value)
                break
            elif isinstance(getattr(self, n), Response):
                getattr(self, n).set_prop(name,value)