9 _moduleLogger = logging.getLogger("channel.text")
12 class TextChannel(telepathy.server.ChannelTypeText):
14 Look into implementing ChannelInterfaceMessages for rich text formatting
17 def __init__(self, connection, h):
18 telepathy.server.ChannelTypeText.__init__(self, connection, h)
19 self._nextRecievedId = 0
22 # @todo Populate participants
23 self.MembersChanged('', handles, [], [], [],
24 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
26 def Send(self, messageType, text):
27 if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
28 raise telepathy.NotImplemented("Unhandled message type")
29 # @todo implement sending message
30 self.Sent(int(time.time()), messageType, text)
33 telepathy.server.ChannelTypeText.Close(self)
34 self.remove_from_connection()
36 def _on_message_received(self, contactId, contactNumber, message):
38 @todo Attatch this to receiving a message
40 currentReceivedId = self._nextRecievedId
42 timestamp = int(time.time())
43 h = handle.create_handle(self._conn, "contact", contactId, contactNumber)
44 type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
45 message = message.content
47 _moduleLogger.info("Received message from User %r" % h)
48 self.Received(id, timestamp, h, type, 0, message)
50 self._nextRecievedId += 1