fix: use regular emoji for dollar, BTC label for bitcoin
This commit is contained in:
@@ -91,16 +91,9 @@ def utf16_len(s: str) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def build_message(usd: float, btc: float, fng_value: int, fng_label: str) -> tuple[str, list]:
|
def build_message(usd: float, btc: float, fng_value: int, fng_label: str) -> tuple[str, list]:
|
||||||
usd_emoji = "💲"
|
|
||||||
btc_emoji = "💵"
|
|
||||||
btc_str = f"{btc:,.0f}".replace(",", " ")
|
btc_str = f"{btc:,.0f}".replace(",", " ")
|
||||||
prefix = f"{usd_emoji} ₽{usd:.2f} "
|
text = f"💰 ₽{usd:.2f} BTC: ${btc_str} 😱 {fng_value} ({fng_label})"
|
||||||
text = f"{prefix}{btc_emoji} ${btc_str} 😱 {fng_value} ({fng_label})"
|
return text, []
|
||||||
entities = [
|
|
||||||
{"type": "custom_emoji", "offset": 0, "length": utf16_len(usd_emoji), "custom_emoji_id": "5229186695072590160"},
|
|
||||||
{"type": "custom_emoji", "offset": utf16_len(prefix), "length": utf16_len(btc_emoji), "custom_emoji_id": "5438436707164761151"},
|
|
||||||
]
|
|
||||||
return text, entities
|
|
||||||
|
|
||||||
|
|
||||||
def post_telegram_ipv4(url: str, payload: dict, timeout: float = 10.0) -> dict:
|
def post_telegram_ipv4(url: str, payload: dict, timeout: float = 10.0) -> dict:
|
||||||
@@ -176,8 +169,9 @@ def edit_pinned_message(text: str, entities: list) -> None:
|
|||||||
"chat_id": TELEGRAM_CHAT_ID,
|
"chat_id": TELEGRAM_CHAT_ID,
|
||||||
"message_id": int(TELEGRAM_MESSAGE_ID),
|
"message_id": int(TELEGRAM_MESSAGE_ID),
|
||||||
"text": text,
|
"text": text,
|
||||||
"entities": entities,
|
|
||||||
}
|
}
|
||||||
|
if entities:
|
||||||
|
payload["entities"] = entities
|
||||||
try:
|
try:
|
||||||
with httpx.Client(timeout=10.0) as client:
|
with httpx.Client(timeout=10.0) as client:
|
||||||
response = client.post(url, json=payload)
|
response = client.post(url, json=payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user