3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00
PyLink/world.py
James Lu 7d11f8c7e0 Begin work on service bot abstraction (#216)
- State-keeping is done by coreplugin
- utils.registerService() introduced
- new PYLINK_NEW_SERVICE hook introduced
2016-05-14 09:55:46 -07:00

40 lines
1.1 KiB
Python

"""
world.py: Stores global variables for PyLink, including lists of active IRC objects and plugins.
"""
from collections import defaultdict
import threading
import subprocess
import os
# Global variable to indicate whether we're being ran directly, or imported
# for a testcase. This defaults to True.
testing = True
# Sets the default protocol module to use with tests.
testing_ircd = 'inspircd'
commands = defaultdict(list)
hooks = defaultdict(list)
networkobjects = {}
plugins = {}
whois_handlers = []
services = {}
started = threading.Event()
plugins_folder = os.path.join(os.getcwd(), 'plugins')
protocols_folder = os.path.join(os.getcwd(), 'protocols')
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 Exception as e:
print('ERROR: Failed to get version from "git describe --tags": %s: %s' % (type(e).__name__, e))