From e5185f65051f881bf61e88542a1acd4957f8383b Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 3 Aug 2025 12:54:12 +0300 Subject: Move bot configuration to SQL land --- src/Bot.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Bot.zig') diff --git a/src/Bot.zig b/src/Bot.zig index b0eb972..fb91b3f 100644 --- a/src/Bot.zig +++ b/src/Bot.zig @@ -6,6 +6,7 @@ const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const Bot = @This(); const Config = @import("Config.zig"); +const DB = @import("DB.zig"); const HttpClient = std.http.Client; const HttpMethod = std.http.Method; const Parsed = std.json.Parsed; @@ -14,6 +15,7 @@ const Uri = std.Uri; allocator: Allocator, http_client: HttpClient, config: Config, +db: *DB, base_uri: Uri = Uri.parse("https://api.telegram.org/") catch unreachable, uri_path_data: ArrayList(u8), poweron: bool = true, @@ -21,7 +23,7 @@ server_header_buffer: [4096]u8 = undefined, username: ?[]const u8 = null, id: ?i64 = null, -pub fn init(allocator: Allocator, config: Config) !Bot { +pub fn init(allocator: Allocator, config: Config, db: *DB) !Bot { var uri_path_data = try ArrayList(u8).initCapacity(allocator, 5 + config.bot_token.len); errdefer uri_path_data.deinit(); @@ -35,6 +37,7 @@ pub fn init(allocator: Allocator, config: Config) !Bot { .allocator = allocator, }, .config = config, + .db = db, .uri_path_data = uri_path_data, }; } @@ -47,6 +50,10 @@ pub fn deinit(self: *Bot) void { self.* = undefined; } +pub inline fn answerCallbackQuery(self: *Bot, args: types.AnswerCallbackQueryParams) !void { + (try self.post(bool, "answerCallbackQuery", args)).deinit(); +} + pub inline fn deleteMessage(self: *Bot, args: types.DeleteMessageParams) !void { (try self.post(bool, "deleteMessage", args)).deinit(); } -- cgit v1.2.3