annotate pyikriam/createAccount.py @ 228:d54e2041e4aa

fix the problem of gmail client for unread subject rules.
author kevin@59-125-147-75.HINET-IP.hinet.net
date Wed, 05 Nov 2008 00:21:57 +0800
parents f3502833be7c
children c0b9604b0be9
rev   line source
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
1 import urllib2,urllib
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
2 import libgmail,email,string,time
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
3 from ikariam import fake_moz
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
4 from lazy.www import c
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
5
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
6 class CreateAccount:
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
7 """
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
8 For create sheep to cheat. take care of the ip address & email check by yourself.
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
9 """
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
10 def __init__(self,account,password,server):
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
11 self.account=account
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
12 self.password=password
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
13 self.server=server
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
14 headers=[('Referer','http://'+self.server[self.server.find('.')+1:]+'/register.php')]
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
15 self.browser = fake_moz(headers)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
16 urllib2.install_opener(self.browser)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
17 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
18
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
19 def ca(self):
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
20 self.baseurl='http://'+self.server
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
21 params = {
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
22 "function":"createAvatar",\
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
23 "name":self.account,\
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
24 "email":self.account+"@ossug.org",\
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
25 "password":self.password,\
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
26 "agb":"on"}
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
27 print 'debug 10'
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
28 self.ret=c(self.baseurl+'/index.php?action=newPlayer').get(params).get_content()
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
29 print "Waiting for 30 seconds to get confirme..."
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
30 time.sleep(30)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
31 confirme(self.account).run()
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
32 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
33
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
34 class confirme:
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
35 def __init__(self,account):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
36 self.account=account
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
37 self.browser = fake_moz()
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
38 urllib2.install_opener(self.browser)
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
39 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
40
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
41 def run(self):
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
42 print "Start get confirme url..."
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
43 ga = libgmail.GmailAccount("gmp3fs@gmail.com", "ossug.org")
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
44 ga.login()
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
45 folder = ga.getMessagesByFolder('inbox')
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
46
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
47 for thread in folder:
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
48 #thread.id, len(thread), thread.subject
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
49 account=string.split(thread.subject)[0]
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
50 print account,
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
51 if account==self.account:
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
52 print "find "+account
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
53 for msg in thread:
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
54 mmsg=email.message_from_string(msg.source)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
55 confcontext=mmsg.get_payload(decode = True)
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
56 for x in string.split(confcontext):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
57 if x[0:7]=='http://':
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
58 confurl=x
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
59 print "got confirme url..."
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
60 break
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
61 self.ret=c(confurl).get().get_content()
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
62 pass
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
63
225
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
64 def rename(self):
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
65 """
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
66 http://s4.ikariam.tw/index.php?view=renameCity&id=6079&position=0
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
67 <input class="textfield" id="newCityName" name="name" size="30" maxlength="15" type="text">
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
68 <input class="button" value="" type="submit">
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
69 """
f3502833be7c add a gmail to get confirme url address.
kevin@tombear.tombears.com
parents: 220
diff changeset
70
228
d54e2041e4aa fix the problem of gmail client for unread subject rules.
kevin@59-125-147-75.HINET-IP.hinet.net
parents: 225
diff changeset
71 ikariamca=CreateAccount('laswnny','wtaaa123','s4.ikariam.tw')
220
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
72 a=ikariamca.ca()
5fa938cbe058 Class of account creater
kevin@tombear.tombears.com
parents:
diff changeset
73