uplink = None
modules = {}
-modules['q'] = (__import__('modules.q', globals(), locals(), ['Pseudo'], 0)).Pseudo()
class config(object):
name = 'services.p10'
'password': 'password',
'vhost': '', #bind to this ip - empty string '' for auto-select
}
+ autoload = ['q']
+
+b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]"
def process(line):
words = line.split()
if words[1] == "G" or words[1] == "PING":
uplink.send("Z %(numeric)s :%(id)s" % {'numeric': config.numeric, 'id': config.uplink['name']})
-class Server(object):
- def __init__(self, numeric, name):
- self.isuplink = False
- self.numeric = numeric
- self.name = name
- self.clients = {}
- def send(self, line, source=None, **kwargs):
- if source is None:
- source = config.numeric
- uplink._transmit(source+" "+(line % kwargs))
-
-class Uplink(Server):
- def __init__(self, *args, **kwargs):
+class Uplink(object):
+ def __init__(self):
global uplink
- super(Uplink, self).__init__(*args, **kwargs)
uplink = self
- self.isuplink = True
- self.data = ""
+
+ self.lastnum = None # last numeric used, as [int,int,int]
+ self.nicks = {} # 'nick': Pseudo-object
+ self.data = "" # receive buffer
self.sock = socket.socket()
self.sock.bind((config.uplink['vhost'], 0))
self._transmit("PASS %s" % (config.uplink['password']))
self._transmit("SERVER %(name)s 1 %(time)s %(time)s J10 %(numeric)s]]] +s :PyP10 Services" % {'name': config.name, 'time': time.time(), 'numeric': config.numeric})
self.send("EB")
- self.send("N Q 1 %(time)s q %(host)s +oknXr pyp10 DAqAAB ]SAAQ :Hax!", time=time.time(), host=config.name)
- self.send("J #p10 780000000", ']SAAQ')
+ def send(self, line, source=None, **kwargs):
+ if source is None:
+ source = config.numeric
+ self._transmit(source+" "+(line % kwargs))
def _transmit(self, line):
print ">", line
self.sock.sendall(line+"\r\n")
while keepgoing:
keepgoing = self._receive()
+ def _newnum(self):
+ if self.lastnum is None:
+ self.lastnum = [0,0,0]
+ else:
+ self.lastnum = [i+1 for i in lastnum]
+ num = config.numeric
+ num += b64[self.lastnum[2]]
+ num += b64[self.lastnum[1]]
+ num += b64[self.lastnum[0]]
+ return num
+
+ def makenick(self, obj, nick, ident, realname):
+ newnum = self._newnum()
+ self.send("N %(nick)s 1 %(time)s %(ident)s %(host)s +oknXr pyp10 DAqAAB %(num)s :%(name)s", nick=nick, ident=ident, name=realname, time=time.time(), host=config.name, num=newnum)
+ self.nicks[nick] = obj
+ return newnum
+
class Account(object):
pass
class Client(object):
pass
-uplink = Uplink(-1, '')
+uplink = Uplink()
+
+for modu in config.autoload:
+ modules[modu] = (__import__('modules.'+str(modu), globals(), locals(), ['Pseudo'], 0)).Pseudo(uplink)
+
uplink.loop()