changeset 227:f41ee87f4f7a

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Tue, 04 Nov 2008 23:44:48 +0800
parents 792e6e23f2a1 (current diff) f3502833be7c (diff)
children d54e2041e4aa
files
diffstat 3 files changed, 40 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pyikriam/README	Tue Nov 04 23:44:48 2008 +0800
@@ -0,0 +1,2 @@
+apt-get install python-libgmail python-lxml
+
--- a/pyikriam/createAccount.py	Tue Nov 04 23:40:25 2008 +0800
+++ b/pyikriam/createAccount.py	Tue Nov 04 23:44:48 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()
-"""
 
--- a/pyikriam/ikariam.py	Tue Nov 04 23:40:25 2008 +0800
+++ b/pyikriam/ikariam.py	Tue Nov 04 23:44:48 2008 +0800
@@ -11,7 +11,7 @@
 class fake_moz(object):
     __metaclass__ = decorator
 
-    def __init__(self,headers=0):
+    def __init__(self,headers=None):
         fakeheaders=[('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.12pre) Gecko/20071220 BonEcho/2.0.0.12pre')]
         if headers:
             fakeheaders=fakeheaders+headers