From 34b7dc964b3516457f04d00d3ec910d3b6fd585b Mon Sep 17 00:00:00 2001
From: Uko Kokņevičs
Date: Thu, 29 Aug 2024 20:41:04 +0800
Subject: thank you Q&A, now theres proper unicode support n shit
---
src/main.zig | 50 ++++++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 20 deletions(-)
(limited to 'src/main.zig')
diff --git a/src/main.zig b/src/main.zig
index 544b105..2e33cfc 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -199,22 +199,29 @@ fn onTextMessage(bot: *Bot, msg: types.Message, text: []const u8) !void {
},
});
} else if (std.ascii.startsWithIgnoreCase(text, "big ")) {
- var output = ArrayList(u8).init(bot.allocator);
- defer output.deinit();
+ const trimmed = try utils.trim(text[4..]);
+ const cd = try utils.getCD();
+ if (trimmed.len > 0) {
+ const uppercased = try cd.toUpperStr(bot.allocator, trimmed);
+ defer bot.allocator.free(uppercased);
- try output.appendSlice("");
- try utils.escapeXml(output.writer(), text[4..]);
- try output.appendSlice("");
+ var output = ArrayList(u8).init(bot.allocator);
+ defer output.deinit();
- try bot.sendMessage_(.{
- .chat_id = msg.chat.id,
- .text = output.items,
- .parse_mode = .html,
- .reply_parameters = .{
- .message_id = msg.message_id,
+ try output.appendSlice("");
+ try utils.escapeXml(output.writer(), uppercased);
+ try output.appendSlice("");
+
+ try bot.sendMessage_(.{
.chat_id = msg.chat.id,
- },
- });
+ .text = output.items,
+ .parse_mode = .html,
+ .reply_parameters = .{
+ .message_id = msg.message_id,
+ .chat_id = msg.chat.id,
+ },
+ });
+ }
} else if (std.ascii.eqlIgnoreCase(text, "forgor")) {
try bot.sendMessage_(.{
.chat_id = msg.chat.id,
@@ -244,14 +251,17 @@ fn onTextMessage(bot: *Bot, msg: types.Message, text: []const u8) !void {
},
});
} else if (std.ascii.startsWithIgnoreCase(text, "say ")) {
- try bot.sendMessage_(.{
- .chat_id = msg.chat.id,
- .text = text[4..],
- .reply_parameters = .{
- .message_id = msg.message_id,
+ const trimmed = try utils.trim(text[4..]);
+ if (trimmed.len > 0) {
+ try bot.sendMessage_(.{
.chat_id = msg.chat.id,
- },
- });
+ .text = trimmed,
+ .reply_parameters = .{
+ .message_id = msg.message_id,
+ .chat_id = msg.chat.id,
+ },
+ });
+ }
} else if (std.ascii.eqlIgnoreCase(text, "uwu")) {
try bot.sendMessage_(.{
.chat_id = msg.chat.id,
--
cgit v1.2.3