PDA

View Full Version : Neolib



AliasXNeo
09-15-2012, 01:45 PM
Neolib ([Only registered and activated users can see links])

Neolib is an in-depth and robust Python library designed to assist programmers in creating programs which automate mundane tasks on the popular browser based game, Neopets. The goal of Neolib is to objectify Neopets by translating it's many objects and tasks into classes and functions that represent them.

Project URL: [Only registered and activated users can see links]
[Only registered and activated users can see links]
Repository Type: Git
Python Version: 3.2.3

Current Team Members


Alias (Project Leader)

Helpful Information


Git for Windows (includes GUI): [Only registered and activated users can see links]
Official book on Git: [Only registered and activated users can see links]
Getting started with GitHub: [Only registered and activated users can see links] ([Only registered and activated users can see links])
Documenting Python: [Only registered and activated users can see links] ([Only registered and activated users can see links])

Project News


21 Sep - Now that the base has been laid, Neolib is now open source again!

Why Join?


By joining you will be participating in a project that directly helps Clraik
Participation in the project will teach you important concepts that can help develop your skills as a programmer. These include version control, documentation, and all the little things you learn by interacting with other programmers in a project environment
Your contributions will help several programmers!

Before you join


Please checkout the repository from Github and spend time reviewing the code including any recent commits.
If you have any questions please feel free to contact a project member or join #neolib on Freenode and talk to someone in there.
Ensure to review any open issues and enhancements and check the wiki for amplifying information
Please understand that this project is running under Python 2.7.3. If you don't know what that means, please figure it out.
If you have never used Git, please use the above links to educate yourself prior to joining the project. It is vital you understand how Git works as it differs from it's counterparts like subversion.
Once you have completed the above steps, and thoroughly reviewed the project, then please submit an application (format shown below) via PM to me (alias).



--------------------------------------------------------------------------------------
Feel free to post your feelings, concerns, and/or broad questions below :p

Member Application


Name (First name):
Programming experience in years:
Proficient languages:
Experience with Python in years:
Have you ever used Git? If not, have you since learned how?
Have you ever been apart of a project like this? Explain.
Why do you want to join the project?
Any amplifying information?

I_royalty_I
09-15-2012, 02:03 PM
Interesting concept for sure.
Do you have a more well known username on another site?

AliasXNeo
09-15-2012, 02:11 PM
I did a lot of programming about 6 years ago when my username was known a lot more (I've made at least one of every popular program type, including a premium MAB I sold). I have since returned to the programming scene for another bout :)

I don't really have much to brag with since it's all long gone. However, here's some sample code of the latest version of the library (0.2):


from neolib.user.User import User
from neolib.daily.Daily import Daily

usr = User("username", "password")
if usr.login(): print "Logged in!"

list = ['Tombola', 'FruitMachine', 'PetPetPark']
for message in Daily.doDailies(usr, list):
print message

print "All dailies done!"

That's an example of the user end. For the developer end, here's a sample:


def __init__(self, usr):
if not usr:
raise invalidUser

self.items = {}
pg = usr.getPage("[Only registered and activated users can see links]")

# Indicates an empty inventory
if pg.content.find("You aren't carrying anything") != -1:
return

try:
for row in pg.find_all("td", "contentModuleContent")[1].table.find_all("tr"):
for item in row.find_all("td"):
name = item.text

# Some item names contain extra information encapsulated in paranthesis
if name.find("(") != -1:
name = name.split("(")[0]

tmpItem = Item(name)
tmpItem.id = item.a['onclick'].split("(")[1].replace(");", "")
tmpItem.img = item.img['src']
tmpItem.desc = item.img['alt']
tmpItem.usr = usr

self.items[name] = tmpItem
except Exception:
logging.getLogger("neolib.inventory").exception("Unable to parse user inventory.")
logging.getLogger("neolib.html").info("Unable to parse user inventory.", {'pg': pg})
raise parseException

That's the code for the UserInventory class __init__() method.

j03
09-15-2012, 04:07 PM
If I wasn't so busy with school and my own projects I have going I would definitely join in on this.

AliasXNeo
09-15-2012, 04:57 PM
If I wasn't so busy with school and my own projects I have going I would definitely join in on this.

Yeah that's been the case with most programmers, its been tough finding contributers :p

j03
09-15-2012, 05:46 PM
Yeah that's been the case with most programmers, its been tough finding contributers :p

To be honest, I have something similar to this being made as we speak. :P Been working on it for a while now and it will most likely be closed-source.

AliasXNeo
09-15-2012, 08:12 PM
To be honest, I have something similar to this being made as we speak. :P Been working on it for a while now and it will most likely be closed-source.

That's cool. This will most likely remain closed source as well, seeing as how powerful it is turning out to be. I've been having a blast refactoring it and making it more Pythonic (then again Python is fun to begin with).

Well anyways, for those that are interested just shoot me a PM. It's currently hosted on a private Github repo at the moment. The base has been laid and focus is currently on expanding the object base (currently supports the basics like inventory, user shops, shop wizard, SDB, etc.).

j03
10-02-2012, 08:33 PM
Hopefully you saved everything you had updated the first post to? :(

j03
10-03-2012, 08:02 PM
That's what a repository is for

No I meant his first post, it had a pretty descriptive paragraph and all that.

ikakk
10-03-2012, 09:38 PM
Github link:
[Only registered and activated users can see links]

AliasXNeo
10-04-2012, 09:07 AM
I'l update the original post again :)

Just a warning to anyone currently using or thinking about using the project, I will be moving to Python 3 with the next release. In fact, the next revision is going to change a lot of the HTTP core. My current intentions are to move the current master branch to a new branch to maintain the Python 2 compatibility, and then update the master branch to the Python 3 version. I also did revision of the configuration system, which I talked about here ([Only registered and activated users can see links]).

Zachafer
10-05-2012, 11:19 AM
Github link:
[Only registered and activated users can see links]


I'l update the original post again :)

Just a warning to anyone currently using or thinking about using the project, I will be moving to Python 3 with the next release. In fact, the next revision is going to change a lot of the HTTP core. My current intentions are to move the current master branch to a new branch to maintain the Python 2 compatibility, and then update the master branch to the Python 3 version. I also did revision of the configuration system, which I talked about here ([Only registered and activated users can see links]).

Welcome to our site you two :)

AliasXNeo
10-05-2012, 06:32 PM
Welcome to our site you two :)

Thanks.

The master branch now reflects the Python 3 changes. The latest stable for Python 2 is now on branch 'py27'. I havn't tested the latest commit with Windows yet (developing on CrunchBang Linux), however I'll do so tonight and update with any hot fixes.

AliasXNeo
10-07-2012, 01:22 AM
Since the some of the old thread content was lost, here's some more showing off :) This is the very basic main loop I have for the UAB I am developing. Searches for an item, buys it if it's cheap enough, then stocks and prices it and repeats.


def mainLoop(self):

while True:
for item in self.items:
cmpPrice = item.price - self.dedAmount

r = ShopWizard.search(self.usr, item.name)

if (int(r[0].price) < cmpPrice):
if r.buy(0):
print ("Bought " + item.name + " at " + str(item.price))

self.usr.inventory.load()
if not item.name in usr.inventory:
print("Error handling item: " + item.name)
continue

self.usr.inventory[item.name].stock()
self.usr.shop.load()
self.usr.shop.inventory[item.name].price = ShopWizard.price(self.usr, item.name, method=ShopWizard.AVERAGE)
self.usr.shop.update()

print("Handled " + item.name + " successfully")
else:
print ("Missed " + item.name)

That being said, I am having trouble finding a python 3.x imaging library that plays well with the main shop captcha. If anyone is interested in really helping this library out, a main shop OCR module would be extremely helpful :)

AliasXNeo
10-18-2012, 11:36 PM
Turns out the current release of Neolib is completely backwards compatible with Python 2.x. That being said, I'm going to go ahead and officially move back to Python 2.x and transfer the current master branch to 'py3k'.

I've started work on the OCR crack with the Python Imaging Library, however due to real life issues I've had little time to improve the accuracy. Anyone interested in helping me pick up the slack let me know. Cheers.

---------- Post added at 11:36 PM ---------- Previous post was at 11:36 PM ----------

Turns out the current release of Neolib is completely backwards compatible with Python 2.x. That being said, I'm going to go ahead and officially move back to Python 2.x and transfer the current master branch to 'py3k'.

I've started work on the OCR crack with the Python Imaging Library, however due to real life issues I've had little time to improve the accuracy. Anyone interested in helping me pick up the slack let me know. Cheers.

Zachafer
10-19-2012, 12:25 AM
Turns out the current release of Neolib is completely backwards compatible with Python 2.x. That being said, I'm going to go ahead and officially move back to Python 2.x and transfer the current master branch to 'py3k'.

I've started work on the OCR crack with the Python Imaging Library, however due to real life issues I've had little time to improve the accuracy. Anyone interested in helping me pick up the slack let me know. Cheers.

---------- Post added at 11:36 PM ---------- Previous post was at 11:36 PM ----------

Turns out the current release of Neolib is completely backwards compatible with Python 2.x. That being said, I'm going to go ahead and officially move back to Python 2.x and transfer the current master branch to 'py3k'.

I've started work on the OCR crack with the Python Imaging Library, however due to real life issues I've had little time to improve the accuracy. Anyone interested in helping me pick up the slack let me know. Cheers.

Have you posted the OCR code? I'd like to see it ;)

AliasXNeo
10-19-2012, 09:57 AM
Well here's a start:


im = Image.open("capt.jpg")
im = im.convert("L")
l, h = im.getextrema()
p = im.point(lambda x: x == l)
x, y, _, _ = p.getbbox()

That usually gets you right on the border of the pet, so it's a starting place (but Neopets usually doesn't like the cords). Just need to grab 3 more points and use it as a virtual box and just aim for the middle.

---------- Post added at 09:57 AM ---------- Previous post was at 09:57 AM ----------

Well here's a start:


im = Image.open("capt.jpg")
im = im.convert("L")
l, h = im.getextrema()
p = im.point(lambda x: x == l)
x, y, _, _ = p.getbbox()

That usually gets you right on the border of the pet, so it's a starting place (but Neopets usually doesn't like the cords). Just need to grab 3 more points and use it as a virtual box and just aim for the middle.

AliasXNeo
10-23-2012, 03:53 PM
All un-revisioned or incomplete changes are being committed to the 'dev' branch. If you're wanting to use the bleeding-edge of this library, please checkout that branch rather than the master branch. The master branch will be updated with the dev branch once all goals of a revision have been met. The latest commit includes the above OCR code.

AliasXNeo
10-30-2012, 12:20 PM
Major update today to V1.0.0. This is the first major public release of Neolib. A PyPi package has been created to allow for installation with easy_install:


easy_install neolib

A more in-depth README can also be found on the Github page.[COLOR="Silver"]

j03
10-30-2012, 04:16 PM
Major update today to V1.0.0. This is the first major public release of Neolib. A PyPi package has been created to allow for installation with easy_install:


easy_install neolib

A more in-depth README can also be found on the Github page.

---------- Post added at 12:20 PM ---------- Previous post was at 12:20 PM ----------

Major update today to V1.0.0. This is the first major public release of Neolib. A PyPi package has been created to allow for installation with easy_install:


easy_install neolib

A more in-depth README can also be found on the Github page.

This is brilliant!

Edit: How come you are continuously double posting now? Guessing you are on some mobile device? B)

AliasXNeo
10-30-2012, 07:51 PM
This is brilliant!

Edit: How come you are continuously double posting now? Guessing you are on some mobile device? B)

Thanks. Glad to finally have a truly stable version out. For some reason vBulletin doesn't like Chromium. Every post is a double post and I can't seem to edit any of my posts either. I'm on Chrome now and it works fine, not sure what the issue is.