mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
add numericServer for sending raw numerics from servers, and WHOIS handling in coreplugin
Basic WHOIS handling (user information, server information, IRCop access) are sent. #72 TODO: send channel lists, an extra note for relay clients, user modes, and idle time
This commit is contained in:
parent
8a1f965303
commit
d52fba37b8
@ -36,3 +36,25 @@ def handle_commands(irc, source, command, args):
|
||||
utils.msg(irc, source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
|
||||
return
|
||||
utils.add_hook(handle_commands, 'PRIVMSG')
|
||||
|
||||
# Return WHOIS replies to IRCds that use them.
|
||||
def handle_whois(irc, source, command, args):
|
||||
target = args['target']
|
||||
user = irc.users.get(target)
|
||||
if user is None:
|
||||
log.warning('(%s) Got a WHOIS request for %r from %r, but the target doesn\'t exist in irc.users!', irc.name, target, source)
|
||||
f = irc.proto.numericServer
|
||||
server = utils.clientToServer(irc, target) or irc.sid
|
||||
nick = user.nick
|
||||
# https://www.alien.net.au/irc/irc2numerics.html
|
||||
# 311: sends nick!user@host information
|
||||
f(irc, server, 311, source, "%s %s %s * :%s" % (nick, user.ident, user.host, user.realname))
|
||||
# 312: sends the server the target is on, and the name
|
||||
f(irc, server, 312, source, "%s %s :PyLink Server" % (nick, irc.serverdata['hostname']))
|
||||
# 313: sends a string denoting the target's operator privilege;
|
||||
# we'll only send it if the user has umode +o.
|
||||
if ('o', None) in user.modes:
|
||||
f(irc, server, 313, source, "%s :is an IRC Operator" % nick)
|
||||
# 318: End of WHOIS.
|
||||
f(irc, server, 318, source, "%s :End of WHOIS" % nick.lower())
|
||||
utils.add_hook(handle_whois, 'WHOIS')
|
||||
|
@ -293,6 +293,12 @@ def pingServer(irc, source=None, target=None):
|
||||
if not (target is None or source is None):
|
||||
_send(irc, source, 'PING %s %s' % (source, target))
|
||||
|
||||
def numericServer(irc, source, numeric, text):
|
||||
raise NotImplementedError("Numeric sending is not yet implemented by this "
|
||||
"protocol module. WHOIS requests are handled "
|
||||
"locally by InspIRCd servers, so there is no "
|
||||
"need for PyLink to send numerics directly yet.")
|
||||
|
||||
def connect(irc):
|
||||
ts = irc.start_ts
|
||||
irc.uidgen = {}
|
||||
|
@ -230,6 +230,9 @@ def pingServer(irc, source=None, target=None):
|
||||
else:
|
||||
_send(irc, source, 'PING %s' % source)
|
||||
|
||||
def numericServer(irc, source, numeric, target, text):
|
||||
_send(irc, source, '%s %s %s' % (numeric, target, text))
|
||||
|
||||
def connect(irc):
|
||||
ts = irc.start_ts
|
||||
irc.uidgen = {}
|
||||
@ -586,3 +589,7 @@ def handle_bmask(irc, numeric, command, args):
|
||||
modes.append(('+%s' % mode, ban))
|
||||
utils.applyModes(irc, channel, modes)
|
||||
return {'target': channel, 'modes': modes, 'ts': ts}
|
||||
|
||||
def handle_whois(irc, numeric, command, args):
|
||||
# <- :42XAAAAAB WHOIS 5PYAAAAAA :pylink-devel
|
||||
return {'target': args[0]}
|
||||
|
Loading…
Reference in New Issue
Block a user