scelis/pykol — pull request #24 by thijsdezoete (2013-06-03 16:37:22+00:00)
Title: Factory pattern for request and database classes

Example bot in readme could be rewritten like this:

```python
from factory import KolFactory as F
from kol.Session import Session

# Login to the KoL servers.
s = Session()
s.login("myUserName", "myPassword")

# Get a list of your kmails and print them out.
r = F('GetMessagesRequest', s)
responseData = r.doRequest()
kmails = responseData["kmails"]
for kmail in kmails:
print "Received kmail from %s (#%s)" % (kmail["userName"], kmail["userId"])
print "Text: %s" % kmail["text"]
print "Meat: %s" % kmail["meat"]
for item in kmail["items"]:
print "Item: %s (%s)" % (item["name"], item["quantity"])

# Use an old coin purse.
item = F('ItemDatabase').getItemFromName("old coin purse")
r = F('UseItemRequest', s, item["id"])
r.doRequest()

# Smash a titanium assault umbrella and print out the results.
item = F('ItemDatabase').getItemFromName("titanium assault umbrella")
r = F('PulverizeRequest', s, item["id"])
responseData = r.doRequest()
smashResults = responseData["results"]
print "After smashing the item you have received the following:"
for result in smashResults:
print "%s (%s)" % (result["name"], result["quantity"])

# Now we logout.
s.logout()
```