mirror of
				https://github.com/42wim/matterbridge.git
				synced 2025-11-03 23:37:24 +01:00 
			
		
		
		
	Add simple functionality to disable URLs in part/quit msgs
This commit is contained in:
		
							parent
							
								
									37d3721c28
								
							
						
					
					
						commit
						e275bbfb2e
					
				@ -84,6 +84,10 @@ func isKill(quitmsg string) bool {
 | 
			
		||||
	return strings.HasPrefix(quitmsg, "Killed") || strings.HasPrefix(quitmsg, "Local kill") || strings.HasPrefix(quitmsg[1:], "-lined")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func suppressUrls(msg *string) {
 | 
			
		||||
	*msg = strings.ReplaceAll(*msg, "://", ": //")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
 | 
			
		||||
	if len(event.Params) == 0 {
 | 
			
		||||
		b.Log.Debugf("handleJoinPart: empty Params? %#v", event)
 | 
			
		||||
@ -114,6 +118,9 @@ func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
 | 
			
		||||
		if event.Command == "PART" && len(event.Params) >= 2 {
 | 
			
		||||
			partmsg = " with message: " + event.Last()
 | 
			
		||||
		}
 | 
			
		||||
		if len(partmsg) > 0 && b.SuppressPartQuitURLs {
 | 
			
		||||
			suppressUrls(&partmsg)
 | 
			
		||||
		}
 | 
			
		||||
		msg := config.Message{Username: "system", Text: event.Source.Name + " " + strings.ToLower(event.Command) + "s" + partmsg, Channel: channel, Account: b.Account, Event: config.EventJoinLeave}
 | 
			
		||||
		if b.GetBool("verbosejoinpart") {
 | 
			
		||||
			b.Log.Debugf("<= Sending verbose JOIN_LEAVE event from %s to gateway", b.Account)
 | 
			
		||||
@ -289,6 +296,9 @@ func (b *Birc) handleQuit(client *girc.Client, event girc.Event) {
 | 
			
		||||
		if len(event.Params) >= 1 {
 | 
			
		||||
			quitmsg = " with message: " + event.Last()
 | 
			
		||||
		}
 | 
			
		||||
		if len(quitmsg) > 0 && b.SuppressPartQuitURLs {
 | 
			
		||||
			suppressUrls(&quitmsg)
 | 
			
		||||
		}
 | 
			
		||||
		if b.GetBool("verbosejoinpart") {
 | 
			
		||||
			verbosequit = " (" + event.Source.Ident + "@" + event.Source.Host + ")"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ type Birc struct {
 | 
			
		||||
	connected                                 chan error
 | 
			
		||||
	Local                                     chan config.Message // local queue for flood control
 | 
			
		||||
	FirstConnection, authDone                 bool
 | 
			
		||||
	SuppressPartQuitURLs                      bool
 | 
			
		||||
	MessageDelay, MessageQueue, MessageLength int
 | 
			
		||||
	ActivityTimeout                           int64
 | 
			
		||||
	channels                                  map[string]bool
 | 
			
		||||
@ -75,6 +76,7 @@ func New(cfg *bridge.Config) bridge.Bridger {
 | 
			
		||||
	} else {
 | 
			
		||||
		b.ActivityTimeout = 0 // Disable
 | 
			
		||||
	}
 | 
			
		||||
	b.SuppressPartQuitURLs = b.GetBool("SuppressPartQuitURLs")
 | 
			
		||||
	b.FirstConnection = true
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user