mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 11:09:22 +01:00
New import paths for properly installed pylinkirc
This commit is contained in:
parent
5f9c14ca18
commit
481d70eff8
@ -17,10 +17,8 @@ import hashlib
|
||||
from copy import deepcopy
|
||||
import inspect
|
||||
|
||||
from log import *
|
||||
import world
|
||||
import utils
|
||||
import structures
|
||||
from . import world, utils, structures
|
||||
from .log import *
|
||||
|
||||
### Exceptions
|
||||
|
||||
|
2
conf.py
2
conf.py
@ -17,7 +17,7 @@ import yaml
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
import world
|
||||
from . import world
|
||||
|
||||
global testconf
|
||||
testconf = {'bot':
|
||||
|
@ -7,11 +7,8 @@ import sys
|
||||
import signal
|
||||
import os
|
||||
|
||||
import utils
|
||||
import conf
|
||||
import classes
|
||||
from log import log
|
||||
import world
|
||||
from . import utils, conf, classes, world
|
||||
from .log import log
|
||||
|
||||
def _shutdown(irc=None):
|
||||
"""Shuts down the Pylink daemon."""
|
||||
|
4
log.py
4
log.py
@ -9,9 +9,9 @@ access the global logger object by importing "log" from this module
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
import world
|
||||
|
||||
from conf import conf, confname
|
||||
from . import world
|
||||
from .conf import conf, confname
|
||||
|
||||
stdout_level = conf['logging'].get('stdout') or 'INFO'
|
||||
|
||||
|
@ -2,13 +2,8 @@
|
||||
bots.py: Spawn virtual users/bots on a PyLink server and make them interact
|
||||
with things.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
@utils.add_cmd
|
||||
def spawnclient(irc, source, args):
|
||||
|
@ -1,11 +1,8 @@
|
||||
"""
|
||||
Changehost plugin - automatically changes the hostname of matching users.
|
||||
"""
|
||||
|
||||
# Import hacks to access utils and log.
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
|
||||
import string
|
||||
|
||||
@ -13,10 +10,6 @@ import string
|
||||
# (pip install ircmatch)
|
||||
import ircmatch
|
||||
|
||||
import utils
|
||||
import world
|
||||
from log import log
|
||||
|
||||
# Characters allowed in a hostname.
|
||||
allowed_chars = string.ascii_letters + '-./:' + string.digits
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
# commands.py: base PyLink commands
|
||||
import sys
|
||||
import os
|
||||
from time import ctime
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import utils
|
||||
from log import log
|
||||
import world
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
@utils.add_cmd
|
||||
def status(irc, source, args):
|
||||
|
@ -1,10 +1,6 @@
|
||||
# ctcp.py: Handles basic CTCP requests.
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
def handle_ctcpversion(irc, source, args):
|
||||
"""
|
||||
|
@ -1,12 +1,6 @@
|
||||
# example.py: An example PyLink plugin.
|
||||
|
||||
# These two lines add PyLink's root directory to the PATH, so that importing things like
|
||||
# 'utils' and 'log' work.
|
||||
import sys, os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
import random
|
||||
|
||||
|
@ -2,16 +2,11 @@
|
||||
exec.py: Provides commands for executing raw code and debugging PyLink.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
|
||||
# These imports are not strictly necessary, but make the following modules
|
||||
# easier to access through eval and exec.
|
||||
import world
|
||||
import threading
|
||||
import re
|
||||
import time
|
||||
|
@ -1,11 +1,6 @@
|
||||
# fantasy.py: Adds FANTASY command support, to allow calling commands in channels
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import utils
|
||||
import world
|
||||
from log import log
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
|
||||
def handle_fantasy(irc, source, command, args):
|
||||
"""Fantasy command handler."""
|
||||
|
@ -1,18 +1,13 @@
|
||||
"""
|
||||
games.py: Create a bot that provides game functionality (dice, 8ball, etc).
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import random
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
from xml.etree import ElementTree
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
import world
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
gameclient = utils.registerService("Games", manipulatable=True)
|
||||
reply = gameclient.reply # TODO find a better syntax for ServiceBot.reply()
|
||||
|
@ -1,14 +1,8 @@
|
||||
"""Networks plugin - allows you to manipulate connections to various configured networks."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import threading
|
||||
|
||||
import utils
|
||||
import world
|
||||
from log import log
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
|
||||
@utils.add_cmd
|
||||
def disconnect(irc, source, args):
|
||||
|
@ -2,11 +2,6 @@
|
||||
opercmds.py: Provides a subset of network management commands.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
# Add the base PyLink folder to path, so we can import utils and log.
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
# ircmatch library from https://github.com/mammon-ircd/ircmatch
|
||||
# (pip install ircmatch)
|
||||
try:
|
||||
@ -14,8 +9,8 @@ try:
|
||||
except ImportError:
|
||||
ircmatch = None
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
@utils.add_cmd
|
||||
def checkban(irc, source, args):
|
||||
|
@ -1,17 +1,12 @@
|
||||
# relay.py: PyLink Relay plugin
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import pickle
|
||||
import time
|
||||
import threading
|
||||
import string
|
||||
from collections import defaultdict
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
import world
|
||||
from pylinkirc import utils, world
|
||||
from pylinkirc.log import log
|
||||
|
||||
### GLOBAL (statekeeping) VARIABLES
|
||||
relayusers = defaultdict(dict)
|
||||
|
@ -1,12 +1,8 @@
|
||||
# servprotect.py: Protects against KILL and nick collision floods
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from expiringdict import ExpiringDict
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
|
||||
# TODO: make length and time configurable
|
||||
savecache = ExpiringDict(max_len=5, max_age_seconds=10)
|
||||
|
@ -3,13 +3,10 @@ import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
import utils
|
||||
from log import log
|
||||
|
||||
from classes import *
|
||||
from ts6 import *
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.protocols.ts6 import *
|
||||
|
||||
class HybridProtocol(TS6Protocol):
|
||||
def __init__(self, irc):
|
||||
|
@ -8,14 +8,10 @@ import os
|
||||
import re
|
||||
import threading
|
||||
|
||||
# Import hacks to access utils and classes...
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
import utils
|
||||
from log import log
|
||||
from classes import *
|
||||
|
||||
from ts6_common import *
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.protocols.ts6_common import *
|
||||
|
||||
class InspIRCdProtocol(TS6BaseProtocol):
|
||||
def __init__(self, irc):
|
||||
|
@ -8,13 +8,9 @@ import base64
|
||||
import struct
|
||||
from ipaddress import ip_address
|
||||
|
||||
# Import hacks to access utils and classes...
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from classes import *
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.log import log
|
||||
|
||||
class P10UIDGenerator(utils.IncrementalUIDGenerator):
|
||||
"""Implements an incremental P10 UID Generator."""
|
||||
|
@ -7,14 +7,10 @@ import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
# Import hacks to access utils and classes...
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
import utils
|
||||
from log import log
|
||||
|
||||
from classes import *
|
||||
from ts6_common import *
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.protocols.ts6_common import *
|
||||
|
||||
class TS6Protocol(TS6BaseProtocol):
|
||||
def __init__(self, irc):
|
||||
|
@ -6,14 +6,9 @@ import sys
|
||||
import os
|
||||
import string
|
||||
|
||||
# Import hacks to access utils and classes...
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from classes import *
|
||||
import structures
|
||||
from pylinkirc import utils, structures
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.log import log
|
||||
|
||||
class TS6SIDGenerator():
|
||||
"""
|
||||
|
@ -9,14 +9,10 @@ import codecs
|
||||
import socket
|
||||
import re
|
||||
|
||||
# Import hacks to access utils and classes...
|
||||
curdir = os.path.dirname(__file__)
|
||||
sys.path += [curdir, os.path.dirname(curdir)]
|
||||
|
||||
import utils
|
||||
from log import log
|
||||
from classes import *
|
||||
from ts6_common import *
|
||||
from pylinkirc import utils
|
||||
from pylinkirc.classes import *
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.protocols.ts6_common import *
|
||||
|
||||
class UnrealProtocol(TS6BaseProtocol):
|
||||
def __init__(self, irc):
|
||||
|
13
pylink
13
pylink
@ -1,20 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Change directory to the folder containing PyLink's source
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# This must be done before conf imports, so we get the real conf instead of testing one.
|
||||
import world
|
||||
from pylinkirc import world
|
||||
world.testing = False
|
||||
|
||||
import conf
|
||||
from log import log
|
||||
import classes
|
||||
import utils
|
||||
import coreplugin
|
||||
from pylinkirc import conf, classes, utils, coreplugin
|
||||
from pylinkirc.log import log
|
||||
|
||||
if __name__ == '__main__':
|
||||
log.info('PyLink %s starting...', world.version)
|
||||
|
4
setup.py
4
setup.py
@ -45,7 +45,7 @@ setup(
|
||||
install_requires=['pyyaml'],
|
||||
|
||||
# Folders (packages of code)
|
||||
packages=find_packages(exclude=['log', 'docs', 'tests']),
|
||||
packages=['pylinkirc', 'pylinkirc.protocols', 'pylinkirc.plugins'],
|
||||
|
||||
# Single modules. TODO: consider organizing this into a pylink/ folder
|
||||
py_modules=["classes", "conf", "coreplugin", "log", "structures", "utils", "world"],
|
||||
@ -55,6 +55,8 @@ setup(
|
||||
'': ['example-conf.yml'],
|
||||
},
|
||||
|
||||
package_dir = {'pylinkirc': '.'},
|
||||
|
||||
# Executable scripts
|
||||
scripts=["pylink"],
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user