From 7df2ced19ccda7fd34accfd57a9c1b924a222d4b Mon Sep 17 00:00:00 2001 From: Piosec Date: Tue, 19 Jul 2022 10:36:28 +0200 Subject: [PATCH 1/2] Update utils.go Add new condition while length > 2 on LinkedIn module Add new email format, 2 first characters of the last name --- src/modules/linkedin/utils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/linkedin/utils.go b/src/modules/linkedin/utils.go index af2ec56..64acccc 100644 --- a/src/modules/linkedin/utils.go +++ b/src/modules/linkedin/utils.go @@ -82,10 +82,26 @@ func (options *Options) getPeople(companyID, start int) []string { email = strings.ReplaceAll(email, "{f}", name[0][0:1]) email = strings.ReplaceAll(email, "{last}", name[1]) email = strings.ReplaceAll(email, "{l}", name[1][0:1]) + email = strings.ReplaceAll(email, "{l2}", name[1][0:2]) + email = strings.ToLower(unidecode.Unidecode(email)) + log.Success(email + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text) + output = append(output, email) + } else if len(name) > 2 && options.Email { + var email string + var last string + email = options.Format + last = strings.TrimRight(name[1],",") + log.Verbose(name[0] + " - " + name[1]) + email = strings.ReplaceAll(email, "{first}", name[0]) + email = strings.ReplaceAll(email, "{f}", name[0][0:1]) + email = strings.ReplaceAll(email, "{last}", last) + email = strings.ReplaceAll(email, "{l}", last[0:1]) + email = strings.ReplaceAll(email, "{l2}", last[0:2]) email = strings.ToLower(unidecode.Unidecode(email)) log.Success(email + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text) output = append(output, email) } + if !options.Email { result := people.Title.Text + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text log.Success(result) From 5c47d8502ab890e3dd7662faed886ceaa9ac71dc Mon Sep 17 00:00:00 2001 From: nodauf Date: Tue, 19 Jul 2022 13:59:19 +0200 Subject: [PATCH 2/2] Merge the two conditions --- src/modules/linkedin/utils.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/modules/linkedin/utils.go b/src/modules/linkedin/utils.go index 64acccc..a0834f7 100644 --- a/src/modules/linkedin/utils.go +++ b/src/modules/linkedin/utils.go @@ -73,24 +73,12 @@ func (options *Options) getPeople(companyID, start int) []string { } // Parse the name to output in the specified format name := strings.Split(people.Title.Text, " ") - // If the name is composed of more than 2 words or the email should not be guessed, we skip it - if len(name) == 2 && options.Email { - var email string - email = options.Format - log.Verbose(name[0] + " - " + name[1]) - email = strings.ReplaceAll(email, "{first}", name[0]) - email = strings.ReplaceAll(email, "{f}", name[0][0:1]) - email = strings.ReplaceAll(email, "{last}", name[1]) - email = strings.ReplaceAll(email, "{l}", name[1][0:1]) - email = strings.ReplaceAll(email, "{l2}", name[1][0:2]) - email = strings.ToLower(unidecode.Unidecode(email)) - log.Success(email + " - " + people.PrimarySubtitle.Text + " - " + people.SecondarySubtitle.Text) - output = append(output, email) - } else if len(name) > 2 && options.Email { + // If the name is composed of less than 2 words or the email should not be guessed, we skip it + if len(name) >= 2 && options.Email { var email string var last string email = options.Format - last = strings.TrimRight(name[1],",") + last = strings.TrimRight(name[1], ",") log.Verbose(name[0] + " - " + name[1]) email = strings.ReplaceAll(email, "{first}", name[0]) email = strings.ReplaceAll(email, "{f}", name[0][0:1])