mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 00:47:21 +01:00 
			
		
		
		
	clientbot: implement away-notify support (#290)
This commit is contained in:
		
							parent
							
								
									ffc734d8e2
								
							
						
					
					
						commit
						72145e09b8
					
				@ -15,7 +15,9 @@ from pylinkirc.protocols.ircs2s_common import *
 | 
			
		||||
from pylinkirc.classes import *
 | 
			
		||||
 | 
			
		||||
FALLBACK_REALNAME = 'PyLink Relay Mirror Client'
 | 
			
		||||
IRCV3_CAPABILITIES = {'multi-prefix', 'sasl'}
 | 
			
		||||
 | 
			
		||||
# IRCv3 capabilities to request when available
 | 
			
		||||
IRCV3_CAPABILITIES = {'multi-prefix', 'sasl', 'away-notify'}
 | 
			
		||||
 | 
			
		||||
class ClientbotWrapperProtocol(IRCCommonProtocol):
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
 | 
			
		||||
@ -176,6 +176,23 @@ class IRCCommonProtocol(IRCNetwork):
 | 
			
		||||
        prefixsearch = re.search(r'\(([A-Za-z]+)\)(.*)', args)
 | 
			
		||||
        return dict(zip(prefixsearch.group(1), prefixsearch.group(2)))
 | 
			
		||||
 | 
			
		||||
    def handle_away(self, source, command, args):
 | 
			
		||||
        """Handles incoming AWAY messages."""
 | 
			
		||||
        # TS6:
 | 
			
		||||
        # <- :6ELAAAAAB AWAY :Auto-away
 | 
			
		||||
        # <- :6ELAAAAAB AWAY
 | 
			
		||||
        # P10:
 | 
			
		||||
        # <- ABAAA A :blah
 | 
			
		||||
        # <- ABAAA A
 | 
			
		||||
        if source not in self.users:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            self.users[source].away = text = args[0]
 | 
			
		||||
        except IndexError:  # User is unsetting away status
 | 
			
		||||
            self.users[source].away = text = ''
 | 
			
		||||
        return {'text': text}
 | 
			
		||||
 | 
			
		||||
    def handle_error(self, numeric, command, args):
 | 
			
		||||
        """Handles ERROR messages - these mean that our uplink has disconnected us!"""
 | 
			
		||||
        raise ProtocolError('Received an ERROR, disconnecting!')
 | 
			
		||||
@ -455,19 +472,6 @@ class IRCS2SProtocol(IRCCommonProtocol):
 | 
			
		||||
        self.channels[target].topicset = True
 | 
			
		||||
    topic_burst = topic
 | 
			
		||||
 | 
			
		||||
    def handle_away(self, numeric, command, args):
 | 
			
		||||
        """Handles incoming AWAY messages."""
 | 
			
		||||
        # TS6:
 | 
			
		||||
        # <- :6ELAAAAAB AWAY :Auto-away
 | 
			
		||||
        # P10:
 | 
			
		||||
        # <- ABAAA A :blah
 | 
			
		||||
        # <- ABAAA A
 | 
			
		||||
        try:
 | 
			
		||||
            self.users[numeric].away = text = args[0]
 | 
			
		||||
        except IndexError:  # User is unsetting away status
 | 
			
		||||
            self.users[numeric].away = text = ''
 | 
			
		||||
        return {'text': text}
 | 
			
		||||
 | 
			
		||||
    def handle_invite(self, numeric, command, args):
 | 
			
		||||
        """Handles incoming INVITEs."""
 | 
			
		||||
        # TS6:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user