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):
19 telepathy.server.ChannelTypeText.__init__(self, connection, h)
20 self._nextRecievedId = 0
23 # @todo Populate participants
24 self.MembersChanged('', handles, [], [], [],
25 0, telepathy.CHANNEL_GROUP_CHANGE_REASON_NONE)
27 def Send(self, messageType, text):
28 if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
29 raise telepathy.NotImplemented("Unhandled message type")
30 # @todo implement sending message
31 self.Sent(int(time.time()), messageType, text)
34 telepathy.server.ChannelTypeText.Close(self)
35 self.remove_from_connection()
37 def _on_message_received(self, sender, message):
39 @todo Attatch this to receiving a message
41 currentReceivedId = self._nextRecievedId
43 timestamp = int(time.time())
44 h = handle.create_handle(self._conn, "contact", sender.account)
45 type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
46 message = message.content
48 _moduleLogger.info("Received message from User %r" % h)
49 self.Received(id, timestamp, h, type, 0, message)
51 self._nextRecievedId += 1