Put getting mentions in own function

So we can use it somewhere else too.

Regards https://github.com/profanity-im/profanity/issues/1261
This commit is contained in:
Michael Vetter
2020-02-20 10:03:36 +01:00
parent 80dd3fdbb2
commit 1ddac7b9c6
3 changed files with 17 additions and 10 deletions

View File

@@ -510,3 +510,18 @@ get_random_string(int length)
return rand;
}
GSList*
get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick)
{
GSList *mentions = NULL;
char *message_search = case_sensitive ? strdup(message) : g_utf8_strdown(message, -1);
char *mynick_search = case_sensitive ? strdup(nick) : g_utf8_strdown(nick, -1);
mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
g_free(message_search);
g_free(mynick_search);
return mentions;
}