12th anniversary minimal methods

This commit is contained in:
Eriks Karls 2019-11-21 11:06:29 +02:00
parent aedfbf4465
commit 90bec82630
2 changed files with 24 additions and 2 deletions

View File

@ -82,7 +82,8 @@ class Citizen(CitizenAPI):
self.telegram.do_init(self.config.telegram_chat_id or 620981703,
self.config.telegram_token or "864251270:AAFzZZdjspI-kIgJVk4gF3TViGFoHnf8H4o",
"" if self.config.telegram_chat_id or self.config.telegram_token else self.name)
self.telegram.send_message(f"*Started* {now():%F %T}")
self.telegram.send_message(f"*Started* {now():%F %T}")
self.__last_full_update = good_timedelta(self.now, - timedelta(minutes=5))
def write_log(self, *args, **kwargs):
@ -2015,3 +2016,16 @@ class Citizen(CitizenAPI):
def vote_article(self, article_id: int) -> bool:
resp = self._post_main_vote_article(article_id).json()
return not bool(resp.get('error'))
def get_anniversary_quest_data(self):
return self._get_anniversary_quest_data().json()
def start_unlocking_map_quest_node(self, node_id: int):
return self._post_map_rewards_unlock(node_id)
def collect_map_quest_node(self, node_id: int):
return self._post_map_rewards_claim(node_id)
def speedup_map_quest_node(self, node_id: int):
node = self.get_anniversary_quest_data().get('cities', {}).get(str(node_id), {})
return self._post_map_rewards_speedup(node_id, node.get("skipCost", 0))

View File

@ -906,6 +906,14 @@ Class for unifying eRepublik known endpoints and their required/optional paramet
data = {'nodeId': node_id, '_token': self.token}
return self.post("{}/main/map-rewards-unlock".format(self.url), data=data)
def _post_map_rewards_speedup(self, node_id: int, currency_amount: int) -> Response:
data = {'nodeId': node_id, '_token': self.token, "currencyCost": currency_amount}
return self.post("{}/main/map-rewards-speedup".format(self.url), data=data)
def _post_map_rewards_claim(self, node_id: int) -> Response:
data = {'nodeId': node_id, '_token': self.token}
return self.post("{}/main/map-rewards-claim".format(self.url), data=data)
class Reporter:
__to_update: List[Dict[Any, Any]] = []
@ -1168,7 +1176,7 @@ class TelegramBot:
self._threads = [t for t in self._threads if t.is_alive()]
self._next_time = utils.good_timedelta(utils.now(), datetime.timedelta(minutes=1))
if not self._threads:
name = "telegram_send"
name = "telegram_{}send".format(f"{self.player_name}_" if self.player_name else "")
send_thread = threading.Thread(target=self.__send_messages, name=name)
send_thread.start()
self._threads.append(send_thread)