mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
relay: store creator hostname in CREATE, code readability...
Closes #135.
This commit is contained in:
parent
62501ce8f2
commit
e97810e5f7
@ -1109,11 +1109,19 @@ def create(irc, source, args):
|
|||||||
irc.reply('Error: You must be in %r to complete this operation.' % channel)
|
irc.reply('Error: You must be in %r to complete this operation.' % channel)
|
||||||
return
|
return
|
||||||
utils.checkAuthenticated(irc, source)
|
utils.checkAuthenticated(irc, source)
|
||||||
|
|
||||||
|
# Check to see whether the channel requested is already part of a different
|
||||||
|
# relay.
|
||||||
localentry = getRelay((irc.name, channel))
|
localentry = getRelay((irc.name, channel))
|
||||||
if localentry:
|
if localentry:
|
||||||
irc.reply('Error: Channel %r is already part of a relay.' % channel)
|
irc.reply('Error: Channel %r is already part of a relay.' % channel)
|
||||||
return
|
return
|
||||||
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), 'blocked_nets': set()}
|
|
||||||
|
# Create the relay database entry with the (network name, channel name)
|
||||||
|
# pair - this is just a dict with various keys.
|
||||||
|
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(),
|
||||||
|
'blocked_nets': set(),
|
||||||
|
'creator': utils.getHostmask(irc, source)}
|
||||||
initializeChannel(irc, channel)
|
initializeChannel(irc, channel)
|
||||||
irc.reply('Done.')
|
irc.reply('Done.')
|
||||||
|
|
||||||
@ -1242,25 +1250,35 @@ def linked(irc, source, args):
|
|||||||
networks.remove(irc.name)
|
networks.remove(irc.name)
|
||||||
s = 'Connected networks: \x02%s\x02 %s' % (irc.name, ' '.join(networks))
|
s = 'Connected networks: \x02%s\x02 %s' % (irc.name, ' '.join(networks))
|
||||||
irc.msg(source, s)
|
irc.msg(source, s)
|
||||||
# Sort relay DB by channel name, and then sort.
|
|
||||||
for k, v in sorted(db.items(), key=lambda channel: channel[0][1]):
|
# Sort the list of shared channels when displaying
|
||||||
|
for k, v in sorted(db.items()):
|
||||||
|
# Bold each network/channel name pair
|
||||||
s = '\x02%s%s\x02 ' % k
|
s = '\x02%s%s\x02 ' % k
|
||||||
remoteirc = world.networkobjects.get(k[0])
|
remoteirc = world.networkobjects.get(k[0])
|
||||||
channel = k[1]
|
channel = k[1] # Get the channel name from the network/channel pair
|
||||||
if remoteirc and channel in remoteirc.channels:
|
if remoteirc and channel in remoteirc.channels:
|
||||||
c = remoteirc.channels[channel]
|
c = remoteirc.channels[channel]
|
||||||
if ('s', None) in c.modes or ('p', None) in c.modes:
|
if ('s', None) in c.modes or ('p', None) in c.modes:
|
||||||
# Only show hidden channels to opers.
|
# Only show secret channels to opers, and tag them with
|
||||||
|
# [secret].
|
||||||
if utils.isOper(irc, source):
|
if utils.isOper(irc, source):
|
||||||
s += '\x02[secret]\x02 '
|
s += '\x02[secret]\x02 '
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if v['links']:
|
|
||||||
|
if v['links']: # Join up and output all the linked channel names.
|
||||||
s += ' '.join([''.join(link) for link in v['links']])
|
s += ' '.join([''.join(link) for link in v['links']])
|
||||||
else:
|
else: # Unless it's empty; then, well... just say no relays yet.
|
||||||
s += '(no relays yet)'
|
s += '(no relays yet)'
|
||||||
|
|
||||||
irc.msg(source, s)
|
irc.msg(source, s)
|
||||||
|
|
||||||
|
if utils.isOper(irc, source):
|
||||||
|
# If the caller is an oper, we can show the hostmasks of people
|
||||||
|
# that created all the available channels (Janus does this too!!)
|
||||||
|
irc.msg(source, ' Channel created by \x02%s\x02.' % v.get('creator', '(N/A)'))
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def linkacl(irc, source, args):
|
def linkacl(irc, source, args):
|
||||||
"""ALLOW|DENY|LIST <channel> <remotenet>
|
"""ALLOW|DENY|LIST <channel> <remotenet>
|
||||||
|
Loading…
Reference in New Issue
Block a user