3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-24 03:33:10 +01:00

Initial upload!

This commit is contained in:
James Lu 2015-03-19 12:55:18 -07:00
commit be3fe38206
5 changed files with 99 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
config.yml
build
__pycache__/
*.py[cod]
*.bak
*~
*.save*

18
README.md Normal file
View File

@ -0,0 +1,18 @@
# PyLink
PyLink is an IRC PseudoService written in Python that might one day be a replacement for the now defunct Janus.
## Dependencies
PyLink is a serious WIP right now (it doesn't even connect to any servers yet!). Dependencies currently include:
* Python 3.4
* PyYAML (`pip install pyyaml` or `apt-get install python3-yaml`)
## Usage
1) Rename `config.yml.example` to `config.yml` and configure your instance there. Of course, most of the options aren't implemented yet!
2) Run `pylink-main.py` from the command line.
3) Profit???

20
config.yml.example Normal file
View File

@ -0,0 +1,20 @@
bot:
# Set nick, user/ident, and real name.
nick: pylink
user: pylink
realname: PyLink Service Client
login:
# PyLink administrative login - Change this, or the service will not start!
user: admin
password: changeme
networks:
mynet:
# Server name, port, and passwords
ip: 127.0.0.1
port: 6667
recvpass: "abcdefg"
sendpass: "gfedcba"
# Set protocol module (currently only a null stub is available, but this will change in the future)
protocol: stub

5
protocols/stub.py Normal file
View File

@ -0,0 +1,5 @@
def connect(name, networkdata):
print('%s: Using PyLink stub/testing protocol.' % name)
print('Send password: %s' % networkdata['sendpass'])
print('Receive password: %s' % networkdata['recvpass'])
print('Server: %s:%s' % (networkdata['ip'], networkdata['port']))

49
pylink-main.py Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/python3
import yaml
import imp
import os
import importlib
import sys
print('PyLink starting...')
with open("config.yml", 'r') as f:
conf = yaml.load(f)
# if conf['login']['password'] == 'changeme':
# print("You have not set the login details correctly! Exiting...")
global networkobjects
networkobjects = {}
class irc:
def __init__(self, network):
self.netname = network
self.networkdata = conf['networks'][network]
protoname = self.networkdata['protocol']
# With the introduction of Python 3, relative imports are no longer
# allowed from normal applications ran from the command line. Instead,
# these imported libraries must be installed as a package using distutils
# or something similar.
#
# But I don't want that! Where PyLink is at right now (a total WIP), it is
# a lot more convenient to run the program directly from the source folder.
protocols_folder = [os.path.join(os.getcwd(), 'protocols')]
# Here, we override the module lookup and import the protocol module
# dynamically depending on which module was configured.
moduleinfo = imp.find_module(protoname, protocols_folder)
self.proto = imp.load_source(protoname, moduleinfo[1])
self.connect()
def connect(self):
self.proto.connect(self.netname, self.networkdata)
for network in conf['networks']:
print('Creating IRC Object for: %s' % network)
networkobjects[network] = irc(network)
# mod = sys.modules[plugin]