Ejemplo n.º 1
0
func (s *SlackLink) addContextAssociation(context uuid.UUID, channelID string) {
	s.contextChannelsLock.Lock()
	s.contextChannels[context.String()] = channelID
	s.contextChannelsLock.Unlock()
	s.contextBuffersLock.Lock()
	s.contextBuffers[context.String()] = bytes.NewBuffer(nil)
	s.contextBuffersLock.Unlock()
}
Ejemplo n.º 2
0
func (s *SlackLink) removeContextAssociation(context uuid.UUID) {
	s.contextChannelsLock.Lock()
	delete(s.contextChannels, context.String())
	s.contextChannelsLock.Unlock()
	s.contextBuffersLock.Lock()
	delete(s.contextBuffers, context.String())
	s.contextBuffersLock.Unlock()
	s.removeSpecialAcknowledgementContext(context)
}
Ejemplo n.º 3
0
func (s *SlackLink) getSpecialAcknowledgement(context uuid.UUID) (*slack.ItemRef, string, bool) {
	s.specialAcknowledgementContextsLock.Lock()
	defer s.specialAcknowledgementContextsLock.Unlock()
	entry, ok := s.specialAcknowledgementContexts[context.String()]
	if !ok {
		return nil, "", false
	}

	return entry.Ref, entry.MustContain, true
}
Ejemplo n.º 4
0
func (s *SlackLink) getContextBuffer(context uuid.UUID) *bytes.Buffer {
	s.contextBuffersLock.Lock()
	defer s.contextBuffersLock.Unlock()
	buf, ok := s.contextBuffers[context.String()]
	if !ok {
		buf = new(bytes.Buffer)
		s.contextBuffers[context.String()] = buf
	}

	return buf
}
Ejemplo n.º 5
0
func (s *SlackLink) addSpecialAcknowledgementContext(context uuid.UUID, ref *slack.ItemRef, mustContain string) {
	s.specialAcknowledgementContextsLock.Lock()
	defer s.specialAcknowledgementContextsLock.Unlock()
	s.specialAcknowledgementContexts[context.String()] = struct {
		MustContain string
		Ref         *slack.ItemRef
	}{
		MustContain: mustContain,
		Ref:         ref,
	}
}
Ejemplo n.º 6
0
func (s *SlackLink) getMinecraftPlayer(id uuid.UUID) *MinecraftPlayer {
	name, err := s.redis.HGet("playerUUIDToName", id.String()).Result()
	if err == redis.Nil {
		return &MinecraftPlayer{
			UUID: id,
		}
	} else if err != nil {
		log.Printf("error in getMinecraftPlayer: %v", err)
		return nil
	}

	return &MinecraftPlayer{
		UUID: id,
		Name: name,
	}
}
Ejemplo n.º 7
0
func (s *SlackLink) removeSpecialAcknowledgementContext(context uuid.UUID) {
	s.specialAcknowledgementContextsLock.Lock()
	defer s.specialAcknowledgementContextsLock.Unlock()
	delete(s.specialAcknowledgementContexts, context.String())
}