pykol-users Mailing List for pykol
Brought to you by:
scelis
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(9) |
Apr
(6) |
May
(6) |
Jun
(3) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <mi...@us...> - 2008-09-30 19:16:15
|
Revision: 31 http://pykol.svn.sourceforge.net/pykol/?rev=31&view=rev Author: misza13 Date: 2008-09-30 19:15:52 +0000 (Tue, 30 Sep 2008) Log Message: ----------- Tagging old code before new stuff checks in. Added Paths: ----------- tags/old/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 12:25:24
|
Revision: 30 http://pykol.svn.sourceforge.net/pykol/?rev=30&view=rev Author: misza13 Date: 2007-08-17 05:25:27 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added svn:keywords property on all .py files (value = 'Id') Modified Paths: -------------- trunk/icypeak.py trunk/kol/__init__.py trunk/kol/adventure.py trunk/kol/campground.py trunk/kol/kolsite.py trunk/kol/mall.py trunk/test.py Property Changed: ---------------- trunk/icypeak.py trunk/kol/__init__.py trunk/kol/adventure.py trunk/kol/campground.py trunk/kol/kolsite.py trunk/kol/mall.py trunk/test.py Modified: trunk/icypeak.py =================================================================== --- trunk/icypeak.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/icypeak.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import sys sys.path.append('.') Property changes on: trunk/icypeak.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/kol/__init__.py =================================================================== --- trunk/kol/__init__.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/kol/__init__.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,5 +4,5 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # Property changes on: trunk/kol/__init__.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/kol/adventure.py =================================================================== --- trunk/kol/adventure.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/kol/adventure.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import re Property changes on: trunk/kol/adventure.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/kol/campground.py =================================================================== --- trunk/kol/campground.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/kol/campground.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import re Property changes on: trunk/kol/campground.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/kol/kolsite.py =================================================================== --- trunk/kol/kolsite.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/kol/kolsite.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import re, urllib, httplib Property changes on: trunk/kol/kolsite.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/kol/mall.py =================================================================== --- trunk/kol/mall.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/kol/mall.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import re Property changes on: trunk/kol/mall.py ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/test.py =================================================================== --- trunk/test.py 2007-08-17 12:12:37 UTC (rev 29) +++ trunk/test.py 2007-08-17 12:25:27 UTC (rev 30) @@ -4,7 +4,7 @@ # # Distributed under the terms of the MIT license. # -__version__ = '$Id: $' +__version__ = '$Id$' # import sys, random from kol.kolsite import KoLSite Property changes on: trunk/test.py ___________________________________________________________________ Name: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 12:12:38
|
Revision: 29 http://pykol.svn.sourceforge.net/pykol/?rev=29&view=rev Author: misza13 Date: 2007-08-17 05:12:37 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added __version__ tags on all files. Modified Paths: -------------- trunk/icypeak.py trunk/kol/__init__.py trunk/kol/adventure.py trunk/kol/campground.py trunk/kol/kolsite.py trunk/kol/mall.py trunk/test.py Modified: trunk/icypeak.py =================================================================== --- trunk/icypeak.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/icypeak.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,7 +4,8 @@ # # Distributed under the terms of the MIT license. # - +__version__ = '$Id: $' +# import sys sys.path.append('.') Modified: trunk/kol/__init__.py =================================================================== --- trunk/kol/__init__.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/kol/__init__.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,3 +4,5 @@ # # Distributed under the terms of the MIT license. # +__version__ = '$Id: $' +# Modified: trunk/kol/adventure.py =================================================================== --- trunk/kol/adventure.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/kol/adventure.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,9 +4,11 @@ # # Distributed under the terms of the MIT license. # - +__version__ = '$Id: $' +# import re + class AutoAdventurer: def __init__(self, site): self.site = site Modified: trunk/kol/campground.py =================================================================== --- trunk/kol/campground.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/kol/campground.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,9 +4,11 @@ # # Distributed under the terms of the MIT license. # - +__version__ = '$Id: $' +# import re + class Campground: def __init__(self, site): self.site = site Modified: trunk/kol/kolsite.py =================================================================== --- trunk/kol/kolsite.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/kol/kolsite.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +__version__ = '$Id: $' +# import re, urllib, httplib try: Modified: trunk/kol/mall.py =================================================================== --- trunk/kol/mall.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/kol/mall.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,10 +4,13 @@ # # Distributed under the terms of the MIT license. # +__version__ = '$Id: $' +# import re import kolsite + class Mall: def __init__(self, Site): self.Site = Site Modified: trunk/test.py =================================================================== --- trunk/test.py 2007-08-17 12:09:42 UTC (rev 28) +++ trunk/test.py 2007-08-17 12:12:37 UTC (rev 29) @@ -4,6 +4,8 @@ # # Distributed under the terms of the MIT license. # +__version__ = '$Id: $' +# import sys, random from kol.kolsite import KoLSite from kol.mall import Mall @@ -30,5 +32,6 @@ for s in M.searchItem('tiny plastic sword'): print s + if __name__ == '__main__': main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 12:09:53
|
Revision: 28 http://pykol.svn.sourceforge.net/pykol/?rev=28&view=rev Author: misza13 Date: 2007-08-17 05:09:42 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Reorganizing. Core classes moved to kol/ subdirectory. Bots moved to main. Modified Paths: -------------- trunk/test.py Added Paths: ----------- trunk/icypeak.py trunk/kol/ trunk/kol/__init__.py trunk/kol/adventure.py trunk/kol/campground.py trunk/kol/kolsite.py trunk/kol/mall.py Removed Paths: ------------- trunk/.svnignore trunk/adventure.py trunk/bots/ trunk/campground.py trunk/kolsite.py trunk/mall.py Deleted: trunk/.svnignore =================================================================== --- trunk/.svnignore 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/.svnignore 2007-08-17 12:09:42 UTC (rev 28) @@ -1,2 +0,0 @@ -*.pyc -*.conf Deleted: trunk/adventure.py =================================================================== --- trunk/adventure.py 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/adventure.py 2007-08-17 12:09:42 UTC (rev 28) @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# - -import re - -class AutoAdventurer: - def __init__(self, site): - self.site = site - - def adventure(self, snarfblat): - print 'Starting adventure...' - response, data = self.site.getPage('adventure.php?snarfblat='+snarfblat) - - if response.getheader('location')=='fight.php': - self.fighting = True - while self.fighting: - self.fight() - - def fight(self): - response, data = self.site.getPage('fight.php') - - monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) - print "You're fighting %s" % monRX.group('monname') - - tackRX = re.search(r"<input id='tack' class=button type=submit value=\"Attack with your (?P<tackitem>.*?)\">",data) - - formdata = { - 'action' : 'attack', - 'tack' : 'Attack with your ' + tackRX.group('tackitem'), - } - response, data = self.site.postForm('fight.php',formdata) - - if "You win the fight!" in data: - print "You win the fight!" - self.fighting = False - else: - self.fighting = True Deleted: trunk/campground.py =================================================================== --- trunk/campground.py 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/campground.py 2007-08-17 12:09:42 UTC (rev 28) @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# - -import re - -class Campground: - def __init__(self, site): - self.site = site - - - def rest(self, count=1): - #Function will return cumulative gains: - cHPgain = 0 - cMPgain = 0 - for i in range(count): - print 'Now resting...' - response, data = self.site.getPage('campground.php?action=rest') - - if "You don't need to rest." in data: - print "You don't need to rest." - break - else: - rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)',data) - if rx: - HPgain = int(rx.group('hp')) - MPgain = int(rx.group('mp')) - print 'You gained %d HP, %d MP' % (HPgain,MPgain) - return (cHPgain,cMPgain) Copied: trunk/icypeak.py (from rev 26, trunk/bots/icypeak.py) =================================================================== --- trunk/icypeak.py (rev 0) +++ trunk/icypeak.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import sys +sys.path.append('.') + +from optparse import OptionParser + +from kol.kolsite import KoLSite +from kol.campground import Campground +from kol.adventure import AutoAdventurer + + +def main(options,args): + config = {} + execfile(options.conf) + if not config.has_key('nick') or not config.has_key('password'): + print 'Nick or password not specified in config!' + return + + Site = KoLSite() + Site.doLogin(config['nick'],config['password']) + + AutoAdv = AutoAdventurer(Site) + + for i in range(options.num): + print 'Adventure %d of %d...' % (i+1,options.num) + AutoAdv.adventure('110') + + +if __name__ == '__main__': + parser = OptionParser() + parser.add_option('-c', '--conf', dest='conf', + help='use FILE as configuration', metavar='FILE') + parser.add_option('-n', '--num', dest='num', type='int', default=1, + help='adventure NUM times', metavar='NUM') + options, args = parser.parse_args() + + if options.conf: + main(options,args) + else: + parser.print_help() Property changes on: trunk/kol ___________________________________________________________________ Name: svn:ignore + *.pyc Added: trunk/kol/__init__.py =================================================================== --- trunk/kol/__init__.py (rev 0) +++ trunk/kol/__init__.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# Copied: trunk/kol/adventure.py (from rev 26, trunk/adventure.py) =================================================================== --- trunk/kol/adventure.py (rev 0) +++ trunk/kol/adventure.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import re + +class AutoAdventurer: + def __init__(self, site): + self.site = site + + def adventure(self, snarfblat): + print 'Starting adventure...' + response, data = self.site.getPage('adventure.php?snarfblat='+snarfblat) + + if response.getheader('location')=='fight.php': + self.fighting = True + while self.fighting: + self.fight() + + def fight(self): + response, data = self.site.getPage('fight.php') + + monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) + print "You're fighting %s" % monRX.group('monname') + + tackRX = re.search(r"<input id='tack' class=button type=submit value=\"Attack with your (?P<tackitem>.*?)\">",data) + + formdata = { + 'action' : 'attack', + 'tack' : 'Attack with your ' + tackRX.group('tackitem'), + } + response, data = self.site.postForm('fight.php',formdata) + + if "You win the fight!" in data: + print "You win the fight!" + self.fighting = False + else: + self.fighting = True Copied: trunk/kol/campground.py (from rev 26, trunk/campground.py) =================================================================== --- trunk/kol/campground.py (rev 0) +++ trunk/kol/campground.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import re + +class Campground: + def __init__(self, site): + self.site = site + + + def rest(self, count=1): + #Function will return cumulative gains: + cHPgain = 0 + cMPgain = 0 + for i in range(count): + print 'Now resting...' + response, data = self.site.getPage('campground.php?action=rest') + + if "You don't need to rest." in data: + print "You don't need to rest." + break + else: + rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)',data) + if rx: + HPgain = int(rx.group('hp')) + MPgain = int(rx.group('mp')) + print 'You gained %d HP, %d MP' % (HPgain,MPgain) + return (cHPgain,cMPgain) Copied: trunk/kol/kolsite.py (from rev 26, trunk/kolsite.py) =================================================================== --- trunk/kol/kolsite.py (rev 0) +++ trunk/kol/kolsite.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# +import re, urllib, httplib + +try: + import hashlib + new_md5 = hashlib.md5 +except ImportError: #Old python? + import md5 + new_md5 = md5.md5 + + +def urlEncode(query): + """This can encode a query so that it can be sent as a query using + a http POST request""" + if not query: + return None + l = [] + for key, value in query.iteritems(): + key = urllib.quote(key) + value = urllib.quote(value) + l.append(key + '=' + value) + return '&'.join(l) + + +def challengePassword(challenge,password): + m = new_md5() + m.update(password) + hashedpw = m.hexdigest() + m = new_md5() + m.update(hashedpw+':'+challenge) + return m.hexdigest() + + +class LoginError: + def __init__(self,reason='None'): + self.reason = reason + + def __repr__(self): + return 'LoginError{%s}' % self.reason + + +class KoLSite: + def __init__(self): + self.hostname = 'www.kingdomofloathing.com' + self.cookie = None + + + def getPage(self, address, data=''): + #print 'GET http://' + self.hostname + '/' + address + conn = httplib.HTTPConnection(self.hostname) + + conn.putrequest('GET', '/' + address) + if self.cookie: + conn.putheader('Cookie', self.cookie) + conn.endheaders() + conn.send('') + + response = conn.getresponse() + data = response.read().decode('utf-8') + conn.close() + return response, data + + + def postForm(self, address, formdata): + data = urlEncode(formdata) + return self.postData(address, data) + + + def postData(self, address, data=''): + #print 'POST http://' + self.hostname + '/' + address + conn = httplib.HTTPConnection(self.hostname) + + conn.putrequest('POST', '/' + address) + if self.cookie: + conn.putheader('Cookie', self.cookie) + conn.putheader('Content-Length', str(len(data))) + conn.putheader('Content-Type', 'application/x-www-form-urlencoded') + conn.endheaders() + conn.send(data) + + response = conn.getresponse() + data = response.read().decode('utf-8') + conn.close() + return response, data + + + def doLogin(self, nick, password): + try: + cookie = file('cookie','r').readlines() + self.cookie = cookie[1][:-1] + self.hostname = cookie[0][:-1] + except: + self.cookie = None + + if self.cookie: + print 'Trying a recovered cookie...' + response, data = self.getPage('main.php') + if data or response.getheader('location')=='fight.php': + print "Successfully recovered cookie file." + return + + challenge = self.getChallenge() + + formFields = {} + formFields['loggingin'] = 'Yup.' + formFields['loginname'] = nick + if challenge: + print 'Logging in using challenge...' + formFields['challenge'] = challenge + formFields['response'] = challengePassword(challenge,password) + else: + print 'Logging in without challenge...' + formFields['password'] = password + formFields['secure'] = '1' + + response, data = self.postForm('login.php',formFields) + + if response.status == 302: + self.cookie = response.getheader('set-cookie') + file('cookie','w+').write('%s\n%s\n' % (self.hostname,self.cookie)) + print 'Saved cookie file.' + return + + if re.search('Bad password.',data): + raise LoginError, 'Bad password.' + elif re.search('Too many login failures from this IP.',data): + raise LoginError, 'Too many login failures from this IP.' + elif re.search('Too many login attempts',data): + raise LoginError, 'Too many login attempts.' + else: + raise LoginError, data + + + def getChallenge(self): + print 'Getting login challenge...' + response, data = self.getPage('') + while response.status == 302: + #We got redirected + locRE = re.search('http://(www\d?.kingdomofloathing.com)/(.*)',response.getheader('location')) + if locRE: #Bounced off to a different server? + self.hostname = locRE.group(1) + response, data = self.getPage(locRE.group(2)) + else: #Same server, getting loginid= + response, data = self.getPage(response.getheader('location')) + + #We're there. Looking for challenge... + challenge = re.search('<input type=hidden name=challenge value="([0-9a-f]+)">',data) + if challenge: + return challenge.group(1) + else: + return '' Copied: trunk/kol/mall.py (from rev 26, trunk/mall.py) =================================================================== --- trunk/kol/mall.py (rev 0) +++ trunk/kol/mall.py 2007-08-17 12:09:42 UTC (rev 28) @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# +import re + +import kolsite + +class Mall: + def __init__(self, Site): + self.Site = Site + + def searchItem(self, what, limit=None): + formdata = {'whichitem' : what} + if limit: + formdata['cheaponly'] = '1' + formdata['shownum'] = str(limit) + response, data = self.Site.postForm('searchmall.php',formdata) + + offset = re.search('Price:',data).start() + itemRX = re.compile(r'<b>(?P<itemname>.+?)</b> \((?P<itemcount>\d+)\)(?: \((?P<limit>\d+) / day\))?.*?mallstore.php\?whichstore=(?P<whichstore>\d+).*?>(?P<shopname>.+)</a>.*?>(?P<price>[0-9,]+) ') + for itemM in itemRX.finditer(data,offset): + result = {} + for v in ['itemname','itemcount','limit','whichstore','shopname','price']: + if v == 'itemcount': + result[v] = int(itemM.group('itemcount').replace(',','')) + elif v == 'limit' and itemM.group('limit'): + result[v] = int(itemM.group('limit').replace(',','')) + elif v == 'price': + result[v] = int(itemM.group('price').replace(',','')) + elif v == 'whichstore': + result[v] = int(itemM.group('whichstore').replace(',','')) + else: + result[v] = itemM.group(v) + yield result + Deleted: trunk/kolsite.py =================================================================== --- trunk/kolsite.py 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/kolsite.py 2007-08-17 12:09:42 UTC (rev 28) @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# -import re, urllib, httplib - -try: - import hashlib - new_md5 = hashlib.md5 -except ImportError: #Old python? - import md5 - new_md5 = md5.md5 - - -def urlEncode(query): - """This can encode a query so that it can be sent as a query using - a http POST request""" - if not query: - return None - l = [] - for key, value in query.iteritems(): - key = urllib.quote(key) - value = urllib.quote(value) - l.append(key + '=' + value) - return '&'.join(l) - - -def challengePassword(challenge,password): - m = new_md5() - m.update(password) - hashedpw = m.hexdigest() - m = new_md5() - m.update(hashedpw+':'+challenge) - return m.hexdigest() - - -class LoginError: - def __init__(self,reason='None'): - self.reason = reason - - def __repr__(self): - return 'LoginError{%s}' % self.reason - - -class KoLSite: - def __init__(self): - self.hostname = 'www.kingdomofloathing.com' - self.cookie = None - - - def getPage(self, address, data=''): - #print 'GET http://' + self.hostname + '/' + address - conn = httplib.HTTPConnection(self.hostname) - - conn.putrequest('GET', '/' + address) - if self.cookie: - conn.putheader('Cookie', self.cookie) - conn.endheaders() - conn.send('') - - response = conn.getresponse() - data = response.read().decode('utf-8') - conn.close() - return response, data - - - def postForm(self, address, formdata): - data = urlEncode(formdata) - return self.postData(address, data) - - - def postData(self, address, data=''): - #print 'POST http://' + self.hostname + '/' + address - conn = httplib.HTTPConnection(self.hostname) - - conn.putrequest('POST', '/' + address) - if self.cookie: - conn.putheader('Cookie', self.cookie) - conn.putheader('Content-Length', str(len(data))) - conn.putheader('Content-Type', 'application/x-www-form-urlencoded') - conn.endheaders() - conn.send(data) - - response = conn.getresponse() - data = response.read().decode('utf-8') - conn.close() - return response, data - - - def doLogin(self, nick, password): - try: - cookie = file('cookie','r').readlines() - self.cookie = cookie[1][:-1] - self.hostname = cookie[0][:-1] - except: - self.cookie = None - - if self.cookie: - print 'Trying a recovered cookie...' - response, data = self.getPage('main.php') - if data or response.getheader('location')=='fight.php': - print "Successfully recovered cookie file." - return - - challenge = self.getChallenge() - - formFields = {} - formFields['loggingin'] = 'Yup.' - formFields['loginname'] = nick - if challenge: - print 'Logging in using challenge...' - formFields['challenge'] = challenge - formFields['response'] = challengePassword(challenge,password) - else: - print 'Logging in without challenge...' - formFields['password'] = password - formFields['secure'] = '1' - - response, data = self.postForm('login.php',formFields) - - if response.status == 302: - self.cookie = response.getheader('set-cookie') - file('cookie','w+').write('%s\n%s\n' % (self.hostname,self.cookie)) - print 'Saved cookie file.' - return - - if re.search('Bad password.',data): - raise LoginError, 'Bad password.' - elif re.search('Too many login failures from this IP.',data): - raise LoginError, 'Too many login failures from this IP.' - elif re.search('Too many login attempts',data): - raise LoginError, 'Too many login attempts.' - else: - raise LoginError, data - - - def getChallenge(self): - print 'Getting login challenge...' - response, data = self.getPage('') - while response.status == 302: - #We got redirected - locRE = re.search('http://(www\d?.kingdomofloathing.com)/(.*)',response.getheader('location')) - if locRE: #Bounced off to a different server? - self.hostname = locRE.group(1) - response, data = self.getPage(locRE.group(2)) - else: #Same server, getting loginid= - response, data = self.getPage(response.getheader('location')) - - #We're there. Looking for challenge... - challenge = re.search('<input type=hidden name=challenge value="([0-9a-f]+)">',data) - if challenge: - return challenge.group(1) - else: - return '' Deleted: trunk/mall.py =================================================================== --- trunk/mall.py 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/mall.py 2007-08-17 12:09:42 UTC (rev 28) @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# -import re - -import kolsite - -class Mall: - def __init__(self, Site): - self.Site = Site - - def searchItem(self, what, limit=None): - formdata = {'whichitem' : what} - if limit: - formdata['cheaponly'] = '1' - formdata['shownum'] = str(limit) - response, data = self.Site.postForm('searchmall.php',formdata) - - offset = re.search('Price:',data).start() - itemRX = re.compile(r'<b>(?P<itemname>.+?)</b> \((?P<itemcount>\d+)\)(?: \((?P<limit>\d+) / day\))?.*?mallstore.php\?whichstore=(?P<whichstore>\d+).*?>(?P<shopname>.+)</a>.*?>(?P<price>[0-9,]+) ') - for itemM in itemRX.finditer(data,offset): - result = {} - for v in ['itemname','itemcount','limit','whichstore','shopname','price']: - if v == 'itemcount': - result[v] = int(itemM.group('itemcount').replace(',','')) - elif v == 'limit' and itemM.group('limit'): - result[v] = int(itemM.group('limit').replace(',','')) - elif v == 'price': - result[v] = int(itemM.group('price').replace(',','')) - elif v == 'whichstore': - result[v] = int(itemM.group('whichstore').replace(',','')) - else: - result[v] = itemM.group(v) - yield result - Modified: trunk/test.py =================================================================== --- trunk/test.py 2007-08-17 11:58:46 UTC (rev 27) +++ trunk/test.py 2007-08-17 12:09:42 UTC (rev 28) @@ -5,8 +5,8 @@ # Distributed under the terms of the MIT license. # import sys, random -from kolsite import KoLSite -from mall import Mall +from kol.kolsite import KoLSite +from kol.mall import Mall def main(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 11:58:49
|
Revision: 27 http://pykol.svn.sourceforge.net/pykol/?rev=27&view=rev Author: misza13 Date: 2007-08-17 04:58:46 -0700 (Fri, 17 Aug 2007) Log Message: ----------- moved svn:ignore to trunk and subdirectories Property Changed: ---------------- / trunk/ trunk/bots/ Property changes on: ___________________________________________________________________ Name: svn:ignore - *.pyc *.conf cookie Property changes on: trunk ___________________________________________________________________ Name: svn:ignore + *.pyc *.conf cookie Property changes on: trunk/bots ___________________________________________________________________ Name: svn:ignore + *.pyc *.conf cookie This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 11:55:42
|
Revision: 26 http://pykol.svn.sourceforge.net/pykol/?rev=26&view=rev Author: misza13 Date: 2007-08-17 04:55:39 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Added .pyc, .conf and cookie to svn:ignore. Property Changed: ---------------- / Property changes on: ___________________________________________________________________ Name: svn:ignore + *.pyc *.conf cookie This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-08-17 10:59:41
|
Revision: 25 http://pykol.svn.sourceforge.net/pykol/?rev=25&view=rev Author: misza13 Date: 2007-08-17 03:59:35 -0700 (Fri, 17 Aug 2007) Log Message: ----------- Standarising repository layout. Created /trunk, /branches and /tags. Moved all files under /trunk. Added Paths: ----------- branches/ tags/ trunk/ trunk/.svnignore trunk/LICENSE trunk/adventure.py trunk/bots/ trunk/campground.py trunk/kolsite.py trunk/mall.py trunk/test.py Removed Paths: ------------- .svnignore LICENSE adventure.py bots/ campground.py kolsite.py mall.py test.py Deleted: .svnignore =================================================================== --- .svnignore 2007-06-03 22:25:53 UTC (rev 24) +++ .svnignore 2007-08-17 10:59:35 UTC (rev 25) @@ -1,2 +0,0 @@ -*.pyc -*.conf Deleted: LICENSE =================================================================== --- LICENSE 2007-06-03 22:25:53 UTC (rev 24) +++ LICENSE 2007-08-17 10:59:35 UTC (rev 25) @@ -1,19 +0,0 @@ -Copyright (C) Misza <mi...@mi...>, 2007 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. Deleted: adventure.py =================================================================== --- adventure.py 2007-06-03 22:25:53 UTC (rev 24) +++ adventure.py 2007-08-17 10:59:35 UTC (rev 25) @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# - -import re - -class AutoAdventurer: - def __init__(self, site): - self.site = site - - def adventure(self, snarfblat): - print 'Starting adventure...' - response, data = self.site.getPage('adventure.php?snarfblat='+snarfblat) - - if response.getheader('location')=='fight.php': - self.fighting = True - while self.fighting: - self.fight() - - def fight(self): - response, data = self.site.getPage('fight.php') - - monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) - print "You're fighting %s" % monRX.group('monname') - - tackRX = re.search(r"<input id='tack' class=button type=submit value=\"Attack with your (?P<tackitem>.*?)\">",data) - - formdata = { - 'action' : 'attack', - 'tack' : 'Attack with your ' + tackRX.group('tackitem'), - } - response, data = self.site.postForm('fight.php',formdata) - - if "You win the fight!" in data: - print "You win the fight!" - self.fighting = False - else: - self.fighting = True Deleted: campground.py =================================================================== --- campground.py 2007-06-03 22:25:53 UTC (rev 24) +++ campground.py 2007-08-17 10:59:35 UTC (rev 25) @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# - -import re - -class Campground: - def __init__(self, site): - self.site = site - - - def rest(self, count=1): - #Function will return cumulative gains: - cHPgain = 0 - cMPgain = 0 - for i in range(count): - print 'Now resting...' - response, data = self.site.getPage('campground.php?action=rest') - - if "You don't need to rest." in data: - print "You don't need to rest." - break - else: - rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)',data) - if rx: - HPgain = int(rx.group('hp')) - MPgain = int(rx.group('mp')) - print 'You gained %d HP, %d MP' % (HPgain,MPgain) - return (cHPgain,cMPgain) Deleted: kolsite.py =================================================================== --- kolsite.py 2007-06-03 22:25:53 UTC (rev 24) +++ kolsite.py 2007-08-17 10:59:35 UTC (rev 25) @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# -import re, urllib, httplib - -try: - import hashlib - new_md5 = hashlib.md5 -except ImportError: #Old python? - import md5 - new_md5 = md5.md5 - - -def urlEncode(query): - """This can encode a query so that it can be sent as a query using - a http POST request""" - if not query: - return None - l = [] - for key, value in query.iteritems(): - key = urllib.quote(key) - value = urllib.quote(value) - l.append(key + '=' + value) - return '&'.join(l) - - -def challengePassword(challenge,password): - m = new_md5() - m.update(password) - hashedpw = m.hexdigest() - m = new_md5() - m.update(hashedpw+':'+challenge) - return m.hexdigest() - - -class LoginError: - def __init__(self,reason='None'): - self.reason = reason - - def __repr__(self): - return 'LoginError{%s}' % self.reason - - -class KoLSite: - def __init__(self): - self.hostname = 'www.kingdomofloathing.com' - self.cookie = None - - - def getPage(self, address, data=''): - #print 'GET http://' + self.hostname + '/' + address - conn = httplib.HTTPConnection(self.hostname) - - conn.putrequest('GET', '/' + address) - if self.cookie: - conn.putheader('Cookie', self.cookie) - conn.endheaders() - conn.send('') - - response = conn.getresponse() - data = response.read().decode('utf-8') - conn.close() - return response, data - - - def postForm(self, address, formdata): - data = urlEncode(formdata) - return self.postData(address, data) - - - def postData(self, address, data=''): - #print 'POST http://' + self.hostname + '/' + address - conn = httplib.HTTPConnection(self.hostname) - - conn.putrequest('POST', '/' + address) - if self.cookie: - conn.putheader('Cookie', self.cookie) - conn.putheader('Content-Length', str(len(data))) - conn.putheader('Content-Type', 'application/x-www-form-urlencoded') - conn.endheaders() - conn.send(data) - - response = conn.getresponse() - data = response.read().decode('utf-8') - conn.close() - return response, data - - - def doLogin(self, nick, password): - try: - cookie = file('cookie','r').readlines() - self.cookie = cookie[1][:-1] - self.hostname = cookie[0][:-1] - except: - self.cookie = None - - if self.cookie: - print 'Trying a recovered cookie...' - response, data = self.getPage('main.php') - if data or response.getheader('location')=='fight.php': - print "Successfully recovered cookie file." - return - - challenge = self.getChallenge() - - formFields = {} - formFields['loggingin'] = 'Yup.' - formFields['loginname'] = nick - if challenge: - print 'Logging in using challenge...' - formFields['challenge'] = challenge - formFields['response'] = challengePassword(challenge,password) - else: - print 'Logging in without challenge...' - formFields['password'] = password - formFields['secure'] = '1' - - response, data = self.postForm('login.php',formFields) - - if response.status == 302: - self.cookie = response.getheader('set-cookie') - file('cookie','w+').write('%s\n%s\n' % (self.hostname,self.cookie)) - print 'Saved cookie file.' - return - - if re.search('Bad password.',data): - raise LoginError, 'Bad password.' - elif re.search('Too many login failures from this IP.',data): - raise LoginError, 'Too many login failures from this IP.' - elif re.search('Too many login attempts',data): - raise LoginError, 'Too many login attempts.' - else: - raise LoginError, data - - - def getChallenge(self): - print 'Getting login challenge...' - response, data = self.getPage('') - while response.status == 302: - #We got redirected - locRE = re.search('http://(www\d?.kingdomofloathing.com)/(.*)',response.getheader('location')) - if locRE: #Bounced off to a different server? - self.hostname = locRE.group(1) - response, data = self.getPage(locRE.group(2)) - else: #Same server, getting loginid= - response, data = self.getPage(response.getheader('location')) - - #We're there. Looking for challenge... - challenge = re.search('<input type=hidden name=challenge value="([0-9a-f]+)">',data) - if challenge: - return challenge.group(1) - else: - return '' Deleted: mall.py =================================================================== --- mall.py 2007-06-03 22:25:53 UTC (rev 24) +++ mall.py 2007-08-17 10:59:35 UTC (rev 25) @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# -import re - -import kolsite - -class Mall: - def __init__(self, Site): - self.Site = Site - - def searchItem(self, what, limit=None): - formdata = {'whichitem' : what} - if limit: - formdata['cheaponly'] = '1' - formdata['shownum'] = str(limit) - response, data = self.Site.postForm('searchmall.php',formdata) - - offset = re.search('Price:',data).start() - itemRX = re.compile(r'<b>(?P<itemname>.+?)</b> \((?P<itemcount>\d+)\)(?: \((?P<limit>\d+) / day\))?.*?mallstore.php\?whichstore=(?P<whichstore>\d+).*?>(?P<shopname>.+)</a>.*?>(?P<price>[0-9,]+) ') - for itemM in itemRX.finditer(data,offset): - result = {} - for v in ['itemname','itemcount','limit','whichstore','shopname','price']: - if v == 'itemcount': - result[v] = int(itemM.group('itemcount').replace(',','')) - elif v == 'limit' and itemM.group('limit'): - result[v] = int(itemM.group('limit').replace(',','')) - elif v == 'price': - result[v] = int(itemM.group('price').replace(',','')) - elif v == 'whichstore': - result[v] = int(itemM.group('whichstore').replace(',','')) - else: - result[v] = itemM.group(v) - yield result - Deleted: test.py =================================================================== --- test.py 2007-06-03 22:25:53 UTC (rev 24) +++ test.py 2007-08-17 10:59:35 UTC (rev 25) @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# -# (C) Misza <mi...@mi...>, 2007 -# -# Distributed under the terms of the MIT license. -# -import sys, random -from kolsite import KoLSite -from mall import Mall - - -def main(): - if len(sys.argv) < 2: - print 'Please specify a config file!' - return - config = {} - execfile(sys.argv[1]) - if not config.has_key('nick') or not config.has_key('password'): - print 'Nick or password not specified in config!' - return - - Site = KoLSite() - Site.doLogin(config['nick'],config['password']) - - #response, data = Site.getPage('main.html') - #print response.status - #print data - - M = Mall(Site) - for s in M.searchItem('tiny plastic sword'): - print s - -if __name__ == '__main__': - main() Copied: trunk/.svnignore (from rev 24, .svnignore) =================================================================== --- trunk/.svnignore (rev 0) +++ trunk/.svnignore 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,2 @@ +*.pyc +*.conf Copied: trunk/LICENSE (from rev 24, LICENSE) =================================================================== --- trunk/LICENSE (rev 0) +++ trunk/LICENSE 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,19 @@ +Copyright (C) Misza <mi...@mi...>, 2007 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. Copied: trunk/adventure.py (from rev 24, adventure.py) =================================================================== --- trunk/adventure.py (rev 0) +++ trunk/adventure.py 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import re + +class AutoAdventurer: + def __init__(self, site): + self.site = site + + def adventure(self, snarfblat): + print 'Starting adventure...' + response, data = self.site.getPage('adventure.php?snarfblat='+snarfblat) + + if response.getheader('location')=='fight.php': + self.fighting = True + while self.fighting: + self.fight() + + def fight(self): + response, data = self.site.getPage('fight.php') + + monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) + print "You're fighting %s" % monRX.group('monname') + + tackRX = re.search(r"<input id='tack' class=button type=submit value=\"Attack with your (?P<tackitem>.*?)\">",data) + + formdata = { + 'action' : 'attack', + 'tack' : 'Attack with your ' + tackRX.group('tackitem'), + } + response, data = self.site.postForm('fight.php',formdata) + + if "You win the fight!" in data: + print "You win the fight!" + self.fighting = False + else: + self.fighting = True Copied: trunk/bots (from rev 24, bots) Copied: trunk/campground.py (from rev 24, campground.py) =================================================================== --- trunk/campground.py (rev 0) +++ trunk/campground.py 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import re + +class Campground: + def __init__(self, site): + self.site = site + + + def rest(self, count=1): + #Function will return cumulative gains: + cHPgain = 0 + cMPgain = 0 + for i in range(count): + print 'Now resting...' + response, data = self.site.getPage('campground.php?action=rest') + + if "You don't need to rest." in data: + print "You don't need to rest." + break + else: + rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)',data) + if rx: + HPgain = int(rx.group('hp')) + MPgain = int(rx.group('mp')) + print 'You gained %d HP, %d MP' % (HPgain,MPgain) + return (cHPgain,cMPgain) Copied: trunk/kolsite.py (from rev 24, kolsite.py) =================================================================== --- trunk/kolsite.py (rev 0) +++ trunk/kolsite.py 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,156 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# +import re, urllib, httplib + +try: + import hashlib + new_md5 = hashlib.md5 +except ImportError: #Old python? + import md5 + new_md5 = md5.md5 + + +def urlEncode(query): + """This can encode a query so that it can be sent as a query using + a http POST request""" + if not query: + return None + l = [] + for key, value in query.iteritems(): + key = urllib.quote(key) + value = urllib.quote(value) + l.append(key + '=' + value) + return '&'.join(l) + + +def challengePassword(challenge,password): + m = new_md5() + m.update(password) + hashedpw = m.hexdigest() + m = new_md5() + m.update(hashedpw+':'+challenge) + return m.hexdigest() + + +class LoginError: + def __init__(self,reason='None'): + self.reason = reason + + def __repr__(self): + return 'LoginError{%s}' % self.reason + + +class KoLSite: + def __init__(self): + self.hostname = 'www.kingdomofloathing.com' + self.cookie = None + + + def getPage(self, address, data=''): + #print 'GET http://' + self.hostname + '/' + address + conn = httplib.HTTPConnection(self.hostname) + + conn.putrequest('GET', '/' + address) + if self.cookie: + conn.putheader('Cookie', self.cookie) + conn.endheaders() + conn.send('') + + response = conn.getresponse() + data = response.read().decode('utf-8') + conn.close() + return response, data + + + def postForm(self, address, formdata): + data = urlEncode(formdata) + return self.postData(address, data) + + + def postData(self, address, data=''): + #print 'POST http://' + self.hostname + '/' + address + conn = httplib.HTTPConnection(self.hostname) + + conn.putrequest('POST', '/' + address) + if self.cookie: + conn.putheader('Cookie', self.cookie) + conn.putheader('Content-Length', str(len(data))) + conn.putheader('Content-Type', 'application/x-www-form-urlencoded') + conn.endheaders() + conn.send(data) + + response = conn.getresponse() + data = response.read().decode('utf-8') + conn.close() + return response, data + + + def doLogin(self, nick, password): + try: + cookie = file('cookie','r').readlines() + self.cookie = cookie[1][:-1] + self.hostname = cookie[0][:-1] + except: + self.cookie = None + + if self.cookie: + print 'Trying a recovered cookie...' + response, data = self.getPage('main.php') + if data or response.getheader('location')=='fight.php': + print "Successfully recovered cookie file." + return + + challenge = self.getChallenge() + + formFields = {} + formFields['loggingin'] = 'Yup.' + formFields['loginname'] = nick + if challenge: + print 'Logging in using challenge...' + formFields['challenge'] = challenge + formFields['response'] = challengePassword(challenge,password) + else: + print 'Logging in without challenge...' + formFields['password'] = password + formFields['secure'] = '1' + + response, data = self.postForm('login.php',formFields) + + if response.status == 302: + self.cookie = response.getheader('set-cookie') + file('cookie','w+').write('%s\n%s\n' % (self.hostname,self.cookie)) + print 'Saved cookie file.' + return + + if re.search('Bad password.',data): + raise LoginError, 'Bad password.' + elif re.search('Too many login failures from this IP.',data): + raise LoginError, 'Too many login failures from this IP.' + elif re.search('Too many login attempts',data): + raise LoginError, 'Too many login attempts.' + else: + raise LoginError, data + + + def getChallenge(self): + print 'Getting login challenge...' + response, data = self.getPage('') + while response.status == 302: + #We got redirected + locRE = re.search('http://(www\d?.kingdomofloathing.com)/(.*)',response.getheader('location')) + if locRE: #Bounced off to a different server? + self.hostname = locRE.group(1) + response, data = self.getPage(locRE.group(2)) + else: #Same server, getting loginid= + response, data = self.getPage(response.getheader('location')) + + #We're there. Looking for challenge... + challenge = re.search('<input type=hidden name=challenge value="([0-9a-f]+)">',data) + if challenge: + return challenge.group(1) + else: + return '' Copied: trunk/mall.py (from rev 24, mall.py) =================================================================== --- trunk/mall.py (rev 0) +++ trunk/mall.py 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# +import re + +import kolsite + +class Mall: + def __init__(self, Site): + self.Site = Site + + def searchItem(self, what, limit=None): + formdata = {'whichitem' : what} + if limit: + formdata['cheaponly'] = '1' + formdata['shownum'] = str(limit) + response, data = self.Site.postForm('searchmall.php',formdata) + + offset = re.search('Price:',data).start() + itemRX = re.compile(r'<b>(?P<itemname>.+?)</b> \((?P<itemcount>\d+)\)(?: \((?P<limit>\d+) / day\))?.*?mallstore.php\?whichstore=(?P<whichstore>\d+).*?>(?P<shopname>.+)</a>.*?>(?P<price>[0-9,]+) ') + for itemM in itemRX.finditer(data,offset): + result = {} + for v in ['itemname','itemcount','limit','whichstore','shopname','price']: + if v == 'itemcount': + result[v] = int(itemM.group('itemcount').replace(',','')) + elif v == 'limit' and itemM.group('limit'): + result[v] = int(itemM.group('limit').replace(',','')) + elif v == 'price': + result[v] = int(itemM.group('price').replace(',','')) + elif v == 'whichstore': + result[v] = int(itemM.group('whichstore').replace(',','')) + else: + result[v] = itemM.group(v) + yield result + Copied: trunk/test.py (from rev 24, test.py) =================================================================== --- trunk/test.py (rev 0) +++ trunk/test.py 2007-08-17 10:59:35 UTC (rev 25) @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# +import sys, random +from kolsite import KoLSite +from mall import Mall + + +def main(): + if len(sys.argv) < 2: + print 'Please specify a config file!' + return + config = {} + execfile(sys.argv[1]) + if not config.has_key('nick') or not config.has_key('password'): + print 'Nick or password not specified in config!' + return + + Site = KoLSite() + Site.doLogin(config['nick'],config['password']) + + #response, data = Site.getPage('main.html') + #print response.status + #print data + + M = Mall(Site) + for s in M.searchItem('tiny plastic sword'): + print s + +if __name__ == '__main__': + main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-06-03 22:25:55
|
Revision: 24 http://pykol.svn.sourceforge.net/pykol/?rev=24&view=rev Author: misza13 Date: 2007-06-03 15:25:53 -0700 (Sun, 03 Jun 2007) Log Message: ----------- Added, .pyc and .conf files. Added Paths: ----------- .svnignore Added: .svnignore =================================================================== --- .svnignore (rev 0) +++ .svnignore 2007-06-03 22:25:53 UTC (rev 24) @@ -0,0 +1,2 @@ +*.pyc +*.conf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-06-03 22:20:07
|
Revision: 23 http://pykol.svn.sourceforge.net/pykol/?rev=23&view=rev Author: misza13 Date: 2007-06-03 15:20:04 -0700 (Sun, 03 Jun 2007) Log Message: ----------- Added option parser Modified Paths: -------------- bots/icypeak.py Modified: bots/icypeak.py =================================================================== --- bots/icypeak.py 2007-06-03 22:19:28 UTC (rev 22) +++ bots/icypeak.py 2007-06-03 22:20:04 UTC (rev 23) @@ -6,19 +6,18 @@ # import sys +sys.path.append('.') -sys.path.append('.') +from optparse import OptionParser + from kolsite import KoLSite from campground import Campground from adventure import AutoAdventurer -def main(): - if len(sys.argv) < 2: - print 'Please specify a config file!' - return +def main(options,args): config = {} - execfile(sys.argv[1]) + execfile(options.conf) if not config.has_key('nick') or not config.has_key('password'): print 'Nick or password not specified in config!' return @@ -27,8 +26,21 @@ Site.doLogin(config['nick'],config['password']) AutoAdv = AutoAdventurer(Site) - AutoAdv.adventure('110') + for i in range(options.num): + print 'Adventure %d of %d...' % (i+1,options.num) + AutoAdv.adventure('110') + if __name__ == '__main__': - main() + parser = OptionParser() + parser.add_option('-c', '--conf', dest='conf', + help='use FILE as configuration', metavar='FILE') + parser.add_option('-n', '--num', dest='num', type='int', default=1, + help='adventure NUM times', metavar='NUM') + options, args = parser.parse_args() + + if options.conf: + main(options,args) + else: + parser.print_help() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-06-03 22:19:30
|
Revision: 22 http://pykol.svn.sourceforge.net/pykol/?rev=22&view=rev Author: misza13 Date: 2007-06-03 15:19:28 -0700 (Sun, 03 Jun 2007) Log Message: ----------- Importing missing module Modified Paths: -------------- campground.py Modified: campground.py =================================================================== --- campground.py 2007-05-04 22:22:05 UTC (rev 21) +++ campground.py 2007-06-03 22:19:28 UTC (rev 22) @@ -5,6 +5,8 @@ # Distributed under the terms of the MIT license. # +import re + class Campground: def __init__(self, site): self.site = site This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 22:22:05
|
Revision: 21 http://pykol.svn.sourceforge.net/pykol/?rev=21&view=rev Author: misza13 Date: 2007-05-04 15:22:05 -0700 (Fri, 04 May 2007) Log Message: ----------- Creating a bot that automatically adventures on the Icy Peak. Added Paths: ----------- bots/icypeak.py Added: bots/icypeak.py =================================================================== --- bots/icypeak.py (rev 0) +++ bots/icypeak.py 2007-05-04 22:22:05 UTC (rev 21) @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import sys + +sys.path.append('.') +from kolsite import KoLSite +from campground import Campground +from adventure import AutoAdventurer + + +def main(): + if len(sys.argv) < 2: + print 'Please specify a config file!' + return + config = {} + execfile(sys.argv[1]) + if not config.has_key('nick') or not config.has_key('password'): + print 'Nick or password not specified in config!' + return + + Site = KoLSite() + Site.doLogin(config['nick'],config['password']) + + AutoAdv = AutoAdventurer(Site) + AutoAdv.adventure('110') + + +if __name__ == '__main__': + main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 22:21:22
|
Revision: 20 http://pykol.svn.sourceforge.net/pykol/?rev=20&view=rev Author: misza13 Date: 2007-05-04 15:21:23 -0700 (Fri, 04 May 2007) Log Message: ----------- Removed debugging statements. Modified Paths: -------------- adventure.py Modified: adventure.py =================================================================== --- adventure.py 2007-05-04 21:58:24 UTC (rev 19) +++ adventure.py 2007-05-04 22:21:23 UTC (rev 20) @@ -22,7 +22,6 @@ def fight(self): response, data = self.site.getPage('fight.php') - print data monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) print "You're fighting %s" % monRX.group('monname') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 21:58:26
|
Revision: 19 http://pykol.svn.sourceforge.net/pykol/?rev=19&view=rev Author: misza13 Date: 2007-05-04 14:58:24 -0700 (Fri, 04 May 2007) Log Message: ----------- Added elementary routines for automatic adventuring (start an adventure and attack with weapon until fight is won). Added Paths: ----------- adventure.py Added: adventure.py =================================================================== --- adventure.py (rev 0) +++ adventure.py 2007-05-04 21:58:24 UTC (rev 19) @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +import re + +class AutoAdventurer: + def __init__(self, site): + self.site = site + + def adventure(self, snarfblat): + print 'Starting adventure...' + response, data = self.site.getPage('adventure.php?snarfblat='+snarfblat) + + if response.getheader('location')=='fight.php': + self.fighting = True + while self.fighting: + self.fight() + + def fight(self): + response, data = self.site.getPage('fight.php') + print data + + monRX = re.search(r"You're fighting <span id='monname'>(?P<monname>.*?)</span>",data) + print "You're fighting %s" % monRX.group('monname') + + tackRX = re.search(r"<input id='tack' class=button type=submit value=\"Attack with your (?P<tackitem>.*?)\">",data) + + formdata = { + 'action' : 'attack', + 'tack' : 'Attack with your ' + tackRX.group('tackitem'), + } + response, data = self.site.postForm('fight.php',formdata) + + if "You win the fight!" in data: + print "You win the fight!" + self.fighting = False + else: + self.fighting = True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 21:56:35
|
Revision: 18 http://pykol.svn.sourceforge.net/pykol/?rev=18&view=rev Author: misza13 Date: 2007-05-04 14:56:36 -0700 (Fri, 04 May 2007) Log Message: ----------- Added temporary cookie storage. Modified Paths: -------------- kolsite.py Modified: kolsite.py =================================================================== --- kolsite.py 2007-05-04 21:03:07 UTC (rev 17) +++ kolsite.py 2007-05-04 21:56:36 UTC (rev 18) @@ -90,6 +90,20 @@ def doLogin(self, nick, password): + try: + cookie = file('cookie','r').readlines() + self.cookie = cookie[1][:-1] + self.hostname = cookie[0][:-1] + except: + self.cookie = None + + if self.cookie: + print 'Trying a recovered cookie...' + response, data = self.getPage('main.php') + if data or response.getheader('location')=='fight.php': + print "Successfully recovered cookie file." + return + challenge = self.getChallenge() formFields = {} @@ -108,6 +122,8 @@ if response.status == 302: self.cookie = response.getheader('set-cookie') + file('cookie','w+').write('%s\n%s\n' % (self.hostname,self.cookie)) + print 'Saved cookie file.' return if re.search('Bad password.',data): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 21:03:08
|
Revision: 17 http://pykol.svn.sourceforge.net/pykol/?rev=17&view=rev Author: misza13 Date: 2007-05-04 14:03:07 -0700 (Fri, 04 May 2007) Log Message: ----------- fix Modified Paths: -------------- campground.py Modified: campground.py =================================================================== --- campground.py 2007-05-04 20:52:23 UTC (rev 16) +++ campground.py 2007-05-04 21:03:07 UTC (rev 17) @@ -22,7 +22,7 @@ print "You don't need to rest." break else: - rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)') + rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)',data) if rx: HPgain = int(rx.group('hp')) MPgain = int(rx.group('mp')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-05-04 20:52:23
|
Revision: 16 http://pykol.svn.sourceforge.net/pykol/?rev=16&view=rev Author: misza13 Date: 2007-05-04 13:52:23 -0700 (Fri, 04 May 2007) Log Message: ----------- Created the Campground class with a rest() function. Added Paths: ----------- campground.py Added: campground.py =================================================================== --- campground.py (rev 0) +++ campground.py 2007-05-04 20:52:23 UTC (rev 16) @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# + +class Campground: + def __init__(self, site): + self.site = site + + + def rest(self, count=1): + #Function will return cumulative gains: + cHPgain = 0 + cMPgain = 0 + for i in range(count): + print 'Now resting...' + response, data = self.site.getPage('campground.php?action=rest') + + if "You don't need to rest." in data: + print "You don't need to rest." + break + else: + rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)') + if rx: + HPgain = int(rx.group('hp')) + MPgain = int(rx.group('mp')) + print 'You gained %d HP, %d MP' % (HPgain,MPgain) + return (cHPgain,cMPgain) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-29 19:45:05
|
Revision: 15 http://pykol.svn.sourceforge.net/pykol/?rev=15&view=rev Author: misza13 Date: 2007-04-29 12:45:04 -0700 (Sun, 29 Apr 2007) Log Message: ----------- Adding licensing information. Modified Paths: -------------- kolsite.py mall.py test.py Added Paths: ----------- LICENSE Added: LICENSE =================================================================== --- LICENSE (rev 0) +++ LICENSE 2007-04-29 19:45:04 UTC (rev 15) @@ -0,0 +1,19 @@ +Copyright (C) Misza <mi...@mi...>, 2007 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. Modified: kolsite.py =================================================================== --- kolsite.py 2007-04-08 21:58:49 UTC (rev 14) +++ kolsite.py 2007-04-29 19:45:04 UTC (rev 15) @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- - +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# import re, urllib, httplib try: Modified: mall.py =================================================================== --- mall.py 2007-04-08 21:58:49 UTC (rev 14) +++ mall.py 2007-04-29 19:45:04 UTC (rev 15) @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- - +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# import re import kolsite Modified: test.py =================================================================== --- test.py 2007-04-08 21:58:49 UTC (rev 14) +++ test.py 2007-04-29 19:45:04 UTC (rev 15) @@ -1,5 +1,9 @@ # -*- coding: utf-8 -*- - +# +# (C) Misza <mi...@mi...>, 2007 +# +# Distributed under the terms of the MIT license. +# import sys, random from kolsite import KoLSite from mall import Mall This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-08 21:58:55
|
Revision: 14 http://pykol.svn.sourceforge.net/pykol/?rev=14&view=rev Author: misza13 Date: 2007-04-08 14:58:49 -0700 (Sun, 08 Apr 2007) Log Message: ----------- Creating a directory for specialized bot programs. Added Paths: ----------- bots/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-07 22:10:32
|
Revision: 13 http://pykol.svn.sourceforge.net/pykol/?rev=13&view=rev Author: misza13 Date: 2007-04-07 15:09:38 -0700 (Sat, 07 Apr 2007) Log Message: ----------- Modified the mall searcher into an iterator over the results (using yield). Modified Paths: -------------- mall.py test.py Modified: mall.py =================================================================== --- mall.py 2007-04-07 20:54:13 UTC (rev 12) +++ mall.py 2007-04-07 22:09:38 UTC (rev 13) @@ -11,10 +11,24 @@ def searchItem(self, what, limit=None): formdata = {'whichitem' : what} if limit: - formdata['cheaponly'] = 1 - formdata['shownum'] = limit + formdata['cheaponly'] = '1' + formdata['shownum'] = str(limit) response, data = self.Site.postForm('searchmall.php',formdata) - print response.status - print response.getheaders() - print data + offset = re.search('Price:',data).start() + itemRX = re.compile(r'<b>(?P<itemname>.+?)</b> \((?P<itemcount>\d+)\)(?: \((?P<limit>\d+) / day\))?.*?mallstore.php\?whichstore=(?P<whichstore>\d+).*?>(?P<shopname>.+)</a>.*?>(?P<price>[0-9,]+) ') + for itemM in itemRX.finditer(data,offset): + result = {} + for v in ['itemname','itemcount','limit','whichstore','shopname','price']: + if v == 'itemcount': + result[v] = int(itemM.group('itemcount').replace(',','')) + elif v == 'limit' and itemM.group('limit'): + result[v] = int(itemM.group('limit').replace(',','')) + elif v == 'price': + result[v] = int(itemM.group('price').replace(',','')) + elif v == 'whichstore': + result[v] = int(itemM.group('whichstore').replace(',','')) + else: + result[v] = itemM.group(v) + yield result + Modified: test.py =================================================================== --- test.py 2007-04-07 20:54:13 UTC (rev 12) +++ test.py 2007-04-07 22:09:38 UTC (rev 13) @@ -18,12 +18,13 @@ Site = KoLSite() Site.doLogin(config['nick'],config['password']) - response, data = Site.getPage('main.html') - print response.status - print data + #response, data = Site.getPage('main.html') + #print response.status + #print data M = Mall(Site) - M.searchItem('tiny plastic sword') + for s in M.searchItem('tiny plastic sword'): + print s if __name__ == '__main__': main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-07 20:54:11
|
Revision: 12 http://pykol.svn.sourceforge.net/pykol/?rev=12&view=rev Author: misza13 Date: 2007-04-07 13:54:13 -0700 (Sat, 07 Apr 2007) Log Message: ----------- Adding mall search testing Modified Paths: -------------- test.py Modified: test.py =================================================================== --- test.py 2007-04-07 20:52:15 UTC (rev 11) +++ test.py 2007-04-07 20:54:13 UTC (rev 12) @@ -2,6 +2,7 @@ import sys, random from kolsite import KoLSite +from mall import Mall def main(): @@ -14,12 +15,15 @@ print 'Nick or password not specified in config!' return - Site = KoLSite('www%s.kingdomofloathing.com' % random.choice('12345678')) + Site = KoLSite() Site.doLogin(config['nick'],config['password']) response, data = Site.getPage('main.html') print response.status print data + M = Mall(Site) + M.searchItem('tiny plastic sword') + if __name__ == '__main__': main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-07 20:52:14
|
Revision: 11 http://pykol.svn.sourceforge.net/pykol/?rev=11&view=rev Author: misza13 Date: 2007-04-07 13:52:15 -0700 (Sat, 07 Apr 2007) Log Message: ----------- Creating the Mall() class, with dumb item searching. Added Paths: ----------- mall.py Added: mall.py =================================================================== --- mall.py (rev 0) +++ mall.py 2007-04-07 20:52:15 UTC (rev 11) @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +import re + +import kolsite + +class Mall: + def __init__(self, Site): + self.Site = Site + + def searchItem(self, what, limit=None): + formdata = {'whichitem' : what} + if limit: + formdata['cheaponly'] = 1 + formdata['shownum'] = limit + response, data = self.Site.postForm('searchmall.php',formdata) + + print response.status + print response.getheaders() + print data This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-04-07 20:43:01
|
Revision: 10 http://pykol.svn.sourceforge.net/pykol/?rev=10&view=rev Author: misza13 Date: 2007-04-07 13:42:58 -0700 (Sat, 07 Apr 2007) Log Message: ----------- Major improvement of the login system (supports server rotation). Modified Paths: -------------- kolsite.py Modified: kolsite.py =================================================================== --- kolsite.py 2007-03-31 21:05:49 UTC (rev 9) +++ kolsite.py 2007-04-07 20:42:58 UTC (rev 10) @@ -41,16 +41,18 @@ class KoLSite: - def __init__(self, hostname): - self.hostname = hostname - self.cookie = '' + def __init__(self): + self.hostname = 'www.kingdomofloathing.com' + self.cookie = None def getPage(self, address, data=''): + #print 'GET http://' + self.hostname + '/' + address conn = httplib.HTTPConnection(self.hostname) conn.putrequest('GET', '/' + address) - conn.putheader('Cookie', self.cookie) + if self.cookie: + conn.putheader('Cookie', self.cookie) conn.endheaders() conn.send('') @@ -66,10 +68,14 @@ def postData(self, address, data=''): + #print 'POST http://' + self.hostname + '/' + address conn = httplib.HTTPConnection(self.hostname) conn.putrequest('POST', '/' + address) + if self.cookie: + conn.putheader('Cookie', self.cookie) conn.putheader('Content-Length', str(len(data))) + conn.putheader('Content-Type', 'application/x-www-form-urlencoded') conn.endheaders() conn.send(data) @@ -86,13 +92,14 @@ formFields['loggingin'] = 'Yup.' formFields['loginname'] = nick if challenge: + print 'Logging in using challenge...' formFields['challenge'] = challenge formFields['response'] = challengePassword(challenge,password) else: + print 'Logging in without challenge...' formFields['password'] = password formFields['secure'] = '1' - print 'Now logging in...' response, data = self.postForm('login.php',formFields) if response.status == 302: @@ -111,7 +118,17 @@ def getChallenge(self): print 'Getting login challenge...' - response, data = self.getPage('login.php') + response, data = self.getPage('') + while response.status == 302: + #We got redirected + locRE = re.search('http://(www\d?.kingdomofloathing.com)/(.*)',response.getheader('location')) + if locRE: #Bounced off to a different server? + self.hostname = locRE.group(1) + response, data = self.getPage(locRE.group(2)) + else: #Same server, getting loginid= + response, data = self.getPage(response.getheader('location')) + + #We're there. Looking for challenge... challenge = re.search('<input type=hidden name=challenge value="([0-9a-f]+)">',data) if challenge: return challenge.group(1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-03-31 21:05:49
|
Revision: 9 http://pykol.svn.sourceforge.net/pykol/?rev=9&view=rev Author: misza13 Date: 2007-03-31 14:05:49 -0700 (Sat, 31 Mar 2007) Log Message: ----------- Syntax error. Modified Paths: -------------- kolsite.py Modified: kolsite.py =================================================================== --- kolsite.py 2007-03-31 20:35:01 UTC (rev 8) +++ kolsite.py 2007-03-31 21:05:49 UTC (rev 9) @@ -88,7 +88,7 @@ if challenge: formFields['challenge'] = challenge formFields['response'] = challengePassword(challenge,password) - else" + else: formFields['password'] = password formFields['secure'] = '1' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-03-31 20:35:01
|
Revision: 8 http://pykol.svn.sourceforge.net/pykol/?rev=8&view=rev Author: misza13 Date: 2007-03-31 13:35:01 -0700 (Sat, 31 Mar 2007) Log Message: ----------- Allow non-secure login fallback. Modified Paths: -------------- kolsite.py Modified: kolsite.py =================================================================== --- kolsite.py 2007-03-31 20:31:25 UTC (rev 7) +++ kolsite.py 2007-03-31 20:35:01 UTC (rev 8) @@ -85,9 +85,11 @@ formFields = {} formFields['loggingin'] = 'Yup.' formFields['loginname'] = nick - formFields['challenge'] = challenge - formFields['response'] = challengePassword(challenge,password) - #formFields['password'] = password + if challenge: + formFields['challenge'] = challenge + formFields['response'] = challengePassword(challenge,password) + else" + formFields['password'] = password formFields['secure'] = '1' print 'Now logging in...' @@ -97,7 +99,6 @@ self.cookie = response.getheader('set-cookie') return - #print response.status if re.search('Bad password.',data): raise LoginError, 'Bad password.' elif re.search('Too many login failures from this IP.',data): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mi...@us...> - 2007-03-31 20:31:24
|
Revision: 7 http://pykol.svn.sourceforge.net/pykol/?rev=7&view=rev Author: misza13 Date: 2007-03-31 13:31:25 -0700 (Sat, 31 Mar 2007) Log Message: ----------- Adding server randomisation (far from perfect) Modified Paths: -------------- test.py Modified: test.py =================================================================== --- test.py 2007-03-31 20:12:02 UTC (rev 6) +++ test.py 2007-03-31 20:31:25 UTC (rev 7) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import sys +import sys, random from kolsite import KoLSite @@ -14,7 +14,7 @@ print 'Nick or password not specified in config!' return - Site = KoLSite('www.kingdomofloathing.com') + Site = KoLSite('www%s.kingdomofloathing.com' % random.choice('12345678')) Site.doLogin(config['nick'],config['password']) response, data = Site.getPage('main.html') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |