lynxpresence 4.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lynxpresence might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 qwertyquerty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: lynxpresence
3
+ Version: 4.4.0
4
+ Summary: Discord RPC client written in Python
5
+ Home-page: https://github.com/C0rn3j/pypresence
6
+ Author: C0rn3j
7
+ License: MIT
8
+ Keywords: discord rich presence pypresence rpc api wrapper gamers chat irc
9
+ Platform: Windows
10
+ Platform: Linux
11
+ Platform: OSX
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS :: MacOS X
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Typing :: Typed
26
+ Classifier: Intended Audience :: Developers
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Software Development :: Libraries
29
+ Classifier: Topic :: Communications :: Chat
30
+ Classifier: Framework :: AsyncIO
31
+ Requires-Python: >=3.9
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Dynamic: author
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: license
41
+ Dynamic: license-file
42
+ Dynamic: platform
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ Forked as upstream did not make a release in quite a while, I hope to kill this fork off in the future.
47
+
48
+ > A Discord Rich Presence Client in Python? Looks like you've come to the right place.
49
+ ![PyPI](https://img.shields.io/pypi/v/lynxpresence.svg?style=for-the-badge)
50
+
51
+ ----------
52
+
53
+ # Installation
54
+
55
+ Install pypresence with **`pip`**
56
+
57
+ For the latest development version:
58
+
59
+ ### `pip install https://github.com/C0rn3j/pypresence/archive/master.zip`
60
+
61
+ For the latest stable version:
62
+
63
+ ### `pip install lynxpresence`
64
+
65
+ ----------
66
+
67
+ # Documentation
68
+
69
+ > [!Note]
70
+ > You need an **authorized app** to do anything besides rich presence!
71
+
72
+ #### [pypresence Documentation](https://qwertyquerty.github.io/pypresence/html/index.html)
73
+ #### [Discord Rich Presence Documentation](https://discord.com/developers/docs/rich-presence/how-to)
74
+ #### [Discord RPC Documentation](https://discord.com/developers/docs/topics/rpc)
75
+ #### [pyresence Discord Support Server](https://discord.gg/JF3kg77)
76
+ #### [Discord API Support Server](https://discord.gg/discord-api)
77
+
78
+ ----------
79
+
80
+ # Examples
81
+
82
+ Examples can be found in the [examples](https://github.com/C0rn3j/pypresence/tree/master/examples) directory, and you can contribute your own examples if you wish, just read [examples.md](https://github.com/C0rn3j/pypresence/blob/master/examples/examples.md)!
@@ -0,0 +1,37 @@
1
+ Forked as upstream did not make a release in quite a while, I hope to kill this fork off in the future.
2
+
3
+ > A Discord Rich Presence Client in Python? Looks like you've come to the right place.
4
+ ![PyPI](https://img.shields.io/pypi/v/lynxpresence.svg?style=for-the-badge)
5
+
6
+ ----------
7
+
8
+ # Installation
9
+
10
+ Install pypresence with **`pip`**
11
+
12
+ For the latest development version:
13
+
14
+ ### `pip install https://github.com/C0rn3j/pypresence/archive/master.zip`
15
+
16
+ For the latest stable version:
17
+
18
+ ### `pip install lynxpresence`
19
+
20
+ ----------
21
+
22
+ # Documentation
23
+
24
+ > [!Note]
25
+ > You need an **authorized app** to do anything besides rich presence!
26
+
27
+ #### [pypresence Documentation](https://qwertyquerty.github.io/pypresence/html/index.html)
28
+ #### [Discord Rich Presence Documentation](https://discord.com/developers/docs/rich-presence/how-to)
29
+ #### [Discord RPC Documentation](https://discord.com/developers/docs/topics/rpc)
30
+ #### [pyresence Discord Support Server](https://discord.gg/JF3kg77)
31
+ #### [Discord API Support Server](https://discord.gg/discord-api)
32
+
33
+ ----------
34
+
35
+ # Examples
36
+
37
+ Examples can be found in the [examples](https://github.com/C0rn3j/pypresence/tree/master/examples) directory, and you can contribute your own examples if you wish, just read [examples.md](https://github.com/C0rn3j/pypresence/blob/master/examples/examples.md)!
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.4
2
+ Name: lynxpresence
3
+ Version: 4.4.0
4
+ Summary: Discord RPC client written in Python
5
+ Home-page: https://github.com/C0rn3j/pypresence
6
+ Author: C0rn3j
7
+ License: MIT
8
+ Keywords: discord rich presence pypresence rpc api wrapper gamers chat irc
9
+ Platform: Windows
10
+ Platform: Linux
11
+ Platform: OSX
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS :: MacOS X
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3 :: Only
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Typing :: Typed
26
+ Classifier: Intended Audience :: Developers
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Software Development :: Libraries
29
+ Classifier: Topic :: Communications :: Chat
30
+ Classifier: Framework :: AsyncIO
31
+ Requires-Python: >=3.9
32
+ Description-Content-Type: text/markdown
33
+ License-File: LICENSE
34
+ Dynamic: author
35
+ Dynamic: classifier
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: keywords
40
+ Dynamic: license
41
+ Dynamic: license-file
42
+ Dynamic: platform
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ Forked as upstream did not make a release in quite a while, I hope to kill this fork off in the future.
47
+
48
+ > A Discord Rich Presence Client in Python? Looks like you've come to the right place.
49
+ ![PyPI](https://img.shields.io/pypi/v/lynxpresence.svg?style=for-the-badge)
50
+
51
+ ----------
52
+
53
+ # Installation
54
+
55
+ Install pypresence with **`pip`**
56
+
57
+ For the latest development version:
58
+
59
+ ### `pip install https://github.com/C0rn3j/pypresence/archive/master.zip`
60
+
61
+ For the latest stable version:
62
+
63
+ ### `pip install lynxpresence`
64
+
65
+ ----------
66
+
67
+ # Documentation
68
+
69
+ > [!Note]
70
+ > You need an **authorized app** to do anything besides rich presence!
71
+
72
+ #### [pypresence Documentation](https://qwertyquerty.github.io/pypresence/html/index.html)
73
+ #### [Discord Rich Presence Documentation](https://discord.com/developers/docs/rich-presence/how-to)
74
+ #### [Discord RPC Documentation](https://discord.com/developers/docs/topics/rpc)
75
+ #### [pyresence Discord Support Server](https://discord.gg/JF3kg77)
76
+ #### [Discord API Support Server](https://discord.gg/discord-api)
77
+
78
+ ----------
79
+
80
+ # Examples
81
+
82
+ Examples can be found in the [examples](https://github.com/C0rn3j/pypresence/tree/master/examples) directory, and you can contribute your own examples if you wish, just read [examples.md](https://github.com/C0rn3j/pypresence/blob/master/examples/examples.md)!
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ setup.cfg
4
+ setup.py
5
+ lynxpresence.egg-info/PKG-INFO
6
+ lynxpresence.egg-info/SOURCES.txt
7
+ lynxpresence.egg-info/dependency_links.txt
8
+ lynxpresence.egg-info/top_level.txt
9
+ lynxpresence.egg-info/zip-safe
10
+ pypresence/__init__.py
11
+ pypresence/baseclient.py
12
+ pypresence/client.py
13
+ pypresence/exceptions.py
14
+ pypresence/payloads.py
15
+ pypresence/presence.py
16
+ pypresence/py.typed
17
+ pypresence/types.py
18
+ pypresence/utils.py
@@ -0,0 +1 @@
1
+ pypresence
@@ -0,0 +1,18 @@
1
+ """
2
+ Python RPC Client for Discord
3
+ -----------------------------
4
+ By: qwertyquerty and LewdNeko
5
+ """
6
+
7
+ from .baseclient import BaseClient
8
+ from .client import Client, AioClient
9
+ from .exceptions import *
10
+ from .types import ActivityType
11
+ from .presence import Presence, AioPresence
12
+
13
+
14
+ __title__ = 'pypresence'
15
+ __author__ = 'C0rn3j'
16
+ __copyright__ = 'Copyright 2018 - Current qwertyquerty'
17
+ __license__ = 'MIT'
18
+ __version__ = '4.4.0'
@@ -0,0 +1,130 @@
1
+ from __future__ import annotations
2
+
3
+ import asyncio
4
+ import inspect
5
+ import json
6
+ import struct
7
+ import sys
8
+
9
+ # TODO: Get rid of this import * lol
10
+ from .exceptions import *
11
+ from .payloads import Payload
12
+ from .utils import get_ipc_path, get_event_loop
13
+
14
+
15
+ class BaseClient:
16
+
17
+ def __init__(self, client_id: str, **kwargs):
18
+ loop = kwargs.get('loop', None)
19
+ handler = kwargs.get('handler', None)
20
+ self.pipe = kwargs.get('pipe', None)
21
+ self.isasync = kwargs.get('isasync', False)
22
+ self.connection_timeout = kwargs.get('connection_timeout', 30)
23
+ self.response_timeout = kwargs.get('response_timeout', 10)
24
+
25
+ client_id = str(client_id)
26
+
27
+ if loop is not None:
28
+ self.update_event_loop(loop)
29
+ else:
30
+ self.update_event_loop(get_event_loop())
31
+
32
+ self.sock_reader: asyncio.StreamReader | None = None
33
+ self.sock_writer: asyncio.StreamWriter | None = None
34
+
35
+ self.client_id = client_id
36
+
37
+ if handler is not None:
38
+ if not inspect.isfunction(handler):
39
+ raise PyPresenceException('Error handler must be a function.')
40
+ args = inspect.getfullargspec(handler).args
41
+ if args[0] == 'self':
42
+ args = args[1:]
43
+ if len(args) != 2:
44
+ raise PyPresenceException('Error handler should only accept two arguments.')
45
+
46
+ if self.isasync:
47
+ if not inspect.iscoroutinefunction(handler):
48
+ raise InvalidArgument('Coroutine', 'Subroutine', 'You are running async mode - '
49
+ 'your error handler should be awaitable.')
50
+ err_handler = self._async_err_handle
51
+ else:
52
+ err_handler = self._err_handle
53
+
54
+ self.loop.set_exception_handler(err_handler)
55
+ self.handler = handler
56
+
57
+ if getattr(self, "on_event", None): # Tasty bad code ;^)
58
+ self._events_on = True
59
+ else:
60
+ self._events_on = False
61
+
62
+ def update_event_loop(self, loop):
63
+ # noinspection PyAttributeOutsideInit
64
+ self.loop = loop
65
+ asyncio.set_event_loop(self.loop)
66
+
67
+ def _err_handle(self, loop, context: dict):
68
+ result = self.handler(context['exception'], context['future'])
69
+ if inspect.iscoroutinefunction(self.handler):
70
+ loop.run_until_complete(result)
71
+
72
+ # noinspection PyUnusedLocal
73
+ async def _async_err_handle(self, loop, context: dict):
74
+ await self.handler(context['exception'], context['future'])
75
+
76
+ async def read_output(self):
77
+ try:
78
+ preamble = await asyncio.wait_for(self.sock_reader.read(8), self.response_timeout)
79
+ status_code, length = struct.unpack('<II', preamble[:8])
80
+ data = await asyncio.wait_for(self.sock_reader.read(length), self.response_timeout)
81
+ except (BrokenPipeError, struct.error):
82
+ raise PipeClosed
83
+ except asyncio.TimeoutError:
84
+ raise ResponseTimeout
85
+ payload = json.loads(data.decode('utf-8'))
86
+ if payload["evt"] == "ERROR":
87
+ raise ServerError(payload["data"]["message"])
88
+ return payload
89
+
90
+ def send_data(self, op: int, payload: dict | Payload):
91
+ if isinstance(payload, Payload):
92
+ payload = payload.data
93
+ payload = json.dumps(payload)
94
+
95
+ assert self.sock_writer is not None, "You must connect your client before sending events!"
96
+
97
+ self.sock_writer.write(
98
+ struct.pack(
99
+ '<II',
100
+ op,
101
+ len(payload)) +
102
+ payload.encode('utf-8'))
103
+
104
+ async def handshake(self):
105
+ ipc_path = get_ipc_path(self.pipe)
106
+ if not ipc_path:
107
+ raise DiscordNotFound
108
+
109
+ try:
110
+ if sys.platform == 'linux' or sys.platform == 'darwin':
111
+ self.sock_reader, self.sock_writer = await asyncio.wait_for(asyncio.open_unix_connection(ipc_path), self.connection_timeout)
112
+ elif sys.platform == 'win32':
113
+ self.sock_reader = asyncio.StreamReader(loop=self.loop)
114
+ reader_protocol = asyncio.StreamReaderProtocol(self.sock_reader, loop=self.loop)
115
+ self.sock_writer, _ = await asyncio.wait_for(self.loop.create_pipe_connection(lambda: reader_protocol, ipc_path), self.connection_timeout)
116
+ except FileNotFoundError:
117
+ raise InvalidPipe
118
+ except asyncio.TimeoutError:
119
+ raise ConnectionTimeout
120
+
121
+ self.send_data(0, {'v': 1, 'client_id': self.client_id})
122
+ preamble = await self.sock_reader.read(8)
123
+ code, length = struct.unpack('<ii', preamble)
124
+ data = json.loads(await self.sock_reader.read(length))
125
+ if 'code' in data:
126
+ if data['message'] == 'Invalid Client ID':
127
+ raise InvalidID
128
+ raise DiscordError(data['code'], data['message'])
129
+ if self._events_on:
130
+ self.sock_reader.feed_data = self.on_event