Last active
August 29, 2015 14:14
-
-
Save rascul/46fe1e42a08af41e9c9d to your computer and use it in GitHub Desktop.
Submit a file full of stats to wotmad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# set this stuff | |
apikey = "blahblahblah" | |
statfile = "newbie.stats" | |
name = "test" | |
sex = "M" | |
faction = "H" | |
cclass = "W" | |
homeland = "illian" | |
# touch nothing else! | |
import re | |
import requests | |
repattern = r'^Your base abilities are: Str:(?P<str>\d+) Int:(?P<int>\d+) Wil:(?P<wil>\d+) Dex:(?P<dex>\d+) Con:(?P<con>\d+)( Sum:(?P<sum>\d+))?$' | |
with open(statfile, "r") as f: | |
for line in f: | |
m = re.match(repattern, line) | |
if m.group('str') and m.group('int') and m.group('wil') and m.group('dex') and m.group('con'): | |
payload = { | |
'apikey': apikey, | |
'name': name, | |
'sex': sex, | |
'faction': faction, | |
'homeland': homeland, | |
'class': cclass, | |
'strength': m.group('str'), | |
'intel': m.group('int'), | |
'wil': m.group('wil'), | |
'dex': m.group('dex'), | |
'con': m.group('con'), | |
} | |
r = requests.get('http://wotmad.herokuapp.com/stats/submit/', params=payload) | |
print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment