const std = @import("std"); const types = @import("types.zig"); const utils = @import("utils.zig"); const Bot = @import("Bot.zig"); const whitelist = [_]i64{ 90832338, // @vid 109158646, // @bing 114528005, // @pic 136269978, // @ImageFetcherBot 140267078, // @gif 154595593, // @wiki 184730458, // @UnitConversionBot 223493268, // @minroobot 296635833, // @lastfmrobot 473587803, // @LyBot 595898211, // @DeezerMusicBot 733460033, // @crabravebot 870410041, // @HowGayBot 7904498194, // @tanstiktokbot }; const blacklist = [_]i64{ 6465471545, // @DickGrowerBot 7759097490, // @CookieGrowerBot }; comptime { std.testing.expect(utils.isSorted(i64, &whitelist)) catch unreachable; std.testing.expect(utils.isSorted(i64, &blacklist)) catch unreachable; } inline fn isWhitelisted(bot: types.User) bool { return utils.isIn(i64, bot.id, &whitelist); } inline fn isBlacklisted(bot: types.User) bool { return utils.isIn(i64, bot.id, &blacklist); } // Returns true if processing of message should continue pub fn onInlineBot(bot: *Bot, msg: types.Message, via: types.User) !bool { if (isWhitelisted(via)) { return true; } std.log.info("Deleting an unallowed inline bot message from {?s} {}", .{ via.username, via.id }); try bot.deleteMessage(.{ .chat_id = msg.chat.id, .message_id = msg.message_id, }); if (!isBlacklisted(via)) { // Not explicitly blacklisted, notify dev group const text = try std.fmt.allocPrint( bot.allocator, "Deleted a message sent via inline bot @{?s} {}", .{ via.username, via.id }, ); defer bot.allocator.free(text); try bot.sendMessage_(.{ .chat_id = bot.config.dev_group, .text = text, .parse_mode = .html, }); } return false; }