コード例 #1
0
ファイル: roster.go プロジェクト: tanujmathur/coyim
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)
	})
}
コード例 #2
0
ファイル: session_events.go プロジェクト: PMaynard/coyim
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)
}
コード例 #3
0
ファイル: conversation.go プロジェクト: 0x27/coyim
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
}