Exemplo n.º 1
0
func (r *roster) messageReceived(account *account, from string, timestamp time.Time, encrypted bool, message []byte) {
	doInUIThread(func() {
		conv, err := r.openConversationWindow(account, from)
		if err != nil {
			return
		}

		conv.appendMessage(r.displayNameFor(account, from), timestamp, encrypted, ui.StripHTML(message), false)
	})
}
Exemplo n.º 2
0
func (c *cliUI) handleMessageEvent(ev session.MessageEvent) {
	var line []byte
	if ev.Encrypted {
		line = append(line, c.term.Escape.Green...)
	} else {
		line = append(line, c.term.Escape.Red...)
	}

	t := fmt.Sprintf("(%s) %s: ", ev.When.Format(time.Stamp), ev.From)
	line = append(line, []byte(t)...)
	line = append(line, c.term.Escape.Reset...)
	line = appendTerminalEscaped(line, ui.StripHTML(ev.Body))
	line = append(line, '\n')
	if c.session.Config.Bell {
		line = append(line, '\a')
	}

	c.term.Write(line)
}
Exemplo n.º 3
0
func (conv *conversationWindow) sendMessage(message string) error {
	err := conv.account.session.EncryptAndSendTo(conv.to, message)
	if err != nil {
		return err
	}

	//TODO: review whether it should create a conversation
	//TODO: this should be whether the message was encrypted or not, rather than
	//whether the conversation is encrypted or not
	conversation, _ := conv.account.session.EnsureConversationWith(conv.to)
	conv.appendMessage(conv.account.session.GetConfig().Account, time.Now(), conversation.IsEncrypted(), ui.StripHTML([]byte(message)), true)

	return nil
}