mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 00:47:21 +01:00 
			
		
		
		
	
							parent
							
								
									fbc2fbf595
								
							
						
					
					
						commit
						0540e10d50
					
				@ -416,6 +416,11 @@ def relayModes(irc, remoteirc, sender, channel, modes=None):
 | 
			
		||||
                        arg = getRemoteUser(irc, remoteirc, arg)
 | 
			
		||||
                supported_char = remoteirc.cmodes.get(name)
 | 
			
		||||
            if supported_char:
 | 
			
		||||
                if name in ('ban', 'banexception', 'invex') and not utils.isHostmask(arg):
 | 
			
		||||
                    # Don't add bans that don't match n!u@h syntax!
 | 
			
		||||
                    log.debug("(%s) Relay mode: skipping mode (%r, %r) because it doesn't match nick!user@host syntax.",
 | 
			
		||||
                              irc.name, supported_char, arg)
 | 
			
		||||
                    continue
 | 
			
		||||
                supported_modes.append((prefix+supported_char, arg))
 | 
			
		||||
    log.debug('(%s) Relay mode: final modelist (sending to %s%s) is %s', irc.name, remoteirc.name, remotechan, supported_modes)
 | 
			
		||||
    # Don't send anything if there are no supported modes left after filtering.
 | 
			
		||||
 | 
			
		||||
@ -510,6 +510,7 @@ def handle_events(irc, data):
 | 
			
		||||
                # We don't really care about mode prefixes; just the mode char
 | 
			
		||||
                irc.cmodes[name.lstrip(':')] = char[-1]
 | 
			
		||||
        elif args[1] == 'USERMODES':
 | 
			
		||||
            # <- CAPAB USERMODES :bot=B callerid=g cloak=x deaf_commonchan=c helpop=h hidechans=I hideoper=H invisible=i oper=o regdeaf=R servprotect=k showwhois=W snomask=s u_registered=r u_stripcolor=S wallops=w
 | 
			
		||||
            # Ditto above.
 | 
			
		||||
            for modepair in args[2:]:
 | 
			
		||||
                name, char = modepair.split('=')
 | 
			
		||||
@ -524,6 +525,7 @@ def handle_events(irc, data):
 | 
			
		||||
            irc.maxchanlen = int(caps['CHANMAX'])
 | 
			
		||||
            # Modes are divided into A, B, C, and D classes
 | 
			
		||||
            # See http://www.irc.org/tech_docs/005.html
 | 
			
		||||
 | 
			
		||||
            # FIXME: Find a better way to assign/store this.
 | 
			
		||||
            irc.cmodes['*A'], irc.cmodes['*B'], irc.cmodes['*C'], irc.cmodes['*D'] \
 | 
			
		||||
                = caps['CHANMODES'].split(',')
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								utils.py
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								utils.py
									
									
									
									
									
								
							@ -349,3 +349,8 @@ def getHostmask(irc, user):
 | 
			
		||||
    except AttributeError:
 | 
			
		||||
        host = '<unknown host>'
 | 
			
		||||
    return '%s!%s@%s' % (nick, ident, host)
 | 
			
		||||
 | 
			
		||||
hostmaskRe = re.compile(r'^\S+!\S+@\S+$')
 | 
			
		||||
def isHostmask(text):
 | 
			
		||||
    """Returns whether <text> is a valid hostmask."""
 | 
			
		||||
    return bool(hostmaskRe.match(text))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user