def _wrap_event(event_): """Wrap ClientEvent in ConversationEvent subclass.""" if event_.chat_message is not None: return conversation_event.ChatMessageEvent(event_) elif event_.conversation_rename is not None: return conversation_event.RenameEvent(event_) elif event_.membership_change is not None: return conversation_event.MembershipChangeEvent(event_) else: return conversation_event.ConversationEvent(event_)
def _wrap_event(event_): """Wrap hangouts_pb2.Event in ConversationEvent subclass.""" if event_.HasField('chat_message'): return conversation_event.ChatMessageEvent(event_) elif event_.HasField('conversation_rename'): return conversation_event.RenameEvent(event_) elif event_.HasField('membership_change'): return conversation_event.MembershipChangeEvent(event_) else: return conversation_event.ConversationEvent(event_)
def _wrap_event(event_): """Wrap hangouts_pb2.Event in ConversationEvent subclass.""" if event_.HasField('chat_message'): return conversation_event.ChatMessageEvent(event_) elif event_.HasField('conversation_rename'): return conversation_event.RenameEvent(event_) elif event_.HasField('membership_change'): return conversation_event.MembershipChangeEvent(event_) elif event_.HasField('hangout_event'): return conversation_event.HangoutEvent(event_) elif event_.HasField('group_link_sharing_modification'): return conversation_event.GroupLinkSharingModificationEvent(event_) else: return conversation_event.ConversationEvent(event_)
def add_event(self, event_): """Add a ClientEvent to the Conversation. Returns an instance of ConversationEvent or subclass. """ if event_.chat_message is not None: conv_event = conversation_event.ChatMessageEvent(event_) elif event_.conversation_rename is not None: conv_event = conversation_event.RenameEvent(event_) elif event_.membership_change is not None: conv_event = conversation_event.MembershipChangeEvent(event_) else: conv_event = conversation_event.ConversationEvent(event_) self._events.append(conv_event) return conv_event