Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
16cae24712 | |||
3e051fe906 | |||
aa9cda9314 | |||
fc66db8cab | |||
6bbc4f8768 | |||
160b32a914 | |||
a51c3c620e | |||
a1c26468eb |
10
HISTORY.rst
10
HISTORY.rst
@ -2,12 +2,18 @@
|
||||
History
|
||||
=======
|
||||
|
||||
0.22.2 (2020-11-9)
|
||||
0.22.3 (2020-11-16)
|
||||
-------------------
|
||||
* Fixed round to even bug when doing wam and not enough raw.
|
||||
* Added meta industry airplaneRaw
|
||||
* Added method `Citizen.buy_market_offer(OfferItem, amount=None)` to directly buy market offer with included travel to country and back.
|
||||
|
||||
0.22.2 (2020-11-09)
|
||||
-------------------
|
||||
* Allow querying market offers for q2-q5 aircrafts
|
||||
* Added "Ticket" industry
|
||||
|
||||
0.22.1 (2020-11-4)
|
||||
0.22.1 (2020-11-04)
|
||||
-------------------
|
||||
* Requirement update
|
||||
* Unified product naming in inventory and other places based on `erepublik.constants.INDUSTRIES` values
|
||||
|
@ -93,8 +93,8 @@
|
||||
<label class="custom-control-label" for="wam">Work as manager</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" onchange="updateJson()" id="employ">
|
||||
<label class="custom-control-label" for="employ">Employ employees</label>
|
||||
<input type="checkbox" class="custom-control-input" onchange="updateJson()" id="employees">
|
||||
<label class="custom-control-label" for="employees">Employ employees</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" onchange="updateJson()" id="auto_buy_raw" checked>
|
||||
@ -236,8 +236,8 @@
|
||||
config.debug = debug.checked;
|
||||
let wam = document.getElementById('wam'); // Generated
|
||||
config.wam = wam.checked;
|
||||
let employ = document.getElementById('employ'); // Generated
|
||||
config.employ = employ.checked;
|
||||
let employees = document.getElementById('employees'); // Generated
|
||||
config.employees = employees.checked;
|
||||
|
||||
let auto_buy_raw = document.getElementById('auto_buy_raw'); // Generated
|
||||
let auto_sell_all = document.getElementById('auto_sell_all'); // Generated
|
||||
@ -249,7 +249,7 @@
|
||||
let auto_sell_house = document.getElementById('auto_sell_house'); // Generated
|
||||
let auto_sell_arm = document.getElementById('auto_sell_arm'); // Generated
|
||||
let auto_sell_air = document.getElementById('auto_sell_air'); // Generated
|
||||
if (config.wam || config.employ) {
|
||||
if (config.wam || config.employees) {
|
||||
auto_buy_raw.disabled = false;
|
||||
auto_sell_all.disabled = false;
|
||||
auto_sell_frm.disabled = false;
|
||||
@ -359,7 +359,7 @@
|
||||
"interactive": true,
|
||||
"debug": true,
|
||||
"wam": true,
|
||||
"employ": true,
|
||||
"employees": true,
|
||||
"auto_buy_raw": true,
|
||||
"auto_sell_all": true,
|
||||
"auto_sell": [
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.22.2.1'
|
||||
__version__ = '0.22.3'
|
||||
|
||||
from erepublik import classes, utils, constants
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -15,9 +15,11 @@ class SlowRequests(Session):
|
||||
timeout: datetime.timedelta = datetime.timedelta(milliseconds=500)
|
||||
uas: List[str] = [
|
||||
# Chrome
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36',
|
||||
|
@ -12,6 +12,7 @@ from typing import Any, Dict, List, NoReturn, Optional, Set, Tuple, Union
|
||||
from requests import HTTPError, RequestException, Response
|
||||
|
||||
from . import utils, classes, access_points, constants
|
||||
from .classes import OfferItem
|
||||
|
||||
|
||||
class BaseCitizen(access_points.CitizenAPI):
|
||||
@ -688,9 +689,15 @@ class BaseCitizen(access_points.CitizenAPI):
|
||||
if re.search(r'Occasionally there are a couple of things which we need to check or to implement in order make '
|
||||
r'your experience in eRepublik more pleasant. <strong>Don\'t worry about ongoing battles, timer '
|
||||
r'will be stopped during maintenance.</strong>', response.text):
|
||||
self.write_log("eRepublik ss having maintenance. Sleeping for 5 minutes")
|
||||
self.write_log("eRepublik is having maintenance. Sleeping for 5 minutes")
|
||||
self.sleep(5 * 60)
|
||||
return True
|
||||
|
||||
if re.search('We are experiencing some tehnical dificulties', response.text):
|
||||
self.write_log("eRepublik is having technical difficulties. Sleeping for 5 minutes")
|
||||
self.sleep(5 * 60)
|
||||
return True
|
||||
|
||||
return bool(re.search(r'body id="error"|Internal Server Error|'
|
||||
r'CSRF attack detected|meta http-equiv="refresh"|'
|
||||
r'not_authenticated', response.text))
|
||||
@ -1147,6 +1154,24 @@ class CitizenEconomy(CitizenTravel):
|
||||
self._report_action("BOUGHT_PRODUCTS", json_ret.get('message'), kwargs=json_ret)
|
||||
return json_ret
|
||||
|
||||
def buy_market_offer(self, offer: OfferItem, amount: int = None) -> dict:
|
||||
if amount is None or amount > offer.amount:
|
||||
amount = offer.amount
|
||||
traveled = False
|
||||
if not self.details.current_country == offer.country:
|
||||
traveled = True
|
||||
self.travel_to_country(offer.country)
|
||||
ret = self._post_economy_marketplace_actions('buy', offer=offer.offer_id, amount=amount)
|
||||
json_ret = ret.json()
|
||||
if not json_ret.get('error', True):
|
||||
self.details.cc = ret.json()['currency']
|
||||
self.details.gold = ret.json()['gold']
|
||||
json_ret.pop("offerUpdate", None)
|
||||
self._report_action("BOUGHT_PRODUCTS", json_ret.get('message'), kwargs=json_ret)
|
||||
if traveled:
|
||||
self.travel_to_residence()
|
||||
return json_ret
|
||||
|
||||
def get_market_offers(
|
||||
self, product_name: str, quality: int = None, country: constants.Country = None
|
||||
) -> Dict[str, classes.OfferItem]:
|
||||
@ -2569,7 +2594,7 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
||||
if raw_kind:
|
||||
raw_kind = raw_kind.group(1)
|
||||
result = response.get("result", {})
|
||||
amount_needed = round(result.get("consume", 0) - result.get("stock", 0) + 0.49)
|
||||
amount_needed = round(result.get("consume", 0) - result.get("stock", 0) + 0.5)
|
||||
self._report_action(
|
||||
'WORK_AS_MANAGER', f"Unable to wam! Missing {amount_needed} {raw_kind}, will try to buy.",
|
||||
kwargs=response
|
||||
|
@ -54,7 +54,7 @@ class Country:
|
||||
|
||||
class Industries:
|
||||
__by_name = {'food': 1, 'weapon': 2, 'ticket':3, 'house': 4, 'aircraft': 23,
|
||||
'foodraw': 7, 'weaponraw': 12, 'houseraw': 18, 'aircraftraw': 24,
|
||||
'foodraw': 7, 'weaponraw': 12, 'houseraw': 18, 'aircraftraw': 24, 'airplaneraw': 24,
|
||||
'frm': 7, 'wrm': 12, 'hrm': 18, 'arm': 24,
|
||||
'frm q1': 7, 'frm q2': 8, 'frm q3': 9, 'frm q4': 10, 'frm q5': 11,
|
||||
'wrm q1': 12, 'wrm q2': 13, 'wrm q3': 14, 'wrm q4': 15, 'wrm q5': 16,
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.22.2.1
|
||||
current_version = 0.22.3
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
|
Reference in New Issue
Block a user