13 'address': '127.0.0.1',
16 'password': 'password',
17 'vhost': '', #bind to this ip - empty string '' for auto-select
19 autoload
= ['q', 'do']
21 b64
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]"
29 self
.lastnum
= None # last numeric used, as [int,int,int]
30 self
.nicks
= {} # 'nick': Pseudo-object
31 self
.nums
= {} # 'num': Pseudo-object
32 self
.data
= "" # receive buffer
34 self
.sock
= socket
.socket()
35 self
.sock
.bind((config
.uplink
['vhost'], 0))
36 self
.sock
.connect((config
.uplink
['address'], config
.uplink
['port']))
38 self
._transmit
("PASS %s" % (config
.uplink
['password']))
39 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}
)
41 def send(self
, line
, source
=None, **kwargs
):
43 source
= config
.numeric
44 self
._transmit
(source
+" "+(line
% kwargs
))
45 def _transmit(self
, line
):
47 self
.sock
.sendall(line
+"\r\n")
49 self
.data
+= self
.sock
.recv(4096)
50 while "\n" in self
.data
:
51 pieces
= self
.data
.split("\n", 1)
52 line
= pieces
[0].strip()
60 keepgoing
= self
._receive
()
62 def _process(self
, line
):
64 if words
[1] == "G" or words
[1] == "PING":
65 self
.send("Z %(numeric)s :%(id)s" % {'numeric': config.numeric, 'id': config.uplink['name']}
)
66 elif words
[1] == "P" or words
[1] == "PRIVMSG":
69 extra
= ' '.join(words
[3:])
73 tonick
= target
.split('@', 1)
74 self
.nicks
[tonick
].gotmsg(extra
, source
, target
)
80 self
.nums
[target
].gotmsg(extra
, source
, target
)
82 if self
.lastnum
is None:
83 self
.lastnum
= [0,0,0]
85 self
.lastnum
= [i
+1 for i
in self
.lastnum
]
87 num
+= b64
[self
.lastnum
[2]]
88 num
+= b64
[self
.lastnum
[1]]
89 num
+= b64
[self
.lastnum
[0]]
92 def makenick(self
, obj
, nick
, ident
, realname
):
93 newnum
= self
._newnum
()
94 self
.send("N %(nick)s 1 %(time)s %(ident)s %(host)s +doknXr pyp10 DAqAAB %(num)s :%(name)s", nick
=nick
, ident
=ident
, name
=realname
, time
=time
.time(), host
=config
.name
, num
=newnum
)
95 self
.nums
[newnum
] = obj
96 self
.nicks
[nick
] = obj
100 class Account(object):
103 class Client(object):
108 for modu
in config
.autoload
:
109 modules
[modu
] = (__import__('modules.'+str(modu
), globals(), locals(), ['Pseudo'], 0)).Pseudo(uplink
)