mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
plugins: migrate irc.proto calls to irc
This commit is contained in:
parent
748c1bc158
commit
4696519bad
@ -113,7 +113,7 @@ def match(irc, channel, uids=None):
|
||||
log.debug("(%s) automode: sending modes from modebot_uid %s",
|
||||
irc.name, modebot_uid)
|
||||
|
||||
irc.proto.mode(modebot_uid, channel, outgoing_modes)
|
||||
irc.mode(modebot_uid, channel, outgoing_modes)
|
||||
|
||||
# Create a hook payload to support plugins like relay.
|
||||
irc.callHooks([modebot_uid, 'AUTOMODE_MODE',
|
||||
|
@ -18,7 +18,7 @@ def spawnclient(irc, source, args):
|
||||
except ValueError:
|
||||
irc.error("Not enough arguments. Needs 3: nick, user, host.")
|
||||
return
|
||||
irc.proto.spawnClient(nick, ident, host, manipulatable=True)
|
||||
irc.spawnClient(nick, ident, host, manipulatable=True)
|
||||
irc.reply("Done.")
|
||||
|
||||
@utils.add_cmd
|
||||
@ -45,7 +45,7 @@ def quit(irc, source, args):
|
||||
irc.error("Cannot force quit a protected PyLink services client.")
|
||||
return
|
||||
|
||||
irc.proto.quit(u, quitmsg)
|
||||
irc.quit(u, quitmsg)
|
||||
irc.reply("Done.")
|
||||
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_QUIT', {'text': quitmsg, 'parse_as': 'QUIT'}])
|
||||
|
||||
@ -99,9 +99,9 @@ def joinclient(irc, source, args):
|
||||
|
||||
# join() doesn't support prefixes.
|
||||
if prefixes:
|
||||
irc.proto.sjoin(irc.sid, real_channel, [(joinmodes, u)])
|
||||
irc.sjoin(irc.sid, real_channel, [(joinmodes, u)])
|
||||
else:
|
||||
irc.proto.join(u, real_channel)
|
||||
irc.join(u, real_channel)
|
||||
|
||||
# Call a join hook manually so other plugins like relay can understand it.
|
||||
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_JOIN', {'channel': real_channel, 'users': [u],
|
||||
@ -141,7 +141,7 @@ def nick(irc, source, args):
|
||||
irc.error("Cannot force nick changes for a protected PyLink services client.")
|
||||
return
|
||||
|
||||
irc.proto.nick(u, newnick)
|
||||
irc.nick(u, newnick)
|
||||
irc.reply("Done.")
|
||||
# Ditto above: manually send a NICK change hook payload to other plugins.
|
||||
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_NICK', {'newnick': newnick, 'oldnick': nick, 'parse_as': 'NICK'}])
|
||||
@ -188,7 +188,7 @@ def part(irc, source, args):
|
||||
if not utils.isChannel(channel):
|
||||
irc.error("Invalid channel name %r." % channel)
|
||||
return
|
||||
irc.proto.part(u, channel, reason)
|
||||
irc.part(u, channel, reason)
|
||||
|
||||
irc.reply("Done.")
|
||||
irc.callHooks([u, 'PYLINK_BOTSPLUGIN_PART', {'channels': clist, 'text': reason, 'parse_as': 'PART'}])
|
||||
@ -236,7 +236,7 @@ def msg(irc, source, args):
|
||||
else:
|
||||
real_target = target
|
||||
|
||||
irc.proto.message(sourceuid, real_target, text)
|
||||
irc.message(sourceuid, real_target, text)
|
||||
irc.reply("Done.")
|
||||
irc.callHooks([sourceuid, 'PYLINK_BOTSPLUGIN_MSG', {'target': real_target, 'text': text, 'parse_as': 'PRIVMSG'}])
|
||||
utils.add_cmd(msg, 'say')
|
||||
|
@ -78,7 +78,7 @@ def _changehost(irc, target, args):
|
||||
if char not in allowed_chars:
|
||||
new_host = new_host.replace(char, '-')
|
||||
|
||||
irc.proto.updateClient(target, 'HOST', new_host)
|
||||
irc.updateClient(target, 'HOST', new_host)
|
||||
|
||||
# Only operate on the first match.
|
||||
break
|
||||
|
@ -110,7 +110,7 @@ def showchan(irc, source, args):
|
||||
|
||||
# Mark TS values as untrusted on Clientbot and others (where TS is read-only or not trackable)
|
||||
f('\x02Channel creation time\x02: %s (%s)%s' % (ctime(c.ts), c.ts,
|
||||
' [UNTRUSTED]' if not irc.proto.hasCap('has-ts') else ''))
|
||||
' [UNTRUSTED]' if not irc.hasCap('has-ts') else ''))
|
||||
|
||||
# Show only modes that aren't list-style modes.
|
||||
modes = irc.joinModes([m for m in c.modes if m[0] not in irc.cmodes['*A']], sort=True)
|
||||
|
@ -70,7 +70,7 @@ def jupe(irc, source, args):
|
||||
irc.error("Invalid server name '%s'." % servername)
|
||||
return
|
||||
|
||||
sid = irc.proto.spawnServer(servername, desc=desc)
|
||||
sid = irc.spawnServer(servername, desc=desc)
|
||||
|
||||
irc.callHooks([irc.pseudoclient.uid, 'OPERCMDS_SPAWNSERVER',
|
||||
{'name': servername, 'sid': sid, 'text': desc}])
|
||||
@ -104,7 +104,7 @@ def kick(irc, source, args):
|
||||
return
|
||||
|
||||
sender = irc.pseudoclient.uid
|
||||
irc.proto.kick(sender, channel, targetu, reason)
|
||||
irc.kick(sender, channel, targetu, reason)
|
||||
irc.reply("Done.")
|
||||
irc.callHooks([sender, 'CHANCMDS_KICK', {'channel': channel, 'target': targetu,
|
||||
'text': reason, 'parse_as': 'KICK'}])
|
||||
@ -132,7 +132,7 @@ def kill(irc, source, args):
|
||||
irc.error("No such nick '%s'." % target)
|
||||
return
|
||||
|
||||
irc.proto.kill(sender, targetu, reason)
|
||||
irc.kill(sender, targetu, reason)
|
||||
|
||||
# Format the kill reason properly in hooks.
|
||||
reason = "Killed (%s (%s))" % (irc.getFriendlyName(sender), reason)
|
||||
@ -173,7 +173,7 @@ def mode(irc, source, args):
|
||||
irc.error("No valid modes were given.")
|
||||
return
|
||||
|
||||
irc.proto.mode(irc.pseudoclient.uid, target, parsedmodes)
|
||||
irc.mode(irc.pseudoclient.uid, target, parsedmodes)
|
||||
|
||||
# Call the appropriate hooks for plugins like relay.
|
||||
irc.callHooks([irc.pseudoclient.uid, 'OPERCMDS_MODEOVERRIDE',
|
||||
@ -198,7 +198,7 @@ def topic(irc, source, args):
|
||||
irc.error("Unknown channel %r." % channel)
|
||||
return
|
||||
|
||||
irc.proto.topic(irc.pseudoclient.uid, channel, topic)
|
||||
irc.topic(irc.pseudoclient.uid, channel, topic)
|
||||
|
||||
irc.reply("Done.")
|
||||
irc.callHooks([irc.pseudoclient.uid, 'CHANCMDS_TOPIC',
|
||||
|
104
plugins/relay.py
104
plugins/relay.py
@ -117,7 +117,7 @@ def normalize_nick(irc, netname, nick, times_tagged=0, uid=''):
|
||||
# Charybdis, IRCu, etc. don't allow / in nicks, and will SQUIT with a protocol
|
||||
# violation if it sees one. Or it might just ignore the client introduction and
|
||||
# cause bad desyncs.
|
||||
protocol_allows_slashes = irc.proto.hasCap('slash-in-nicks') or \
|
||||
protocol_allows_slashes = irc.hasCap('slash-in-nicks') or \
|
||||
irc.serverdata.get('relay_force_slashes')
|
||||
|
||||
if '/' not in separator or not protocol_allows_slashes:
|
||||
@ -176,11 +176,11 @@ def normalize_host(irc, host):
|
||||
log.debug('(%s) relay.normalize_host: IRCd=%s, host=%s', irc.name, irc.protoname, host)
|
||||
|
||||
allowed_chars = string.ascii_letters + string.digits + '-.:'
|
||||
if irc.proto.hasCap('slash-in-hosts'):
|
||||
if irc.hasCap('slash-in-hosts'):
|
||||
# UnrealIRCd and IRCd-Hybrid don't allow slashes in hostnames
|
||||
allowed_chars += '/'
|
||||
|
||||
if irc.proto.hasCap('underscore-in-hosts'):
|
||||
if irc.hasCap('underscore-in-hosts'):
|
||||
# Most IRCds allow _ in hostnames, but hybrid/charybdis/ratbox IRCds do not.
|
||||
allowed_chars += '_'
|
||||
|
||||
@ -219,7 +219,7 @@ def spawn_relay_server(irc, remoteirc):
|
||||
suffix = conf.conf.get('relay', {}).get('server_suffix', 'relay')
|
||||
# Strip any leading or trailing .'s
|
||||
suffix = suffix.strip('.')
|
||||
sid = irc.proto.spawnServer('%s.%s' % (remoteirc.name, suffix),
|
||||
sid = irc.spawnServer('%s.%s' % (remoteirc.name, suffix),
|
||||
desc="PyLink Relay network - %s" %
|
||||
(remoteirc.getFullNetworkName()), endburst_delay=3)
|
||||
except (RuntimeError, ValueError): # Network not initialized yet, or a server name conflict.
|
||||
@ -326,14 +326,14 @@ def spawn_relay_user(irc, remoteirc, user, times_tagged=0):
|
||||
realhost = None
|
||||
ip = '0.0.0.0'
|
||||
|
||||
u = remoteirc.proto.spawnClient(nick, ident=ident, host=host, realname=realname, modes=modes,
|
||||
u = remoteirc.spawnClient(nick, ident=ident, host=host, realname=realname, modes=modes,
|
||||
opertype=opertype, server=rsid, ip=ip, realhost=realhost).uid
|
||||
try:
|
||||
remoteirc.users[u].remote = (irc.name, user)
|
||||
remoteirc.users[u].opertype = opertype
|
||||
away = userobj.away
|
||||
if away:
|
||||
remoteirc.proto.away(u, away)
|
||||
remoteirc.away(u, away)
|
||||
except KeyError:
|
||||
# User got killed somehow while we were setting options on it.
|
||||
# This is probably being done by the uplink, due to something like an
|
||||
@ -477,7 +477,7 @@ def initialize_channel(irc, channel):
|
||||
# Only update the topic if it's different from what we already have,
|
||||
# and topic bursting is complete.
|
||||
if remoteirc.channels[remotechan].topicset and topic != irc.channels[channel].topic:
|
||||
irc.proto.topicBurst(irc.sid, channel, topic)
|
||||
irc.topicBurst(irc.sid, channel, topic)
|
||||
|
||||
# Send our users and channel modes to the other nets
|
||||
log.debug('(%s) relay.initialize_channel: joining our (%s) users: %s', irc.name, remotenet, irc.channels[channel].users)
|
||||
@ -494,7 +494,7 @@ def remove_channel(irc, channel):
|
||||
if channel not in map(str.lower, irc.serverdata.get('channels', [])):
|
||||
world.services['pylink'].extra_channels[irc.name].discard(channel)
|
||||
if irc.pseudoclient:
|
||||
irc.proto.part(irc.pseudoclient.uid, channel, 'Channel delinked.')
|
||||
irc.part(irc.pseudoclient.uid, channel, 'Channel delinked.')
|
||||
|
||||
relay = get_relay((irc.name, channel))
|
||||
if relay:
|
||||
@ -506,12 +506,12 @@ def remove_channel(irc, channel):
|
||||
if user == irc.pseudoclient.uid and channel in \
|
||||
irc.serverdata.get('channels', []):
|
||||
continue
|
||||
irc.proto.part(user, channel, 'Channel delinked.')
|
||||
irc.part(user, channel, 'Channel delinked.')
|
||||
# Don't ever quit it either...
|
||||
if user != irc.pseudoclient.uid and not irc.users[user].channels:
|
||||
remoteuser = get_orig_user(irc, user)
|
||||
del relayusers[remoteuser][irc.name]
|
||||
irc.proto.quit(user, 'Left all shared channels.')
|
||||
irc.quit(user, 'Left all shared channels.')
|
||||
|
||||
def check_claim(irc, channel, sender, chanobj=None):
|
||||
"""
|
||||
@ -648,7 +648,7 @@ def relay_joins(irc, channel, users, ts, burst=True):
|
||||
|
||||
# Fetch the known channel TS and all the prefix modes for each user. This ensures
|
||||
# the different sides of the relay are merged properly.
|
||||
if not irc.proto.hasCap('has-ts'):
|
||||
if not irc.hasCap('has-ts'):
|
||||
# Special hack for clientbot: just use the remote's modes so mode changes
|
||||
# take precendence. (TS is always outside the clientbot's control)
|
||||
ts = remoteirc.channels[remotechan].ts
|
||||
@ -668,10 +668,10 @@ def relay_joins(irc, channel, users, ts, burst=True):
|
||||
modes = get_supported_cmodes(irc, remoteirc, channel, irc.channels[channel].modes)
|
||||
rsid = get_remote_sid(remoteirc, irc)
|
||||
if rsid:
|
||||
remoteirc.proto.sjoin(rsid, remotechan, queued_users, ts=ts, modes=modes)
|
||||
remoteirc.sjoin(rsid, remotechan, queued_users, ts=ts, modes=modes)
|
||||
else:
|
||||
# A regular JOIN only needs the user and the channel. TS, source SID, etc., can all be omitted.
|
||||
remoteirc.proto.join(queued_users[0][1], remotechan)
|
||||
remoteirc.join(queued_users[0][1], remotechan)
|
||||
|
||||
joined_nets[remoteirc] = {'channel': remotechan, 'users': [u[-1] for u in queued_users]}
|
||||
|
||||
@ -701,11 +701,11 @@ def relay_part(irc, channel, user):
|
||||
continue
|
||||
|
||||
# Part the relay client with the channel delinked message.
|
||||
remoteirc.proto.part(remoteuser, remotechan, 'Channel delinked.')
|
||||
remoteirc.part(remoteuser, remotechan, 'Channel delinked.')
|
||||
|
||||
# If the relay client no longer has any channels, quit them to prevent inflating /lusers.
|
||||
if isRelayClient(remoteirc, remoteuser) and not remoteirc.users[remoteuser].channels:
|
||||
remoteirc.proto.quit(remoteuser, 'Left all shared channels.')
|
||||
remoteirc.quit(remoteuser, 'Left all shared channels.')
|
||||
del relayusers[(irc.name, user)][remoteirc.name]
|
||||
|
||||
|
||||
@ -783,7 +783,7 @@ def get_supported_cmodes(irc, remoteirc, channel, modes):
|
||||
"for network %r.",
|
||||
irc.name, modechar, arg, remoteirc.name)
|
||||
|
||||
if (not irc.proto.hasCap('can-spawn-clients')) and irc.pseudoclient and arg == irc.pseudoclient.uid:
|
||||
if (not irc.hasCap('can-spawn-clients')) and irc.pseudoclient and arg == irc.pseudoclient.uid:
|
||||
# Skip modesync on the main PyLink client.
|
||||
log.debug("(%s) relay.get_supported_cmodes: filtering prefix change (%r, %r) on Clientbot relayer",
|
||||
irc.name, name, arg)
|
||||
@ -848,7 +848,7 @@ def handle_relay_whois(irc, source, command, args):
|
||||
"""Convenience wrapper to return WHOIS replies."""
|
||||
# WHOIS replies are by convention prefixed with the target user's nick.
|
||||
text = '%s %s' % (targetuser.nick, text)
|
||||
irc.proto.numeric(server, num, source, text)
|
||||
irc.numeric(server, num, source, text)
|
||||
|
||||
def checkSendKey(infoline):
|
||||
"""
|
||||
@ -876,7 +876,7 @@ def handle_relay_whois(irc, source, command, args):
|
||||
# Send account information if told to and the target is logged in.
|
||||
wreply(330, "%s :is logged in (on %s) as" % (realuser.services_account, netname))
|
||||
|
||||
if checkSendKey('whois_show_server') and realirc.proto.hasCap('can-track-servers'):
|
||||
if checkSendKey('whois_show_server') and realirc.hasCap('can-track-servers'):
|
||||
wreply(320, ":is actually connected via the following server:")
|
||||
realserver = realirc.getServer(uid)
|
||||
realserver = realirc.servers[realserver]
|
||||
@ -936,7 +936,7 @@ def handle_join(irc, numeric, command, args):
|
||||
|
||||
if modes:
|
||||
log.debug('(%s) relay.handle_join: reverting modes on BURST: %s', irc.name, irc.joinModes(modes))
|
||||
irc.proto.mode(irc.sid, channel, modes)
|
||||
irc.mode(irc.sid, channel, modes)
|
||||
|
||||
relay_joins(irc, channel, users, ts, burst=False)
|
||||
utils.add_hook(handle_join, 'JOIN')
|
||||
@ -950,7 +950,7 @@ def handle_quit(irc, numeric, command, args):
|
||||
for netname, user in relayusers[(irc.name, numeric)].copy().items():
|
||||
remoteirc = world.networkobjects[netname]
|
||||
try: # Try to quit the client. If this fails because they're missing, bail.
|
||||
remoteirc.proto.quit(user, args['text'])
|
||||
remoteirc.quit(user, args['text'])
|
||||
except LookupError:
|
||||
pass
|
||||
del relayusers[(irc.name, numeric)]
|
||||
@ -1007,7 +1007,7 @@ def handle_nick(irc, numeric, command, args):
|
||||
remoteirc = world.networkobjects[netname]
|
||||
newnick = normalize_nick(remoteirc, irc.name, args['newnick'], uid=user)
|
||||
if remoteirc.users[user].nick != newnick:
|
||||
remoteirc.proto.nick(user, newnick)
|
||||
remoteirc.nick(user, newnick)
|
||||
utils.add_hook(handle_nick, 'NICK')
|
||||
|
||||
def handle_part(irc, numeric, command, args):
|
||||
@ -1017,14 +1017,14 @@ def handle_part(irc, numeric, command, args):
|
||||
if numeric == irc.pseudoclient.uid:
|
||||
# For clientbot: treat forced parts to the bot as clearchan, and attempt to rejoin only
|
||||
# if it affected a relay.
|
||||
if not irc.proto.hasCap('can-spawn-clients'):
|
||||
if not irc.hasCap('can-spawn-clients'):
|
||||
for channel in [c for c in channels if get_relay((irc.name, c))]:
|
||||
for user in irc.channels[channel].users:
|
||||
if (not irc.isInternalClient(user)) and (not isRelayClient(irc, user)):
|
||||
irc.callHooks([irc.sid, 'CLIENTBOT_SERVICE_KICKED', {'channel': channel, 'target': user,
|
||||
'text': 'Clientbot was force parted (Reason: %s)' % text or 'None',
|
||||
'parse_as': 'KICK'}])
|
||||
irc.proto.join(irc.pseudoclient.uid, channel)
|
||||
irc.join(irc.pseudoclient.uid, channel)
|
||||
|
||||
return
|
||||
return
|
||||
@ -1035,9 +1035,9 @@ def handle_part(irc, numeric, command, args):
|
||||
remotechan = get_remote_channel(irc, remoteirc, channel)
|
||||
if remotechan is None:
|
||||
continue
|
||||
remoteirc.proto.part(user, remotechan, text)
|
||||
remoteirc.part(user, remotechan, text)
|
||||
if not remoteirc.users[user].channels:
|
||||
remoteirc.proto.quit(user, 'Left all shared channels.')
|
||||
remoteirc.quit(user, 'Left all shared channels.')
|
||||
del relayusers[(irc.name, numeric)][remoteirc.name]
|
||||
utils.add_hook(handle_part, 'PART')
|
||||
|
||||
@ -1120,9 +1120,9 @@ def handle_messages(irc, numeric, command, args):
|
||||
|
||||
try:
|
||||
if notice:
|
||||
remoteirc.proto.notice(user, real_target, real_text)
|
||||
remoteirc.notice(user, real_target, real_text)
|
||||
else:
|
||||
remoteirc.proto.message(user, real_target, real_text)
|
||||
remoteirc.message(user, real_target, real_text)
|
||||
except LookupError:
|
||||
# Our relay clone disappeared while we were trying to send the message.
|
||||
# This is normally due to a nick conflict with the IRCd.
|
||||
@ -1149,7 +1149,7 @@ def handle_messages(irc, numeric, command, args):
|
||||
return
|
||||
remoteirc = world.networkobjects[homenet]
|
||||
|
||||
if (not remoteirc.proto.hasCap('can-spawn-clients')) and not conf.conf.get('relay', {}).get('allow_clientbot_pms'):
|
||||
if (not remoteirc.hasCap('can-spawn-clients')) and not conf.conf.get('relay', {}).get('allow_clientbot_pms'):
|
||||
irc.msg(numeric, 'Private messages to users connected via Clientbot have '
|
||||
'been administratively disabled.', notice=True)
|
||||
return
|
||||
@ -1158,9 +1158,9 @@ def handle_messages(irc, numeric, command, args):
|
||||
|
||||
try:
|
||||
if notice:
|
||||
remoteirc.proto.notice(user, real_target, text)
|
||||
remoteirc.notice(user, real_target, text)
|
||||
else:
|
||||
remoteirc.proto.message(user, real_target, text)
|
||||
remoteirc.message(user, real_target, text)
|
||||
except LookupError:
|
||||
# Our relay clone disappeared while we were trying to send the message.
|
||||
# This is normally due to a nick conflict with the IRCd.
|
||||
@ -1180,7 +1180,7 @@ def handle_kick(irc, source, command, args):
|
||||
relay = get_relay((irc.name, channel))
|
||||
|
||||
# Special case for clientbot: treat kicks to the PyLink service bot as channel clear.
|
||||
if (not irc.proto.hasCap('can-spawn-clients')) and irc.pseudoclient and target == irc.pseudoclient.uid:
|
||||
if (not irc.hasCap('can-spawn-clients')) and irc.pseudoclient and target == irc.pseudoclient.uid:
|
||||
for user in irc.channels[channel].users:
|
||||
if (not irc.isInternalClient(user)) and (not isRelayClient(irc, user)):
|
||||
reason = "Clientbot kicked by %s (Reason: %s)" % (irc.getFriendlyName(source), text)
|
||||
@ -1222,7 +1222,7 @@ def handle_kick(irc, source, command, args):
|
||||
# kick ops, admins can't kick owners, etc.
|
||||
modes = get_prefix_modes(remoteirc, irc, remotechan, real_target)
|
||||
# Join the kicked client back with its respective modes.
|
||||
irc.proto.sjoin(irc.sid, channel, [(modes, target)])
|
||||
irc.sjoin(irc.sid, channel, [(modes, target)])
|
||||
if kicker in irc.users:
|
||||
log.info('(%s) relay: Blocked KICK (reason %r) from %s/%s to relay client %s on %s.',
|
||||
irc.name, args['text'], irc.users[source].nick, irc.name,
|
||||
@ -1241,13 +1241,13 @@ def handle_kick(irc, source, command, args):
|
||||
# Propogate the kick!
|
||||
if real_kicker:
|
||||
log.debug('(%s) relay.handle_kick: Kicking %s from channel %s via %s on behalf of %s/%s', irc.name, real_target, remotechan,real_kicker, kicker, irc.name)
|
||||
remoteirc.proto.kick(real_kicker, remotechan, real_target, args['text'])
|
||||
remoteirc.kick(real_kicker, remotechan, real_target, args['text'])
|
||||
else:
|
||||
# Kick originated from a server, or the kicker isn't in any
|
||||
# common channels with the target relay network.
|
||||
rsid = get_remote_sid(remoteirc, irc)
|
||||
log.debug('(%s) relay.handle_kick: Kicking %s from channel %s via %s on behalf of %s/%s', irc.name, real_target, remotechan, rsid, kicker, irc.name)
|
||||
if not irc.proto.hasCap('can-spawn-clients'):
|
||||
if not irc.hasCap('can-spawn-clients'):
|
||||
# Special case for clientbot: no kick prefixes are needed.
|
||||
text = args['text']
|
||||
else:
|
||||
@ -1260,16 +1260,16 @@ def handle_kick(irc, source, command, args):
|
||||
except AttributeError:
|
||||
text = "(<unknown kicker>@%s) %s" % (irc.name, args['text'])
|
||||
rsid = rsid or remoteirc.sid # Fall back to the main PyLink SID if get_remote_sid() fails
|
||||
remoteirc.proto.kick(rsid, remotechan, real_target, text)
|
||||
remoteirc.kick(rsid, remotechan, real_target, text)
|
||||
|
||||
# If the target isn't on any channels, quit them.
|
||||
if remoteirc != irc and (not remoteirc.users[real_target].channels) and not origuser:
|
||||
del relayusers[(irc.name, target)][remoteirc.name]
|
||||
remoteirc.proto.quit(real_target, 'Left all shared channels.')
|
||||
remoteirc.quit(real_target, 'Left all shared channels.')
|
||||
|
||||
if origuser and not irc.users[target].channels:
|
||||
del relayusers[origuser][irc.name]
|
||||
irc.proto.quit(target, 'Left all shared channels.')
|
||||
irc.quit(target, 'Left all shared channels.')
|
||||
|
||||
utils.add_hook(handle_kick, 'KICK')
|
||||
|
||||
@ -1292,7 +1292,7 @@ def handle_chgclient(irc, source, command, args):
|
||||
newtext = normalize_host(remoteirc, text)
|
||||
else: # Don't overwrite the original text variable on every iteration.
|
||||
newtext = text
|
||||
remoteirc.proto.updateClient(user, field, newtext)
|
||||
remoteirc.updateClient(user, field, newtext)
|
||||
except NotImplementedError: # IRCd doesn't support changing the field we want
|
||||
log.debug('(%s) relay.handle_chgclient: Ignoring changing field %r of %s on %s (for %s/%s);'
|
||||
' remote IRCd doesn\'t support it', irc.name, field,
|
||||
@ -1322,17 +1322,17 @@ def handle_mode(irc, numeric, command, args):
|
||||
# from the corresponding server.
|
||||
u = get_remote_user(irc, remoteirc, numeric, spawn_if_missing=False)
|
||||
if u:
|
||||
remoteirc.proto.mode(u, remotechan, supported_modes)
|
||||
remoteirc.mode(u, remotechan, supported_modes)
|
||||
else:
|
||||
rsid = get_remote_sid(remoteirc, irc)
|
||||
rsid = rsid or remoteirc.sid
|
||||
remoteirc.proto.mode(rsid, remotechan, supported_modes)
|
||||
remoteirc.mode(rsid, remotechan, supported_modes)
|
||||
else: # Mode change blocked by CLAIM.
|
||||
reversed_modes = irc.reverseModes(target, modes, oldobj=oldchan)
|
||||
log.debug('(%s) relay.handle_mode: Reversing mode changes of %r with %r (CLAIM).',
|
||||
irc.name, modes, reversed_modes)
|
||||
if reversed_modes:
|
||||
irc.proto.mode(irc.sid, target, reversed_modes)
|
||||
irc.mode(irc.sid, target, reversed_modes)
|
||||
break
|
||||
|
||||
else:
|
||||
@ -1350,7 +1350,7 @@ def handle_mode(irc, numeric, command, args):
|
||||
remoteuser = get_remote_user(irc, remoteirc, target, spawn_if_missing=False)
|
||||
|
||||
if remoteuser and modes:
|
||||
remoteirc.proto.mode(remoteuser, remoteuser, modes)
|
||||
remoteirc.mode(remoteuser, remoteuser, modes)
|
||||
|
||||
utils.add_hook(handle_mode, 'MODE')
|
||||
|
||||
@ -1370,12 +1370,12 @@ def handle_topic(irc, numeric, command, args):
|
||||
# This might originate from a server too.
|
||||
remoteuser = get_remote_user(irc, remoteirc, numeric, spawn_if_missing=False)
|
||||
if remoteuser:
|
||||
remoteirc.proto.topic(remoteuser, remotechan, topic)
|
||||
remoteirc.topic(remoteuser, remotechan, topic)
|
||||
else:
|
||||
rsid = get_remote_sid(remoteirc, irc)
|
||||
remoteirc.proto.topicBurst(rsid, remotechan, topic)
|
||||
remoteirc.topicBurst(rsid, remotechan, topic)
|
||||
elif oldtopic: # Topic change blocked by claim.
|
||||
irc.proto.topicBurst(irc.sid, channel, oldtopic)
|
||||
irc.topicBurst(irc.sid, channel, oldtopic)
|
||||
|
||||
utils.add_hook(handle_topic, 'TOPIC')
|
||||
|
||||
@ -1403,7 +1403,7 @@ def handle_kill(irc, numeric, command, args):
|
||||
modes = get_prefix_modes(remoteirc, irc, remotechan, realuser[1])
|
||||
log.debug('(%s) relay.handle_kill: userpair: %s, %s', irc.name, modes, realuser)
|
||||
client = get_remote_user(remoteirc, irc, realuser[1], times_tagged=1)
|
||||
irc.proto.sjoin(get_remote_sid(irc, remoteirc), localchan, [(modes, client)])
|
||||
irc.sjoin(get_remote_sid(irc, remoteirc), localchan, [(modes, client)])
|
||||
|
||||
if userdata and numeric in irc.users:
|
||||
log.info('(%s) relay.handle_kill: Blocked KILL (reason %r) from %s to relay client %s/%s.',
|
||||
@ -1432,7 +1432,7 @@ utils.add_hook(handle_kill, 'KILL')
|
||||
def handle_away(irc, numeric, command, args):
|
||||
for netname, user in relayusers[(irc.name, numeric)].items():
|
||||
remoteirc = world.networkobjects[netname]
|
||||
remoteirc.proto.away(user, args['text'])
|
||||
remoteirc.away(user, args['text'])
|
||||
utils.add_hook(handle_away, 'AWAY')
|
||||
|
||||
def handle_invite(irc, source, command, args):
|
||||
@ -1453,7 +1453,7 @@ def handle_invite(irc, source, command, args):
|
||||
'channel not on their network!',
|
||||
notice=True)
|
||||
else:
|
||||
remoteirc.proto.invite(remotesource, remoteuser,
|
||||
remoteirc.invite(remotesource, remoteuser,
|
||||
remotechan)
|
||||
utils.add_hook(handle_invite, 'INVITE')
|
||||
|
||||
@ -1540,7 +1540,7 @@ def nick_collide(irc, target):
|
||||
newnick = normalize_nick(irc, remotenet, nick, times_tagged=1)
|
||||
log.debug('(%s) relay.nick_collide: Fixing nick of relay client %r (%s) to %s',
|
||||
irc.name, target, nick, newnick)
|
||||
irc.proto.nick(target, newnick)
|
||||
irc.nick(target, newnick)
|
||||
|
||||
def handle_save(irc, numeric, command, args):
|
||||
target = args['target']
|
||||
@ -1582,7 +1582,7 @@ def create(irc, source, args):
|
||||
if not utils.isChannel(channel):
|
||||
irc.error('Invalid channel %r.' % channel)
|
||||
return
|
||||
if not irc.proto.hasCap('can-host-relay'):
|
||||
if not irc.hasCap('can-host-relay'):
|
||||
irc.error('Clientbot networks cannot be used to host a relay.')
|
||||
return
|
||||
if source not in irc.channels[channel].users:
|
||||
@ -1723,7 +1723,7 @@ def link(irc, source, args):
|
||||
# Special case for Clientbot: join the requested channel first, then
|
||||
# require that the caller be opped.
|
||||
if localchan not in irc.pseudoclient.channels:
|
||||
irc.proto.join(irc.pseudoclient.uid, localchan)
|
||||
irc.join(irc.pseudoclient.uid, localchan)
|
||||
irc.reply('Joining %r now to check for op status; please run this command again after I join.' % localchan)
|
||||
return
|
||||
elif not irc.channels[localchan].isOpPlus(source):
|
||||
@ -1774,7 +1774,7 @@ def link(irc, source, args):
|
||||
|
||||
our_ts = irc.channels[localchan].ts
|
||||
their_ts = world.networkobjects[remotenet].channels[channel].ts
|
||||
if (our_ts < their_ts) and irc.proto.hasCap('has-ts'):
|
||||
if (our_ts < their_ts) and irc.hasCap('has-ts'):
|
||||
log.debug('(%s) relay: Blocking link request %s%s -> %s%s due to bad TS (%s < %s)', irc.name,
|
||||
irc.name, localchan, remotenet, args.channel, our_ts, their_ts)
|
||||
irc.error("The channel creation date (TS) on %s (%s) is lower than the target "
|
||||
|
@ -204,7 +204,7 @@ def rpm(irc, source, args):
|
||||
return
|
||||
|
||||
relay = world.plugins.get('relay')
|
||||
if irc.proto.hasCap('can-spawn-clients'):
|
||||
if irc.hasCap('can-spawn-clients'):
|
||||
irc.error('This command is only supported on Clientbot networks. Try /msg %s <text>' % target)
|
||||
return
|
||||
elif relay is None:
|
||||
|
@ -78,7 +78,7 @@ def _map(irc, source, args, show_relay=True):
|
||||
# This is a relay server - display the remote map of the network it represents
|
||||
relay_server = serverlist[leaf].remote
|
||||
remoteirc = world.networkobjects[relay_server]
|
||||
if remoteirc.proto.hasCap('can-track-servers'):
|
||||
if remoteirc.hasCap('can-track-servers'):
|
||||
# Only ever show relay subservers once - this prevents infinite loops.
|
||||
showall(remoteirc, remoteirc.sid, hops=hops, is_relay_server=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user