mirror of
				https://github.com/42wim/matterbridge.git
				synced 2025-11-04 07:47:27 +01:00 
			
		
		
		
	Run gofumpt, remove unneeded 'else'
This commit is contained in:
		
							parent
							
								
									b82b7b67a8
								
							
						
					
					
						commit
						5c82f187bc
					
				@ -96,11 +96,13 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
 | 
			
		||||
			time.Sleep(time.Duration(b.GetInt("RejoinDelay")) * time.Second)
 | 
			
		||||
			b.Remote <- config.Message{Username: "system", Text: "rejoin", Channel: channel, Account: b.Account, Event: config.EventRejoinChannels}
 | 
			
		||||
		} else {
 | 
			
		||||
			msg := config.Message{Username: "system",
 | 
			
		||||
				Text:    event.Source.Name + " kicked " + event.Params[1] + " with message: " + event.Last(),
 | 
			
		||||
				Channel: channel,
 | 
			
		||||
				Account: b.Account,
 | 
			
		||||
				Event:   config.EventJoinLeave}
 | 
			
		||||
			msg := config.Message{
 | 
			
		||||
				Username: "system",
 | 
			
		||||
				Text:     event.Source.Name + " kicked " + event.Params[1] + " with message: " + event.Last(),
 | 
			
		||||
				Channel:  channel,
 | 
			
		||||
				Account:  b.Account,
 | 
			
		||||
				Event:    config.EventJoinLeave,
 | 
			
		||||
			}
 | 
			
		||||
			b.Log.Debugf("<= Message is %#v", msg)
 | 
			
		||||
			b.Remote <- msg
 | 
			
		||||
		}
 | 
			
		||||
@ -150,11 +152,13 @@ func (b *Birc) handleNick(client *girc.Client, event girc.Event) {
 | 
			
		||||
		b.Log.Debugf("handleJoinPart: malformed nick change? %#v", event)
 | 
			
		||||
		return
 | 
			
		||||
	} else if isActive, activeTime := b.isUserActive(event.Source.Name); isActive {
 | 
			
		||||
		msg := config.Message{Username: "system",
 | 
			
		||||
			Text:    event.Source.Name + " changed nick to " + event.Params[0],
 | 
			
		||||
			Channel: b.getPseudoChannel(),
 | 
			
		||||
			Account: b.Account,
 | 
			
		||||
			Event:   config.EventJoinLeave}
 | 
			
		||||
		msg := config.Message{
 | 
			
		||||
			Username: "system",
 | 
			
		||||
			Text:     event.Source.Name + " changed nick to " + event.Params[0],
 | 
			
		||||
			Channel:  b.getPseudoChannel(),
 | 
			
		||||
			Account:  b.Account,
 | 
			
		||||
			Event:    config.EventJoinLeave,
 | 
			
		||||
		}
 | 
			
		||||
		b.Log.Debugf("<= Message is %#v", msg)
 | 
			
		||||
		b.Remote <- msg
 | 
			
		||||
		if b.ActivityTimeout != 0 {
 | 
			
		||||
@ -276,6 +280,7 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
 | 
			
		||||
	b.Remote <- rmsg
 | 
			
		||||
	b.cleanActiveMap()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *Birc) handleQuit(client *girc.Client, event girc.Event) {
 | 
			
		||||
	if event.Source.Name == b.Nick && strings.Contains(event.Last(), "Ping timeout") {
 | 
			
		||||
		b.Log.Infof("%s reconnecting ..", b.Account)
 | 
			
		||||
@ -298,6 +303,7 @@ func (b *Birc) handleQuit(client *girc.Client, event girc.Event) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *Birc) handleRunCommands() {
 | 
			
		||||
	for _, cmd := range b.GetStringSlice("RunCommands") {
 | 
			
		||||
		if err := b.i.Cmd.SendRaw(cmd); err != nil {
 | 
			
		||||
 | 
			
		||||
@ -438,18 +438,17 @@ func (b *Birc) isUserActive(nick string) (bool, int64) {
 | 
			
		||||
	b.Log.Debugf("checking activity for %s", nick)
 | 
			
		||||
	if b.ActivityTimeout == 0 {
 | 
			
		||||
		return true, 0
 | 
			
		||||
	} else {
 | 
			
		||||
		b.activeUsersMutex.RLock()
 | 
			
		||||
		defer b.activeUsersMutex.RUnlock()
 | 
			
		||||
		if activeTime, ok := b.activeUsers[nick]; ok {
 | 
			
		||||
			now := time.Now().Unix()
 | 
			
		||||
			b.Log.Debugf("last activity for %s was %d, currently %d", nick, activeTime, now)
 | 
			
		||||
			if now < activeTime {
 | 
			
		||||
				b.Log.Errorf("User %s has active time in the future: %d", nick, activeTime)
 | 
			
		||||
				return true, now // err on the side of caution
 | 
			
		||||
			}
 | 
			
		||||
			return (now - activeTime) < b.ActivityTimeout, activeTime
 | 
			
		||||
	}
 | 
			
		||||
	b.activeUsersMutex.RLock()
 | 
			
		||||
	defer b.activeUsersMutex.RUnlock()
 | 
			
		||||
	if activeTime, ok := b.activeUsers[nick]; ok {
 | 
			
		||||
		now := time.Now().Unix()
 | 
			
		||||
		b.Log.Debugf("last activity for %s was %d, currently %d", nick, activeTime, now)
 | 
			
		||||
		if now < activeTime {
 | 
			
		||||
			b.Log.Errorf("User %s has active time in the future: %d", nick, activeTime)
 | 
			
		||||
			return true, now // err on the side of caution
 | 
			
		||||
		}
 | 
			
		||||
		return (now - activeTime) < b.ActivityTimeout, activeTime
 | 
			
		||||
	}
 | 
			
		||||
	return false, 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user