-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
40 lines (35 loc) · 1.24 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
############### Imports and globals ##############
from twisted.internet import protocol
import sys, socket
from request import Request
from cli_db import ClientDBAgent
db = ClientDBAgent('cli_db.sqlite',
['create table users (alias text, user_id int, pass text)']
)
from proto_consts import *
##################################################
class IMClient(protocol.Protocol):
def __init__(self, password, usr_id, alias):
self.password = password
self.usr_id = int(usr_id)
self.alias = alias
def connectionMade(self):
self.connected = True
def connectionLost(self,connection,reason):
self.connected = False
def parse(self,line):
vals = line.split(',')[0:4]
def lineReceived(self, line): pass
class IMClientFactory(protocol.ClientFactory):
protocol = IMClient
def clientConnectionLost(self,connector,reason):
reactor.stop()
def clientConnectionFailed(self,connector,reason):
reactor.stop()
class UserClient(object):
def __init__(self, password = '', usr_id = 0, alias = 'noone'):
self.s = None
self.password = password
self.usr_id = int(usr_id)
self.alias = alias