mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
relay: rework fallback message routing to be less annoying (#384)
- PRIVMSGs from users not spawned on a network are sent via the main PyLink client in the format "<$orignick/$network> <$text>" - <PyLink> <user/net> blah blah - NOTICEs from users use the same format above, and are routed from the relay subserver representing the network that the message originated from - Notice(somenet.relay): <user/net> blah blah - PRIVMSGs from servers are blocked, because they aren't valid on all IRCds and are fairly obscure anyways (suggestsions/improvements welcome) - NOTICEs from servers are forwarded as raw text, from the relay subserver representing the origin network - Notice(somenet.relay): some server announcement
This commit is contained in:
parent
e936b9cfd2
commit
fa30d3c732
@ -1052,6 +1052,10 @@ def handle_messages(irc, numeric, command, args):
|
|||||||
# Drop attempted PMs between internal clients (this shouldn't happen,
|
# Drop attempted PMs between internal clients (this shouldn't happen,
|
||||||
# but whatever).
|
# but whatever).
|
||||||
return
|
return
|
||||||
|
elif (numeric in irc.servers) and (not notice):
|
||||||
|
log.warning('(%s) relay.handle_messages: dropping PM from server %s to %s',
|
||||||
|
irc.name, numeric, target)
|
||||||
|
return
|
||||||
|
|
||||||
relay = get_relay((irc.name, target))
|
relay = get_relay((irc.name, target))
|
||||||
remoteusers = relayusers[(irc.name, numeric)]
|
remoteusers = relayusers[(irc.name, numeric)]
|
||||||
@ -1079,15 +1083,23 @@ def handle_messages(irc, numeric, command, args):
|
|||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
# No relay clone exists for the sender; route the message through our
|
# No relay clone exists for the sender; route the message through our
|
||||||
# main client.
|
# main client (or SID for notices).
|
||||||
if numeric in irc.servers:
|
|
||||||
displayedname = irc.servers[numeric].name
|
|
||||||
else:
|
|
||||||
displayedname = irc.users[numeric].nick
|
|
||||||
|
|
||||||
real_text = '[from %s/%s] %s' % (displayedname, irc.name, text)
|
# Skip "from:" formatting for servers; it's messy with longer hostnames
|
||||||
|
if numeric not in irc.servers:
|
||||||
|
displayedname = irc.getFriendlyName(numeric)
|
||||||
|
real_text = '<%s/%s> %s' % (displayedname, irc.name, text)
|
||||||
|
else:
|
||||||
|
real_text = text
|
||||||
|
|
||||||
|
# XXX: perhaps consider routing messages from the server where
|
||||||
|
# possible - most IRCds except TS6 (charybdis, ratbox, hybrid)
|
||||||
|
# allow this.
|
||||||
try:
|
try:
|
||||||
user = remoteirc.pseudoclient.uid
|
user = get_remote_sid(remoteirc, irc, spawn_if_missing=False) \
|
||||||
|
if notice else remoteirc.pseudoclient.uid
|
||||||
|
if not user:
|
||||||
|
continue
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# Remote main client hasn't spawned yet. Drop the message.
|
# Remote main client hasn't spawned yet. Drop the message.
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user