Пример #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)
	}
}