From: Vsevolod Stakhov Date: Fri, 22 Feb 2019 16:22:04 +0000 (+0000) Subject: [Minor] Lua_selectors: Add languages selector X-Git-Tag: 1.9.0~97 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=43c67de7e23f2018a6cc51a9d187aec9ad928387;p=rspamd.git [Minor] Lua_selectors: Add languages selector Issue: #2763 --- diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 0a02edca9..b678ef179 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -199,6 +199,27 @@ the second optional argument is optional hash type (`blake2`, `sha256`, `sha1`, end, ['description'] = 'Get all attachments files', }, + -- Get languages for text parts + ['languages'] = { + ['get_value'] = function(task) + local text_parts = task:get_text_parts() or E + local languages = {} + + for _,p in ipairs(text_parts) do + local lang = p:get_language() + if lang then + table.insert(languages, lang) + end + end + + if #languages > 0 then + return languages,'string_list' + end + + return nil + end, + ['description'] = 'Get languages for text parts', + }, -- Get helo value ['helo'] = { ['get_value'] = function(task)