nullclient.py
[python-purple] / nullclient.py
1 import purple
2
3 class NullClient:
4     def __init__(self):
5         self.p = purple.Purple()
6         self.account = None
7
8     def execute(self):
9         self.p.purple_init()
10
11     def set_protocol(self, protocol):
12         for i in self.p.get_protocols():
13             if i[1] == protocol:
14                 print "-- NULLCLIENT --: Choosing %s as protocol" % protocol
15                 self.protocol = i[0]
16                 print "-- NULLCLIENT --: Protocol successfully chosen: %s" % i[0]
17                 return
18
19     def new_account(self, username, protocol, password):
20         self.account = purple.Account(username, protocol)
21         self.account.set_password(password)
22         self.account.set_enabled("carman-purple-python", True)
23
24 if __name__ == '__main__':
25
26     client = NullClient()
27     client.execute()
28     client.set_protocol("XMPP")
29     client.new_account("seu_email@email.com", client.protocol,"sua_senha_aqui")
30
31     client.p.connect()
32     client.p.run_loop()