3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 11:39:25 +01:00

relay: log (de)linked, created, and destroyed channels to INFO

Closes #125.
This commit is contained in:
James Lu 2015-11-28 21:18:30 -08:00
parent e97810e5f7
commit f16edf6efc

View File

@ -1117,11 +1117,12 @@ def create(irc, source, args):
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
creator = utils.getHostmask(irc, source)
# Create the relay database entry with the (network name, channel name) # Create the relay database entry with the (network name, channel name)
# pair - this is just a dict with various keys. # pair - this is just a dict with various keys.
db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(), db[(irc.name, channel)] = {'claim': [irc.name], 'links': set(),
'blocked_nets': set(), 'blocked_nets': set(), 'creator': creator}
'creator': utils.getHostmask(irc, source)} log.info('(%s) relay: Channel %s created by %s.', irc.name, channel, creator)
initializeChannel(irc, channel) initializeChannel(irc, channel)
irc.reply('Done.') irc.reply('Done.')
@ -1147,6 +1148,8 @@ def destroy(irc, source, args):
removeChannel(irc, channel) removeChannel(irc, channel)
del db[entry] del db[entry]
irc.reply('Done.') irc.reply('Done.')
log.info('(%s) relay: Channel %s destroyed by %s.', irc.name,
channel, utils.getHostmask(irc, source))
else: else:
irc.reply('Error: No such relay %r exists.' % channel) irc.reply('Error: No such relay %r exists.' % channel)
return return
@ -1193,11 +1196,12 @@ def link(irc, source, args):
return return
for link in entry['links']: for link in entry['links']:
if link[0] == irc.name: if link[0] == irc.name:
irc.reply("Error: Remote channel '%s%s' is already" irc.reply("Error: Remote channel '%s%s' is already linked here "
" linked here as %r." % (remotenet, "as %r." % (remotenet, channel, link[1]))
channel, link[1]))
return return
entry['links'].add((irc.name, localchan)) entry['links'].add((irc.name, localchan))
log.info('(%s) relay: Channel %s linked to %s%s by %s.', irc.name,
localchan, remotenet, channel, utils.getHostmask(irc, source))
initializeChannel(irc, localchan) initializeChannel(irc, localchan)
irc.reply('Done.') irc.reply('Done.')
@ -1238,6 +1242,8 @@ def delink(irc, source, args):
removeChannel(irc, channel) removeChannel(irc, channel)
db[entry]['links'].remove((irc.name, channel)) db[entry]['links'].remove((irc.name, channel))
irc.reply('Done.') irc.reply('Done.')
log.info('(%s) relay: Channel %s delinked from %s%s by %s.', irc.name,
channel, entry[0], entry[1], utils.getHostmask(irc, source))
else: else:
irc.reply('Error: No such relay %r.' % channel) irc.reply('Error: No such relay %r.' % channel)