Telegram formatting

This commit is contained in:
Eriks Karls 2019-10-01 09:59:37 +03:00
parent 6b2c073abe
commit 2f8120bd0d
2 changed files with 5 additions and 4 deletions

View File

@ -245,7 +245,6 @@ class SlowRequests(Session):
self._log_request(hist_resp.request.url, "REDIRECT") self._log_request(hist_resp.request.url, "REDIRECT")
self._log_response(hist_resp.request.url, hist_resp, redirect=True) self._log_response(hist_resp.request.url, hist_resp, redirect=True)
# TODO: Must thoroughly check response writing on windows systems
file_data = { file_data = {
"path": 'debug/requests', "path": 'debug/requests',
"time": self.last_time.strftime('%Y-%m-%d_%H-%M-%S'), "time": self.last_time.strftime('%Y-%m-%d_%H-%M-%S'),
@ -1173,7 +1172,9 @@ class TelegramBot:
message = f"Player *{self.player_name}*\n" + message message = f"Player *{self.player_name}*\n" + message
if utils.good_timedelta(utils.now(), datetime.timedelta(seconds=-1)) <= self.__last_time: if utils.good_timedelta(utils.now(), datetime.timedelta(seconds=-1)) <= self.__last_time:
tb = traceback.extract_stack() tb = traceback.extract_stack()
message += "\n\n```\n{}\n```".format("\n".join([' File "{}", line {}, in {}\n'.format(l.filename, l.lineno, l.name) for l in tb])) message += "\n\n```\n{}\n```".format(
"\n".join([' File "{}", line {}, in {}'.format(l.filename, l.lineno, l.name) for l in tb])
)
response = post(self.api_url, json=dict(chat_id=self.chat_id, text=message, parse_mode="Markdown")) response = post(self.api_url, json=dict(chat_id=self.chat_id, text=message, parse_mode="Markdown"))
self.__last_time = utils.now() self.__last_time = utils.now()
return response.json().get('ok') return response.json().get('ok')