This commit is contained in:
Eriks K 2020-07-11 10:21:12 +03:00
parent d044af6d2f
commit d70c3e2c9e
2 changed files with 14 additions and 18 deletions

View File

@ -161,14 +161,14 @@ class ErepublikArticleAPI(CitizenBaseAPI):
def _get_main_article_json(self, article_id: int) -> Response: def _get_main_article_json(self, article_id: int) -> Response:
return self.get("{}/main/articleJson/{}".format(self.url, article_id)) return self.get("{}/main/articleJson/{}".format(self.url, article_id))
def _post_main_article_comments(self, article: int, page: int = 1) -> Response: def _post_main_article_comments(self, article_id: int, page: int = 1) -> Response:
data = dict(_token=self.token, articleId=article, page=page) data = dict(_token=self.token, articleId=article_id, page=page)
if page: if page:
data.update({'page': page}) data.update({'page': page})
return self.post("{}/main/articleComments".format(self.url), data=data) return self.post("{}/main/articleComments".format(self.url), data=data)
def _post_main_article_comments_create(self, message: str, article: int, parent: int = 0) -> Response: def _post_main_article_comments_create(self, message: str, article_id: int, parent: int = 0) -> Response:
data = dict(_token=self.token, message=message, articleId=article) data = dict(_token=self.token, message=message, articleId=article_id)
if parent: if parent:
data.update({"parentId": parent}) data.update({"parentId": parent})
return self.post("{}/main/articleComments/create".format(self.url), data=data) return self.post("{}/main/articleComments/create".format(self.url), data=data)
@ -177,9 +177,9 @@ class ErepublikArticleAPI(CitizenBaseAPI):
data = dict(_token=self.token, articleId=article_id, amount=amount) data = dict(_token=self.token, articleId=article_id, amount=amount)
return self.post("{}/main/donate-article".format(self.url), data=data) return self.post("{}/main/donate-article".format(self.url), data=data)
def _post_main_write_article(self, title: str, content: str, country: int, kind: int) -> Response: def _post_main_write_article(self, title: str, content: str, country_id: int, kind_id: int) -> Response:
data = dict(_token=self.token, article_name=title, article_body=content, article_location=country, data = dict(_token=self.token, article_name=title, article_body=content, article_location=country_id,
article_category=kind) article_category=kind_id)
return self.post("{}/main/write-article".format(self.url), data=data) return self.post("{}/main/write-article".format(self.url), data=data)
def _post_main_vote_article(self, article_id: int) -> Response: def _post_main_vote_article(self, article_id: int) -> Response:
@ -188,12 +188,12 @@ class ErepublikArticleAPI(CitizenBaseAPI):
class ErepublikCompanyAPI(CitizenBaseAPI): class ErepublikCompanyAPI(CitizenBaseAPI):
def _post_economy_assign_to_holding(self, factory: int, holding: int) -> Response: def _post_economy_assign_to_holding(self, factory_id: int, holding_id: int) -> Response:
data = dict(_token=self.token, factoryId=factory, action="assign", holdingCompanyId=holding) data = dict(_token=self.token, factoryId=factory_id, action="assign", holdingCompanyId=holding_id)
return self.post("{}/economy/assign-to-holding".format(self.url), data=data) return self.post("{}/economy/assign-to-holding".format(self.url), data=data)
def _post_economy_create_company(self, industry: int, building_type: int = 1) -> Response: def _post_economy_create_company(self, industry_id: int, building_type: int = 1) -> Response:
data = {"_token": self.token, "company[industry_id]": industry, "company[building_type]": building_type} data = {"_token": self.token, "company[industry_id]": industry_id, "company[building_type]": building_type}
return self.post("{}/economy/create-company".format(self.url), data=data, return self.post("{}/economy/create-company".format(self.url), data=data,
headers={"Referer": "{}/economy/create-company".format(self.url)}) headers={"Referer": "{}/economy/create-company".format(self.url)})

View File

@ -855,11 +855,7 @@ class CitizenCompanies(BaseCitizen):
Storage={1000: 1, 2000: 2} <- Building_type 2 Storage={1000: 1, 2000: 2} <- Building_type 2
""" """
company_name = {1: "Food", 2: "Weapons", 4: "House", 23: "Aircraft", company_name = constants.INDUSTRIES[industry_id]
7: "FRM q1", 8: "FRM q2", 9: "FRM q3", 10: "FRM q4", 11: "FRM q5",
12: "WRM q1", 13: "WRM q2", 14: "WRM q3", 15: "WRM q4", 16: "WRM q5",
18: "HRM q1", 19: "HRM q2", 20: "HRM q3", 21: "HRM q4", 22: "HRM q5",
24: "ARM q1", 25: "ARM q2", 26: "ARM q3", 27: "ARM q4", 28: "ARM q5", }[industry_id]
if building_type == 2: if building_type == 2:
company_name = "Storage" company_name = "Storage"
self.write_log(f'{company_name} created!') self.write_log(f'{company_name} created!')
@ -1260,8 +1256,8 @@ class CitizenMedia(BaseCitizen):
4: "Political debates and analysis", 5: "Financial business", 4: "Political debates and analysis", 5: "Financial business",
6: "Social interactions and entertainment"} 6: "Social interactions and entertainment"}
if kind in kinds: if kind in kinds:
data = {'title': title, 'content': content, 'country': self.details.citizenship, 'kind': kind} data = {'title': title, 'content': content, 'country': self.details.citizenship.id, 'kind': kind}
resp = self._post_main_write_article(**data) resp = self._post_main_write_article(title, content, self.details.citizenship.id, kind)
try: try:
article_id = int(resp.history[1].url.split("/")[-3]) article_id = int(resp.history[1].url.split("/")[-3])
self._report_action("ARTICLE_PUBLISH", f"Published new article \"{title}\" ({article_id})", kwargs=data) self._report_action("ARTICLE_PUBLISH", f"Published new article \"{title}\" ({article_id})", kwargs=data)