mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
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:
parent
80dd3fdbb2
commit
1ddac7b9c6
15
src/common.c
15
src/common.c
@ -510,3 +510,18 @@ get_random_string(int length)
|
|||||||
|
|
||||||
return rand;
|
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;
|
||||||
|
}
|
||||||
|
@ -99,6 +99,7 @@ gboolean is_notify_enabled(void);
|
|||||||
|
|
||||||
GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word,
|
GSList* prof_occurrences(const char *const needle, const char *const haystack, int offset, gboolean whole_word,
|
||||||
GSList **result);
|
GSList **result);
|
||||||
|
GSList* get_mentions(gboolean whole_word, gboolean case_sensitive, const char *const message, const char *const nick);
|
||||||
|
|
||||||
int is_regular_file(const char *path);
|
int is_regular_file(const char *path);
|
||||||
int is_dir(const char *path);
|
int is_dir(const char *path);
|
||||||
|
@ -319,17 +319,8 @@ sv_ev_room_message(ProfMessage *message)
|
|||||||
char *old_plain = message->plain;
|
char *old_plain = message->plain;
|
||||||
message->plain = plugins_pre_room_message_display(message->jid->barejid, message->jid->resourcepart, message->plain);
|
message->plain = plugins_pre_room_message_display(message->jid->barejid, message->jid->resourcepart, message->plain);
|
||||||
|
|
||||||
gboolean whole_word = prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD);
|
GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick);
|
||||||
gboolean case_sensitive = prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE);
|
|
||||||
char *message_search = case_sensitive ? strdup(message->plain) : g_utf8_strdown(message->plain, -1);
|
|
||||||
char *mynick_search = case_sensitive ? strdup(mynick) : g_utf8_strdown(mynick, -1);
|
|
||||||
|
|
||||||
GSList *mentions = NULL;
|
|
||||||
mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
|
|
||||||
gboolean mention = g_slist_length(mentions) > 0;
|
gboolean mention = g_slist_length(mentions) > 0;
|
||||||
g_free(message_search);
|
|
||||||
g_free(mynick_search);
|
|
||||||
|
|
||||||
GList *triggers = prefs_message_get_triggers(message->plain);
|
GList *triggers = prefs_message_get_triggers(message->plain);
|
||||||
|
|
||||||
_clean_incoming_message(message);
|
_clean_incoming_message(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user