Esempio n. 1
0
// GetPrompt will render the terminal prompt string based on the user.
func GetPrompt(user *message.User) string {
	name := user.Name()
	if user.Config.Theme != nil {
		name = user.Config.Theme.ColorName(user)
	}
	return fmt.Sprintf("[%s] ", name)
}
Esempio n. 2
0
// Join the room as a user, will announce.
func (r *Room) Join(u *message.User) (*Member, error) {
	if r.closed {
		return nil, ErrRoomClosed
	}
	if u.Id() == "" {
		return nil, ErrInvalidName
	}
	member := Member{u, false}
	err := r.members.Add(&member)
	if err != nil {
		return nil, err
	}
	r.History(u)
	s := fmt.Sprintf("%s joined. (Connected: %d)", u.Name(), r.members.Len())
	r.Send(message.NewAnnounceMsg(s))
	return &member, nil
}