From d4a285215fdb5c4c5f7406158207450bfeba5588 Mon Sep 17 00:00:00 2001 From: Yuuta Liang Date: Wed, 3 Apr 2024 16:35:29 -0700 Subject: Fix ranking --- query.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/query.c b/query.c index 336f0c5..80b92aa 100644 --- a/query.c +++ b/query.c @@ -70,6 +70,9 @@ int handle_inline(struct TdUpdateNewInlineQuery *update) { } goto cleanup; } + if ((r = sqlite3_bind_int64(stmt_personal_stat, 2, update->sender_user_id_))) { + goto sql_err; + } switch (r = sqlite3_step(stmt_personal_stat)) { case SQLITE_ROW: { @@ -86,7 +89,11 @@ int handle_inline(struct TdUpdateNewInlineQuery *update) { } } - snprintf(msg_stat, sizeof(msg_stat), "我已经卖了 %d 句菜,TGCN 排名 %d / %d", personal_stat, ranking, total); + if (ranking > 0) { + snprintf(msg_stat, sizeof(msg_stat), "我已经卖了 %d 句菜,TGCN 排名 %d / %d", personal_stat, ranking, total); + } else { + snprintf(msg_stat, sizeof(msg_stat), "您从未卖过菜!"); + } snprintf(id_temp, sizeof(id_temp), "s%lld", update->sender_user_id_); results_inline[0] = create_inline_result(id_temp, "卖菜统计", "点击发送卖菜统计", msg_stat); effective_items_count++; -- cgit v1.2.3