on_status event now has the old game ID and old status as parameters.

This commit is contained in:
Rapptz 2015-11-30 03:31:03 -05:00
parent 31fd5023f1
commit 307392ff19
2 changed files with 6 additions and 2 deletions

View File

@ -206,13 +206,15 @@ class ConnectionState(object):
member_id = user['id']
member = utils.find(lambda m: m.id == member_id, server.members)
if member is not None:
old_status = copy.copy(member.status)
old_game_id = copy.copy(member.game_id)
member.status = data.get('status')
member.game_id = data.get('game_id')
member.name = user.get('username', member.name)
member.avatar = user.get('avatar', member.avatar)
# call the event now
self.dispatch('status', member)
self.dispatch('status', member, old_game_id, old_status)
self.dispatch('member_update', member)
def handle_user_update(self, data):

View File

@ -152,11 +152,13 @@ to handle it, which defaults to print a traceback and ignore the exception.
:param before: A :class:`Message` of the previous version of the message.
:param after: A :class:`Message` of the current version of the message.
.. function:: on_status(member)
.. function:: on_status(member, old_game_id, old_status)
Called whenever a :class:`Member` changes their status or game playing status.
:param member: The :class:`Member` who has had their status changed.
:param old_game_id: The game ID the member had before it changed.
:param old_status: The status the member had before it changed.
.. function:: on_channel_delete(channel)
on_channel_create(channel)