mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-13 05:32:33 +01:00
ngircd: implement nick changing
This commit is contained in:
parent
42a25300c4
commit
b780070ee6
@ -112,6 +112,18 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
self.channels[channel].users.add(client)
|
self.channels[channel].users.add(client)
|
||||||
self.users[client].channels.add(channel)
|
self.users[client].channels.add(channel)
|
||||||
|
|
||||||
|
def nick(self, source, newnick):
|
||||||
|
"""Changes the nick of a PyLink client."""
|
||||||
|
if not self.is_internal_client(source):
|
||||||
|
raise LookupError('No such PyLink client exists.')
|
||||||
|
|
||||||
|
self._send_with_prefix(source, 'NICK %s' % newnick)
|
||||||
|
|
||||||
|
self.users[source].nick = newnick
|
||||||
|
|
||||||
|
# Update the nick TS for consistency with other protocols (it isn't actually used in S2S)
|
||||||
|
self.users[source].ts = int(time.time())
|
||||||
|
|
||||||
### Handlers
|
### Handlers
|
||||||
|
|
||||||
def handle_pass(self, source, command, args):
|
def handle_pass(self, source, command, args):
|
||||||
@ -145,6 +157,11 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
return {'name': servername, 'sid': None, 'text': serverdesc}
|
return {'name': servername, 'sid': None, 'text': serverdesc}
|
||||||
|
|
||||||
def handle_nick(self, source, command, args):
|
def handle_nick(self, source, command, args):
|
||||||
|
"""
|
||||||
|
Handles the NICK command, used for server introductions and nick changes.
|
||||||
|
"""
|
||||||
|
if len(args) >= 2:
|
||||||
|
# User introduction:
|
||||||
# <- :ngircd.midnight.local NICK GL 1 ~gl localhost 1 +io :realname
|
# <- :ngircd.midnight.local NICK GL 1 ~gl localhost 1 +io :realname
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
assert source in self.servers, "Server %r tried to introduce nick %r but isn't in the servers index?" % (source, nick)
|
assert source in self.servers, "Server %r tried to introduce nick %r but isn't in the servers index?" % (source, nick)
|
||||||
@ -164,6 +181,12 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
|
|
||||||
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': host, 'host': host, 'ident': ident,
|
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': host, 'host': host, 'ident': ident,
|
||||||
'parse_as': 'UID', 'ip': '0.0.0.0'}
|
'parse_as': 'UID', 'ip': '0.0.0.0'}
|
||||||
|
else:
|
||||||
|
# Nick changes:
|
||||||
|
# <- :GL NICK :GL_
|
||||||
|
oldnick = self.users[source].nick
|
||||||
|
newnick = self.users[source].nick = args[0]
|
||||||
|
return {'newnick': newnick, 'oldnick': oldnick}
|
||||||
|
|
||||||
def handle_ping(self, source, command, args):
|
def handle_ping(self, source, command, args):
|
||||||
if source == self.uplink:
|
if source == self.uplink:
|
||||||
|
Loading…
Reference in New Issue
Block a user