From 1d1df7b540721d58db174764a0f720e3c638a67b Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Tue, 22 Jul 2025 08:23:22 +0300 Subject: Whitelist allowed inline bots Also update to Zig 0.14.1 Also don't send the animations rn --- src/utils.zig | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/utils.zig') diff --git a/src/utils.zig b/src/utils.zig index b739f6f..b5d9f19 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -2,8 +2,8 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; -const CaseData = @import("CaseData"); -const GenCatData = @import("GenCatData"); +const GeneralCategories = @import("GeneralCategories"); +const LetterCasing = @import("LetterCasing"); const Utf8View = std.unicode.Utf8View; pub fn escapeXml(writer: anytype, text: []const u8) !void { @@ -18,41 +18,41 @@ pub fn escapeXml(writer: anytype, text: []const u8) !void { } } -var gcd_global: ?GenCatData = null; +var gc_global: ?GeneralCategories = null; -pub fn getGCD() !GenCatData { - if (gcd_global) |gcd| { - return gcd; +pub fn getGC() !GeneralCategories { + if (gc_global) |gc| { + return gc; } - gcd_global = try GenCatData.init(std.heap.page_allocator); - return gcd_global.?; + gc_global = try GeneralCategories.init(std.heap.page_allocator); + return gc_global.?; } -var cd_global: ?CaseData = null; +var lc_global: ?LetterCasing = null; -pub fn getCD() !CaseData { - if (cd_global) |cd| { - return cd; +pub fn getLetterCasing() !LetterCasing { + if (lc_global) |lc| { + return lc; } - cd_global = try CaseData.init(std.heap.page_allocator); - return cd_global.?; + lc_global = try LetterCasing.init(std.heap.page_allocator); + return lc_global.?; } pub inline fn isNull(value: anytype) bool { return switch (@typeInfo(@TypeOf(value))) { - .Null => true, - .Optional => value == null, + .null => true, + .optional => value == null, else => false, }; } pub fn isTgWhitespaceStr(str: []const u8) !bool { const view = try Utf8View.init(str); - const gcd = try getGCD(); + const gc = try getGC(); var it = view.iterator(); while (it.nextCodepoint()) |cp| { - if (!isTgWhitespace(gcd, cp)) { + if (!isTgWhitespace(gc, cp)) { return false; } } @@ -60,7 +60,7 @@ pub fn isTgWhitespaceStr(str: []const u8) !bool { return true; } -inline fn isTgWhitespace(gcd: GenCatData, cp: u21) bool { - return gcd.isSeparator(cp) or gcd.isControl(cp) or cp == 0x2800 // BRAILLE PATTERN BLANK, telegram treats messages with just this as invalid messages +inline fn isTgWhitespace(gc: GeneralCategories, cp: u21) bool { + return gc.isSeparator(cp) or gc.isControl(cp) or cp == 0x2800 // BRAILLE PATTERN BLANK, telegram treats messages with just this as invalid messages ; } -- cgit v1.2.3