mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 00:47:21 +01:00 
			
		
		
		
	core: rename ping() to _ping_uplink(), and drop the unused source/target arguments
This commit is contained in:
		
							parent
							
								
									43af9d1bac
								
							
						
					
					
						commit
						970b38719d
					
				@ -1117,7 +1117,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
 | 
			
		||||
 | 
			
		||||
    def _schedule_ping(self):
 | 
			
		||||
        """Schedules periodic pings in a loop."""
 | 
			
		||||
        self.ping()
 | 
			
		||||
        self._ping_uplink()
 | 
			
		||||
 | 
			
		||||
        self.pingTimer = threading.Timer(self.pingfreq, self._schedule_ping)
 | 
			
		||||
        self.pingTimer.daemon = True
 | 
			
		||||
 | 
			
		||||
@ -245,9 +245,9 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
 | 
			
		||||
        # Wrap around message(), which does all the text formatting for us.
 | 
			
		||||
        self.message(source, target, text, notice=True)
 | 
			
		||||
 | 
			
		||||
    def ping(self, source=None, target=None):
 | 
			
		||||
    def _ping_uplink(self):
 | 
			
		||||
        """
 | 
			
		||||
        Sends PING to the uplink.
 | 
			
		||||
        Sends a PING to the uplink.
 | 
			
		||||
        """
 | 
			
		||||
        if self.uplink:
 | 
			
		||||
            self.send('PING %s' % self.get_friendly_name(self.uplink))
 | 
			
		||||
 | 
			
		||||
@ -358,18 +358,12 @@ class IRCS2SProtocol(IRCCommonProtocol):
 | 
			
		||||
        self._send_with_prefix(client, msg)
 | 
			
		||||
        self.handle_part(client, 'PART', [channel])
 | 
			
		||||
 | 
			
		||||
    def ping(self, source=None, target=None):
 | 
			
		||||
        """Sends a PING to a target server.
 | 
			
		||||
    def _ping_uplink(self):
 | 
			
		||||
        """Sends a PING to the uplink.
 | 
			
		||||
 | 
			
		||||
        This is mostly used by PyLink internals to check whether the remote link is up."""
 | 
			
		||||
        source = source or self.sid
 | 
			
		||||
        if source is None:  # Source hasn't been initialized yet; ignore this command
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        if target is not None:
 | 
			
		||||
            self._send_with_prefix(source, 'PING %s %s' % (source, target))
 | 
			
		||||
        else:
 | 
			
		||||
            self._send_with_prefix(source, 'PING %s' % source)
 | 
			
		||||
        if self.sid:
 | 
			
		||||
            self._send_with_prefix(self.sid, 'PING %s' % self.sid)
 | 
			
		||||
 | 
			
		||||
    def quit(self, numeric, reason):
 | 
			
		||||
        """Quits a PyLink client."""
 | 
			
		||||
 | 
			
		||||
@ -72,7 +72,6 @@ class NgIRCdProtocol(IRCS2SProtocol):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def spawn_server(self, name, sid=None, uplink=None, desc=None, endburst_delay=0):
 | 
			
		||||
        pass
 | 
			
		||||
        '''
 | 
			
		||||
        """
 | 
			
		||||
        Spawns a server off a PyLink server.
 | 
			
		||||
@ -80,9 +79,6 @@ class NgIRCdProtocol(IRCS2SProtocol):
 | 
			
		||||
        * desc (server description) defaults to the one in the config.
 | 
			
		||||
        * uplink defaults to the main PyLink server.
 | 
			
		||||
        * SID is set equal to the server name for ngIRCd.
 | 
			
		||||
 | 
			
		||||
        Note: TS6 doesn't use a specific ENDBURST command, so the endburst_delay
 | 
			
		||||
        option will be ignored if given.
 | 
			
		||||
        """
 | 
			
		||||
        # -> :0AL SID test.server 1 0XY :some silly pseudoserver
 | 
			
		||||
        uplink = uplink or self.sid
 | 
			
		||||
@ -106,10 +102,12 @@ class NgIRCdProtocol(IRCS2SProtocol):
 | 
			
		||||
        '''
 | 
			
		||||
 | 
			
		||||
    def join(self, client, channel):
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    def ping(self, *args):
 | 
			
		||||
        self.lastping = time.time()
 | 
			
		||||
        channel = self.to_lower(channel)
 | 
			
		||||
        if not self.is_internal_client(client):
 | 
			
		||||
            raise LookupError('No such PyLink client exists.')
 | 
			
		||||
        self._send_with_prefix(client, "JOIN %s" % channel)
 | 
			
		||||
        self.channels[channel].users.add(client)
 | 
			
		||||
        self.users[client].channels.add(channel)
 | 
			
		||||
 | 
			
		||||
    ### Handlers
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -471,16 +471,10 @@ class P10Protocol(IRCS2SProtocol):
 | 
			
		||||
        self._send_with_prefix(client, msg)
 | 
			
		||||
        self.handle_part(client, 'PART', [channel])
 | 
			
		||||
 | 
			
		||||
    def ping(self, source=None, target=None):
 | 
			
		||||
        """Sends a PING to a target server. Periodic PINGs are sent to our uplink
 | 
			
		||||
        automatically by the Irc() internals; plugins shouldn't have to use this."""
 | 
			
		||||
        source = source or self.sid
 | 
			
		||||
        if source is None:
 | 
			
		||||
            return
 | 
			
		||||
        if target is not None:
 | 
			
		||||
            self._send_with_prefix(source, 'G %s %s' % (source, target))
 | 
			
		||||
        else:
 | 
			
		||||
            self._send_with_prefix(source, 'G %s' % source)
 | 
			
		||||
    def _ping_uplink(self):
 | 
			
		||||
        """Sends a PING to the uplink."""
 | 
			
		||||
        if self.sid:
 | 
			
		||||
            self._send_with_prefix(self.sid, 'G %s' % self.sid)
 | 
			
		||||
 | 
			
		||||
    def quit(self, numeric, reason):
 | 
			
		||||
        """Quits a PyLink client."""
 | 
			
		||||
 | 
			
		||||
@ -332,7 +332,7 @@ class TS6Protocol(TS6BaseProtocol):
 | 
			
		||||
 | 
			
		||||
        # Finally, end all the initialization with a PING - that's Charybdis'
 | 
			
		||||
        # way of saying end-of-burst :)
 | 
			
		||||
        self.ping()
 | 
			
		||||
        self._ping_uplink()
 | 
			
		||||
 | 
			
		||||
    def handle_pass(self, numeric, command, args):
 | 
			
		||||
        """
 | 
			
		||||
@ -399,7 +399,7 @@ class TS6Protocol(TS6BaseProtocol):
 | 
			
		||||
            self._send_with_prefix(destination, 'PONG %s %s' % (destination, source), queue=False)
 | 
			
		||||
 | 
			
		||||
            if destination == self.sid and not self.has_eob:
 | 
			
		||||
                # Charybdis' idea of endburst is just sending a PING. No, really!
 | 
			
		||||
                # Charybdis' endburst is just sending a PING to the other server.
 | 
			
		||||
                # https://github.com/charybdis-ircd/charybdis/blob/dc336d1/modules/core/m_server.c#L484-L485
 | 
			
		||||
                self.has_eob = True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -187,13 +187,10 @@ class UnrealProtocol(TS6BaseProtocol):
 | 
			
		||||
 | 
			
		||||
        self.updateTS(server, channel, ts, changedmodes)
 | 
			
		||||
 | 
			
		||||
    def ping(self, source=None, target=None):
 | 
			
		||||
        """Sends a PING to a target server. Periodic PINGs are sent to our uplink
 | 
			
		||||
        automatically by the Irc() internals; plugins shouldn't have to use this."""
 | 
			
		||||
        source = source or self.sid
 | 
			
		||||
        target = target or self.uplink
 | 
			
		||||
        if not (target is None or source is None):
 | 
			
		||||
            self._send_with_prefix(source, 'PING %s %s' % (self.servers[source].name, self.servers[target].name))
 | 
			
		||||
    def _ping_uplink(self):
 | 
			
		||||
        """Sends a PING to the uplink."""
 | 
			
		||||
        if self.sid and self.uplink:
 | 
			
		||||
            self._send_with_prefix(self.sid, 'PING %s %s' % (self.get_friendly_name(self.sid), self.get_friendly_name(self.uplink)))
 | 
			
		||||
 | 
			
		||||
    def mode(self, numeric, target, modes, ts=None):
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user