summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index 04d4055..544b105 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,5 +1,6 @@
1const types = @import("types.zig");
2const std = @import("std"); 1const std = @import("std");
2const types = @import("types.zig");
3const utils = @import("utils.zig");
3 4
4const Allocator = std.mem.Allocator; 5const Allocator = std.mem.Allocator;
5const ArrayList = std.ArrayList; 6const ArrayList = std.ArrayList;
@@ -198,16 +199,16 @@ fn onTextMessage(bot: *Bot, msg: types.Message, text: []const u8) !void {
198 }, 199 },
199 }); 200 });
200 } else if (std.ascii.startsWithIgnoreCase(text, "big ")) { 201 } else if (std.ascii.startsWithIgnoreCase(text, "big ")) {
201 var output = try bot.allocator.alloc(u8, text.len + 3); 202 var output = ArrayList(u8).init(bot.allocator);
202 defer bot.allocator.free(output); 203 defer output.deinit();
203 204
204 std.mem.copyForwards(u8, output, "<b>"); 205 try output.appendSlice("<b>");
205 _ = std.ascii.upperString(output[3..], text[4..]); 206 try utils.escapeXml(output.writer(), text[4..]);
206 std.mem.copyForwards(u8, output[output.len - 4 ..], "</b>"); 207 try output.appendSlice("</b>");
207 208
208 try bot.sendMessage_(.{ 209 try bot.sendMessage_(.{
209 .chat_id = msg.chat.id, 210 .chat_id = msg.chat.id,
210 .text = output, 211 .text = output.items,
211 .parse_mode = .html, 212 .parse_mode = .html,
212 .reply_parameters = .{ 213 .reply_parameters = .{
213 .message_id = msg.message_id, 214 .message_id = msg.message_id,