Type hinting. Class parameter defined lists where shared accross instances.
This commit is contained in:
parent
aba8c15fd3
commit
39093accd0
@ -26,9 +26,9 @@ class Citizen(CitizenAPI):
|
|||||||
|
|
||||||
active_fs: bool = False
|
active_fs: bool = False
|
||||||
|
|
||||||
food = {"q1": 0, "q2": 0, "q3": 0, "q4": 0, "q5": 0, "q6": 0, "q7": 0, "total": 0}
|
food: Dict[str, int] = {"q1": 0, "q2": 0, "q3": 0, "q4": 0, "q5": 0, "q6": 0, "q7": 0, "total": 0}
|
||||||
inventory = {"used": 0, "total": 0}
|
inventory: Dict[str, int] = {"used": 0, "total": 0}
|
||||||
boosters = {100: {}, 50: {}}
|
boosters: Dict[int, Dict[int, int]] = {100: {}, 50: {}}
|
||||||
|
|
||||||
eb_normal = 0
|
eb_normal = 0
|
||||||
eb_double = 0
|
eb_double = 0
|
||||||
|
@ -271,7 +271,7 @@ class Config:
|
|||||||
work = True
|
work = True
|
||||||
train = True
|
train = True
|
||||||
wam = False
|
wam = False
|
||||||
auto_sell: List[str] = list()
|
auto_sell: List[str] = None
|
||||||
auto_sell_all = False
|
auto_sell_all = False
|
||||||
employees = False
|
employees = False
|
||||||
fight = False
|
fight = False
|
||||||
@ -295,6 +295,9 @@ class Config:
|
|||||||
telegram_chat_id = 0
|
telegram_chat_id = 0
|
||||||
telegram_token = ""
|
telegram_token = ""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.auto_sell = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wt(self):
|
def wt(self):
|
||||||
return self.work and self.train
|
return self.work and self.train
|
||||||
@ -379,7 +382,7 @@ class Details:
|
|||||||
pp = 0
|
pp = 0
|
||||||
pin = None
|
pin = None
|
||||||
gold = 0
|
gold = 0
|
||||||
next_pp: List[int] = []
|
next_pp: List[int] = None
|
||||||
citizen_id = 0
|
citizen_id = 0
|
||||||
citizenship = 0
|
citizenship = 0
|
||||||
current_region = 0
|
current_region = 0
|
||||||
@ -390,6 +393,9 @@ class Details:
|
|||||||
daily_task_reward = False
|
daily_task_reward = False
|
||||||
mayhem_skills = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, }
|
mayhem_skills = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, }
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.next_pp = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def xp_till_level_up(self):
|
def xp_till_level_up(self):
|
||||||
if self.xp >= 10000:
|
if self.xp >= 10000:
|
||||||
@ -928,9 +934,19 @@ Class for unifying eRepublik known endpoints and their required/optional paramet
|
|||||||
data = {'nodeId': node_id, '_token': self.token}
|
data = {'nodeId': node_id, '_token': self.token}
|
||||||
return self.post("{}/main/map-rewards-claim".format(self.url), data=data)
|
return self.post("{}/main/map-rewards-claim".format(self.url), data=data)
|
||||||
|
|
||||||
|
def _post_new_war(self, self_country_id: int, attack_country_id: int, debate: str = "") -> Response:
|
||||||
|
data = dict(requirments=1, _token=self.token, debate=debate,
|
||||||
|
countryNameConfirm=utils.COUNTRY_LINK[attack_country_id])
|
||||||
|
return self.post("{}/{}/new-war".format(self.url, utils.COUNTRY_LINK[self_country_id]), data=data)
|
||||||
|
|
||||||
|
def _post_new_donation(self, country_id: int, amount: int, org_name: str, debate: str = "") -> Response:
|
||||||
|
data = dict(requirments=1, _token=self.token, debate=debate, currency=1, value=amount, commit='Propose',
|
||||||
|
type_name=org_name)
|
||||||
|
return self.post("{}/{}/new-donation".format(self.url, utils.COUNTRY_LINK[country_id]), data=data)
|
||||||
|
|
||||||
|
|
||||||
class Reporter:
|
class Reporter:
|
||||||
__to_update: List[Dict[Any, Any]] = []
|
__to_update: List[Dict[Any, Any]] = None
|
||||||
name: str = ""
|
name: str = ""
|
||||||
email: str = ""
|
email: str = ""
|
||||||
citizen_id: int = 0
|
citizen_id: int = 0
|
||||||
@ -946,6 +962,7 @@ class Reporter:
|
|||||||
self._req = Session()
|
self._req = Session()
|
||||||
self.url = "https://api.erep.lv"
|
self.url = "https://api.erep.lv"
|
||||||
self._req.headers.update({"user-agent": "Bot reporter v2"})
|
self._req.headers.update({"user-agent": "Bot reporter v2"})
|
||||||
|
self.__to_update = []
|
||||||
self.__registered: bool = False
|
self.__registered: bool = False
|
||||||
|
|
||||||
def do_init(self, name: str = "", email: str = "", citizen_id: int = 0):
|
def do_init(self, name: str = "", email: str = "", citizen_id: int = 0):
|
||||||
@ -1047,8 +1064,8 @@ class BattleSide:
|
|||||||
class BattleDivision:
|
class BattleDivision:
|
||||||
end: datetime.datetime
|
end: datetime.datetime
|
||||||
epic: bool
|
epic: bool
|
||||||
dom_pts: Dict[str, int] = None
|
dom_pts: Dict[str, int]
|
||||||
wall: Dict[str, Union[int, float]] = None
|
wall: Dict[str, Union[int, float]]
|
||||||
battle_zone_id: int
|
battle_zone_id: int
|
||||||
def_medal: Dict[str, int]
|
def_medal: Dict[str, int]
|
||||||
inv_medal: Dict[str, int]
|
inv_medal: Dict[str, int]
|
||||||
@ -1071,15 +1088,15 @@ class BattleDivision:
|
|||||||
|
|
||||||
|
|
||||||
class Battle:
|
class Battle:
|
||||||
id: int = 0
|
id: int
|
||||||
war_id: int = 0
|
war_id: int
|
||||||
zone_id: int = 0
|
zone_id: int
|
||||||
is_rw: bool = False
|
is_rw: bool
|
||||||
is_dict_lib: bool = False
|
is_dict_lib: bool
|
||||||
start: datetime.datetime = None
|
start: datetime.datetime
|
||||||
invader: BattleSide = None
|
invader: BattleSide
|
||||||
defender: BattleSide = None
|
defender: BattleSide
|
||||||
div: Dict[int, BattleDivision] = None
|
div: Dict[int, BattleDivision]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_air(self) -> bool:
|
def is_air(self) -> bool:
|
||||||
@ -1171,17 +1188,19 @@ class EnergyToFight:
|
|||||||
|
|
||||||
class TelegramBot:
|
class TelegramBot:
|
||||||
__initialized = False
|
__initialized = False
|
||||||
__queue: List[str] = []
|
__queue: List[str]
|
||||||
chat_id = 0
|
chat_id = 0
|
||||||
api_url = ""
|
api_url = ""
|
||||||
player_name = ""
|
player_name = ""
|
||||||
__thread_stopper: threading.Event = None
|
__thread_stopper: threading.Event
|
||||||
_last_time: datetime.datetime = None
|
_last_time: datetime.datetime
|
||||||
_last_full_energy_report: datetime.datetime = None
|
_last_full_energy_report: datetime.datetime
|
||||||
_next_time: datetime.datetime = None
|
_next_time: datetime.datetime
|
||||||
_threads: List[threading.Thread] = []
|
_threads: List[threading.Thread]
|
||||||
|
|
||||||
def __init__(self, stop_event: threading.Event = None):
|
def __init__(self, stop_event: threading.Event = None):
|
||||||
|
self._threads = []
|
||||||
|
self.__queue = []
|
||||||
self.__thread_stopper = threading.Event() if stop_event is None else stop_event
|
self.__thread_stopper = threading.Event() if stop_event is None else stop_event
|
||||||
|
|
||||||
def __dict__(self):
|
def __dict__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user