mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 14:49:28 +01:00
Add a useful "version" command
This commit is contained in:
parent
0d207f7d08
commit
0f26848b16
@ -185,3 +185,11 @@ def shutdown(irc, source, args):
|
||||
# Disable auto-connect first by setting the time to negative.
|
||||
ircobj.serverdata['autoconnect'] = -1
|
||||
ircobj.aborted.set()
|
||||
|
||||
@utils.add_cmd
|
||||
def version(irc, source, args):
|
||||
"""takes no arguments.
|
||||
|
||||
Returns the version of the currently running PyLink instance."""
|
||||
irc.msg(source, "PyLink version \x02%s\x02, released under the Mozilla Public License version 2.0." % world.version)
|
||||
irc.msg(source, "The source of this program is available at \x02%s\x02." % world.source)
|
||||
|
3
pylink
3
pylink
@ -14,7 +14,7 @@ import classes
|
||||
import coreplugin
|
||||
|
||||
if __name__ == '__main__':
|
||||
log.info('PyLink starting...')
|
||||
log.info('PyLink %s starting...', world.version)
|
||||
if conf.conf['login']['password'] == 'changeme':
|
||||
log.critical("You have not set the login details correctly! Exiting...")
|
||||
sys.exit(2)
|
||||
@ -61,4 +61,3 @@ if __name__ == '__main__':
|
||||
world.networkobjects[network] = classes.Irc(network, proto)
|
||||
world.started.set()
|
||||
log.info("loaded plugins: %s", world.plugins)
|
||||
|
||||
|
12
world.py
12
world.py
@ -2,6 +2,7 @@
|
||||
|
||||
from collections import defaultdict
|
||||
import threading
|
||||
import subprocess
|
||||
|
||||
# Global variable to indicate whether we're being ran directly, or imported
|
||||
# for a testcase.
|
||||
@ -16,3 +17,14 @@ schedulers = {}
|
||||
plugins = []
|
||||
whois_handlers = []
|
||||
started = threading.Event()
|
||||
|
||||
version = "<unknown>"
|
||||
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
|
||||
|
||||
# Only run this once.
|
||||
if version == "<unknown>":
|
||||
# Get version from Git tags.
|
||||
try:
|
||||
version = 'v' + subprocess.check_output(['git', 'describe', '--tags']).decode('utf-8').strip()
|
||||
except:
|
||||
log.exception('Failed to get version from "git describe --tags".')
|
||||
|
Loading…
Reference in New Issue
Block a user