3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

commands: Add a shutdown command (#82)

Sometimes exiting takes a little time, possibly from waiting for sockets to close?
This commit is contained in:
James Lu 2015-09-02 23:46:59 -07:00
parent 2c4a88b9be
commit 2777b88d33

View File

@ -125,3 +125,17 @@ def showuser(irc, source, args):
f('\x02Real host\x02: %s; \x02IP\x02: %s; \x02Away status\x02: %s' % \
(userobj.realhost, userobj.ip, userobj.away or '\x1D(not set)\x1D'))
f('\x02Channels\x02: %s' % (' '.join(userobj.channels).strip() or '\x1D(none)\x1D'))
@utils.add_cmd
def shutdown(irc, source, args):
"""takes no arguments.
Exits PyLink by disconnecting all networks."""
utils.checkAuthenticated(irc, source, allowOper=False)
u = irc.users[source]
log.info('(%s) SHUTDOWN requested by "%s!%s@%s", exiting...', irc.name, u.nick,
u.ident, u.host)
for ircobj in world.networkobjects.values():
# Disable auto-connect first by setting the time to negative.
ircobj.serverdata['autoconnect'] = -1
ircobj.aborted.set()