Skip to content

Commit

Permalink
Add new event type for OTR modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrance committed Nov 2, 2016
1 parent 755e43b commit dceea63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hangups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .auth import get_auth, get_auth_stdin, GoogleAuthError
from .exceptions import HangupsError, NetworkError
from .conversation_event import (ChatMessageSegment, ConversationEvent,
ChatMessageEvent, RenameEvent,
ChatMessageEvent, OTREvent, RenameEvent,
MembershipChangeEvent, HangoutEvent,
GroupLinkSharingModificationEvent)
# Only import Protocol Buffer objects that are needed for the high-level
Expand Down
2 changes: 2 additions & 0 deletions hangups/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def _wrap_event(event_):
"""Wrap hangouts_pb2.Event in ConversationEvent subclass."""
if event_.HasField('chat_message'):
return conversation_event.ChatMessageEvent(event_)
elif event_.HasField('otr_modification'):
return conversation_event.OTREvent(event_)
elif event_.HasField('conversation_rename'):
return conversation_event.RenameEvent(event_)
elif event_.HasField('membership_change'):
Expand Down
18 changes: 18 additions & 0 deletions hangups/conversation_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ def attachments(self):
return attachments


class OTREvent(ConversationEvent):

"""An event that changes OTR mode.
Corresponds to hangouts_pb2.OTRModification.
"""

@property
def new_otr_status(self):
"""The conversation's old OTR status."""
return self._event.otr_modification.new_otr_status

@property
def old_otr_status(self):
"""The conversation's old OTR status."""
return self._event.otr_modification.old_otr_status


class RenameEvent(ConversationEvent):

"""An event that renames a conversation.
Expand Down

0 comments on commit dceea63

Please sign in to comment.