diff pyikriam/createAccount.py @ 225:f3502833be7c

add a gmail to get confirme url address.
author kevin@tombear.tombears.com
date Tue, 04 Nov 2008 23:32:06 +0800
parents 5fa938cbe058
children d54e2041e4aa
line wrap: on
line diff
--- a/pyikriam/createAccount.py	Tue Nov 04 18:34:06 2008 +0800
+++ b/pyikriam/createAccount.py	Tue Nov 04 23:32:06 2008 +0800
@@ -1,5 +1,5 @@
 import urllib2,urllib
-
+import libgmail,email,string,time
 from ikariam import fake_moz
 from lazy.www import c
 
@@ -7,11 +7,10 @@
     """
     For create sheep to cheat. take care of the ip address & email check by yourself.
     """
-    def __init__(self,account,email,password,server):
+    def __init__(self,account,password,server):
         self.account=account
         self.password=password
         self.server=server
-        self.email=email
         headers=[('Referer','http://'+self.server[self.server.find('.')+1:]+'/register.php')]
         self.browser = fake_moz(headers)
         urllib2.install_opener(self.browser)
@@ -22,26 +21,53 @@
         params = {
         "function":"createAvatar",\
         "name":self.account,\
-        "email":self.email,\
+        "email":self.account+"@ossug.org",\
         "password":self.password,\
         "agb":"on"}
+        print 'debug 10'
         self.ret=c(self.baseurl+'/index.php?action=newPlayer').get(params).get_content()
+        print "Waiting for 30 seconds to get confirme..."
+        time.sleep(30)
+        confirme(self.account).run()
         pass
 
 class confirme:
-    def __init__(self,confirmeurl):
-        self.confirmeurl=confirmeurl
+    def __init__(self,account):
+        self.account=account
         self.browser = fake_moz()
         urllib2.install_opener(self.browser)
         pass
 
     def run(self):
-        self.ret=c(self.confirmeurl).get().get_content()
+        print "Start get confirme url..."
+        ga = libgmail.GmailAccount("gmp3fs@gmail.com", "ossug.org")
+        ga.login()
+        folder = ga.getMessagesByFolder('inbox')
+
+        for thread in folder:
+            #thread.id, len(thread), thread.subject
+            account=string.split(thread.subject)[0]
+            print account,
+            if account==self.account:
+                print "find "+account
+                for msg in thread:
+                    mmsg=email.message_from_string(msg.source)
+                    confcontext=mmsg.get_payload(decode = True)
+                    for x in string.split(confcontext):
+                        if x[0:7]=='http://':
+                            confurl=x
+                            print "got confirme url..."
+                            break
+        self.ret=c(confurl).get().get_content()
         pass
 
-"""
-ikariamca=CreateAccount('someac','kevin@butyshop.com','contest123','s2.ikariam.tw')
+    def rename(self):
+        """
+        http://s4.ikariam.tw/index.php?view=renameCity&id=6079&position=0
+        <input class="textfield" id="newCityName" name="name" size="30" maxlength="15" type="text">
+        <input class="button" value="" type="submit">
+        """
+
+ikariamca=CreateAccount('ijdanny','taaa123','s4.ikariam.tw')
 a=ikariamca.ca()
-confirme("http://s2.ikariam.tw/index.php?action=newPlayer&function=validateEmail&hash=c239c92a94690066078ca95c993d348b&id=70997").run()
-"""