summaryrefslogtreecommitdiff
path: root/src/Bot.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-07-26 17:26:39 +0300
committerGravatar Uko Kokņevičs2024-07-26 17:26:39 +0300
commit00a07a4de190edfad5f16e22e238c4b5c37e2cba (patch)
tree39775a032e116ccdf2e0412bcf979dc773d330c4 /src/Bot.zig
parentRespect request to wait on submitting requests (diff)
downloadukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.gz
ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.xz
ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.zip
Added msginfo command
Diffstat (limited to 'src/Bot.zig')
-rw-r--r--src/Bot.zig13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/Bot.zig b/src/Bot.zig
index 45717e1..0346d2c 100644
--- a/src/Bot.zig
+++ b/src/Bot.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;
@@ -176,14 +177,6 @@ fn call(
176 } 177 }
177} 178}
178 179
179inline fn isNull(value: anytype) bool {
180 return switch (@typeInfo(@TypeOf(value))) {
181 .Null => true,
182 .Optional => value == null,
183 else => false,
184 };
185}
186
187fn intoQueryString(allocator: Allocator, data: anytype) !?[]u8 { 180fn intoQueryString(allocator: Allocator, data: anytype) !?[]u8 {
188 return switch (@typeInfo(@TypeOf(data))) { 181 return switch (@typeInfo(@TypeOf(data))) {
189 .Null => null, 182 .Null => null,
@@ -195,7 +188,7 @@ fn intoQueryString(allocator: Allocator, data: anytype) !?[]u8 {
195 var counter: usize = 0; 188 var counter: usize = 0;
196 189
197 inline for (s.fields) |field| { 190 inline for (s.fields) |field| {
198 if (!isNull(@field(data, field.name))) { 191 if (!utils.isNull(@field(data, field.name))) {
199 counter += 1; 192 counter += 1;
200 193
201 try sb.ensureUnusedCapacity(field.name.len + 2); 194 try sb.ensureUnusedCapacity(field.name.len + 2);