Split Game object to separate Activity subtypes for Rich Presences.

This is a massive breaking change.

* All references to "game" have been renamed to "activity"
* Activity objects contain a majority of the rich presence information
* Game and Streaming are subtypes for memory optimisation purposes for
  the more common cases.
* Introduce a more specialised read-only type, Spotify, for the
  official Spotify integration to make it easier to use.
This commit is contained in:
Rapptz
2018-03-05 11:01:46 -05:00
parent 2f562bd695
commit f8f8f418f3
12 changed files with 708 additions and 150 deletions

View File

@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
from .guild import Guild
from .activity import _ActivityTag
from .user import User, ClientUser
from .emoji import Emoji, PartialEmoji
from .message import Message
@ -67,9 +68,12 @@ class ConnectionState:
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
self._listeners = []
game = options.get('game', None)
if game:
game = dict(game)
activity = options.get('activity', None)
if activity:
if not isinstance(activity, _ActivityTag):
raise TypeError('activity parameter must be one of Game, Streaming, or Activity.')
activity = activity.to_dict()
status = options.get('status', None)
if status:
@ -78,7 +82,7 @@ class ConnectionState:
else:
status = str(status)
self._game = game
self._activity = activity
self._status = status
self.clear()