From 00a07a4de190edfad5f16e22e238c4b5c37e2cba Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Fri, 26 Jul 2024 17:26:39 +0300 Subject: Added msginfo command --- src/main.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 4bd15fe..203f4ab 100644 --- a/src/main.zig +++ b/src/main.zig @@ -324,6 +324,23 @@ fn onTextCommand(bot: *Bot, msg: types.Message, text: []const u8, cmd: []const u .chat_id = msg.chat.id, }, }); + } else if (std.mem.eql(u8, simple_cmd, "msginfo")) { + if (msg.reply_to_message) |replied| { + const str_data = try std.json.stringifyAlloc(bot.allocator, replied.*, .{ + .whitespace = .indent_2, + .emit_null_optional_fields = false, + }); + defer bot.allocator.free(str_data); + + try bot.sendMessage_(.{ + .chat_id = msg.chat.id, + .text = str_data, + .reply_parameters = .{ + .message_id = msg.message_id, + .chat_id = msg.chat.id, + }, + }); + } } else if (std.mem.eql(u8, simple_cmd, "ping")) { var timer = try std.time.Timer.start(); -- cgit v1.2.3