示例#1
0
func createMessage(m string) Message {
	return Message{
		ID:        util.RandomID(),
		Addr:      self,
		Body:      m,
		Nick:      *selfNick,
		Timestamp: time.Now().Unix(),
	}
}
示例#2
0
func createMessage(m string) Message {
	for shortcut, emoji := range emojis {
		m = strings.Replace(m, shortcut, emoji, -1)
	}
	return Message{
		ID:        util.RandomID(),
		Addr:      self,
		Body:      m,
		Nick:      *selfNick,
		Timestamp: time.Now().Unix(),
	}
}
示例#3
0
func readInput() {
	s := bufio.NewScanner(os.Stdin)
	for s.Scan() {
		body := s.Text()
		if body != "" {
			m := Message{
				ID:   util.RandomID(),
				Addr: self,
				Body: s.Text(),
				Nick: *selfNick,
			}
			Seen(m.ID)
			broadcast(m)
		}
	}
	if err := s.Err(); err != nil {
		log.Fatal(err)
	}
}