From 0c85cde5598c83414add4e3659a924055df13f46 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Fri, 26 Jul 2024 17:38:38 +0300 Subject: New members are now greeted by a GIF --- src/Bot.zig | 8 ++++++++ src/main.zig | 10 ++++++++-- src/types/SendAnimationParams.zig | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/types/SendAnimationParams.zig (limited to 'src') diff --git a/src/Bot.zig b/src/Bot.zig index 0346d2c..49c5df3 100644 --- a/src/Bot.zig +++ b/src/Bot.zig @@ -74,6 +74,14 @@ pub inline fn getUsername(self: *Bot) ![]const u8 { return self.username.?; } +pub inline fn sendAnimation(self: *Bot, args: types.SendAnimationParams) !Parsed(types.Message) { + return self.post(types.Message, "sendAnimation", args); +} + +pub inline fn sendAnimation_(self: *Bot, args: types.SendAnimationParams) !void { + (try self.sendAnimation(args)).deinit(); +} + pub inline fn sendMessage(self: *Bot, args: types.SendMessageParams) !Parsed(types.Message) { return self.post(types.Message, "sendMessage", args); } diff --git a/src/main.zig b/src/main.zig index 203f4ab..0bc5013 100644 --- a/src/main.zig +++ b/src/main.zig @@ -101,10 +101,16 @@ fn onNewMember(bot: *Bot, msg: types.Message, new_member: types.User) !void { try new_member.writeFormattedName(w); try w.writeAll("! Be on your bestest behaviour now!!"); - try bot.sendMessage_(.{ + try bot.sendAnimation_(.{ .chat_id = msg.chat.id, - .text = sb.items, + // TODO: lol + .animation = "CgACAgQAAx0CVcPEEgACC9Vmo6_zCxMp3ZNXSMM1nI6nMkIhgwACNwMAAtDmDFMop6BHmV7lUTUE", + .duration = 3, + .width = 166, + .height = 240, + .caption = sb.items, .parse_mode = .html, + .show_caption_above_media = true, .reply_parameters = .{ .allow_sending_without_reply = true, .message_id = msg.message_id, diff --git a/src/types/SendAnimationParams.zig b/src/types/SendAnimationParams.zig new file mode 100644 index 0000000..9377b3f --- /dev/null +++ b/src/types/SendAnimationParams.zig @@ -0,0 +1,25 @@ +const MessageEntity = @import("MessageEntity.zig"); +const ParseMode = @import("parse_mode.zig").ParseMode; +const ReplyParameters = @import("ReplyParameters.zig"); + +business_connection_id: ?[]const u8 = null, +// TODO: Integer or String +chat_id: i64, +message_thread_id: ?u64 = null, +// TODO: InputFile or String +animation: []const u8, +duration: ?u64 = null, +width: ?u64 = null, +height: ?u64 = null, +// TODO: InputFile or String +thumbnail: ?[]const u8 = null, +caption: ?[]const u8 = null, +parse_mode: ?ParseMode = null, +caption_entities: ?[]MessageEntity = null, +show_caption_above_media: ?bool = null, +has_spoiler: ?bool = null, +disable_notification: ?bool = null, +protect_content: ?bool = null, +message_effect_id: ?[]const u8 = null, +reply_parameters: ?ReplyParameters = null, +// TODO: reply_markup: InlineKeyboardMarkup OR ReplyKeyboardMarkup OR ReplyKeyboardRemove OR ForceReply -- cgit v1.2.3