From cbbad1f5666950ab9aa0751aeee73403b1c2cd83 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sat, 31 Aug 2024 07:02:07 +0300 Subject: replace trimming with just checking if the string is whitespace --- src/main.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 2e33cfc..b164284 100644 --- a/src/main.zig +++ b/src/main.zig @@ -199,10 +199,10 @@ fn onTextMessage(bot: *Bot, msg: types.Message, text: []const u8) !void { }, }); } else if (std.ascii.startsWithIgnoreCase(text, "big ")) { - const trimmed = try utils.trim(text[4..]); - const cd = try utils.getCD(); - if (trimmed.len > 0) { - const uppercased = try cd.toUpperStr(bot.allocator, trimmed); + const the_text = text[4..]; + if (!try utils.isTgWhitespaceStr(the_text)) { + const cd = try utils.getCD(); + const uppercased = try cd.toUpperStr(bot.allocator, the_text); defer bot.allocator.free(uppercased); var output = ArrayList(u8).init(bot.allocator); @@ -251,11 +251,11 @@ fn onTextMessage(bot: *Bot, msg: types.Message, text: []const u8) !void { }, }); } else if (std.ascii.startsWithIgnoreCase(text, "say ")) { - const trimmed = try utils.trim(text[4..]); - if (trimmed.len > 0) { + const the_text = text[4..]; + if (!try utils.isTgWhitespaceStr(the_text)) { try bot.sendMessage_(.{ .chat_id = msg.chat.id, - .text = trimmed, + .text = the_text, .reply_parameters = .{ .message_id = msg.message_id, .chat_id = msg.chat.id, -- cgit v1.2.3