mirror of
https://github.com/catspace-dev/unicheckbot.git
synced 2024-11-22 13:56:34 +03:00
rewrite getting emoji from http code
This commit is contained in:
parent
e5045c76ad
commit
6ab17a0109
|
@ -40,7 +40,8 @@ class APINode:
|
||||||
|
|
||||||
|
|
||||||
HTTP_EMOJI = {
|
HTTP_EMOJI = {
|
||||||
200: "🆗",
|
2: "✅",
|
||||||
404: "🔍",
|
3: "➡️",
|
||||||
500: "☠️",
|
4: "🔍",
|
||||||
}
|
5: "❌️",
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "core"
|
name = "core"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
description = "Types and other core functionality"
|
description = "Types and other core functionality"
|
||||||
authors = ["kiriharu <kiriharu@yandex.ru>"]
|
authors = ["kiriharu <kiriharu@yandex.ru>"]
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ async def prepare_webcheck_message(response: Response) -> str:
|
||||||
status = json_rsp.get("status")
|
status = json_rsp.get("status")
|
||||||
if status == ResponseStatus.OK:
|
if status == ResponseStatus.OK:
|
||||||
status_code = json_rsp['payload']['status_code']
|
status_code = json_rsp['payload']['status_code']
|
||||||
time = round(json_rsp['payload']['time'], 3)
|
time = round(json_rsp['payload']['time'], 2)
|
||||||
message = f"Location, Town: {HTTP_EMOJI.get(status_code, None)} {status_code}, {time} сек."
|
message = f"Location, Town: {HTTP_EMOJI.get(status_code//100, '')} {status_code}, ⏰ {time} сек."
|
||||||
if status == ResponseStatus.ERROR:
|
if status == ResponseStatus.ERROR:
|
||||||
message = json_rsp['payload']['message']
|
message = json_rsp['payload']['message']
|
||||||
message = f"Location, Town: ❌ {message}"
|
message = f"Location, Town: ❌ {message}"
|
||||||
|
@ -48,7 +48,8 @@ async def check_web(message: Message, host: str, port: Optional[int]):
|
||||||
if port is None:
|
if port is None:
|
||||||
port = 80
|
port = 80
|
||||||
rsp_msg = await message.answer(f"Отчет о проверке хоста {host}:{port}...\n\n")
|
rsp_msg = await message.answer(f"Отчет о проверке хоста {host}:{port}...\n\n")
|
||||||
iter_keys = 1
|
iter_keys = 1 # because I can't use enumerate
|
||||||
|
# using generators for magic...
|
||||||
async for res in send_check_requests(host, port):
|
async for res in send_check_requests(host, port):
|
||||||
# set typing status...
|
# set typing status...
|
||||||
await message.bot.send_chat_action(message.chat.id, 'typing')
|
await message.bot.send_chat_action(message.chat.id, 'typing')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user