From b5e2c41f7445882596e992d3a06ce146911ff8c3 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Tue, 7 Sep 2021 11:12:39 -0700 Subject: Revert "feat: remove [t.me] links" This reverts commit 94d16a76d9b710fc88231ef89439d2db4821265b. --- main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.c b/main.c index 2094be8..50d05ff 100644 --- a/main.c +++ b/main.c @@ -69,6 +69,7 @@ void *main_tg2mc(void *e) char msg[4097]; char name[1024]; char username[512]; + char url[512]; char uid[32]; int32_t max_upd_id = 0; run: @@ -191,6 +192,22 @@ run: json_object *obj2 = json_object_new_object(); json_object_array_add(req_root, obj2); json_object_object_add(obj2, "text", json_object_new_string(msg)); + json_object *obj3 = json_object_new_object(); + json_object_array_add(req_root, obj3); + json_object_object_add(obj3, "text", json_object_new_string("[t.me]")); + json_object_object_add(obj3, "underlined", json_object_new_boolean(1)); + json_object_object_add(obj3, "color", json_object_new_string("dark_aqua")); + json_object *obj3_click_event = json_object_new_object(); + json_object_object_add(obj3, "clickEvent", obj3_click_event); + json_object_object_add(obj3_click_event, "action", json_object_new_string("open_url")); + sprintf(url, env->tg_link_fmt, tgmsg->message_id); + json_object_object_add(obj3_click_event, "value", json_object_new_string(url)); + json_object *obj3_hover_event = json_object_new_object(); + json_object_object_add(obj3, "hoverEvent", obj3_hover_event); + json_object_object_add(obj3_hover_event, "action", json_object_new_string("show_text")); + json_object *obj3_hv_contents = json_object_new_object(); + json_object_object_add(obj3_hover_event, "contents", obj3_hv_contents); + json_object_object_add(obj3_hv_contents, "text", json_object_new_string("View in Telegram")); const char *json = json_object_to_json_string(req_root); cmd = calloc(strlen(json) + 11 /* "tellraw @a " */ + 1, sizeof(char)); sprintf(cmd, "tellraw @a %s", json); -- cgit v1.2.3